Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[payment] don't rely on VERSION env var #5189

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

JanKoehnlein
Copy link
Contributor

Fixes #5187

@roboquat roboquat requested a review from laushinka August 13, 2021 11:39
@JanKoehnlein
Copy link
Contributor Author

/schedule
/assign

@JanKoehnlein JanKoehnlein force-pushed the jankoehnlein/payment-endpoint-is-5187 branch from aaa1da5 to 2097115 Compare August 13, 2021 11:54
@JanKoehnlein
Copy link
Contributor Author

/cc @jankeromnes

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't feel very legitimate in reviewing this change, as I don't see what sort of side-effects it could have.

Still, if this change is urgent, I'll approve it to unblock it. I guess if it builds & deploys fine, it means there are no deal-breaking problems.

If I understand correctly, you're moving version from AbstractComponentEnv into Env, in order to no longer have it in Config (what a terribly ambiguous class name 🙈).

Looking through the code, I couldn't spot any obvious dangers, except maybe for this part which looks supicious to me (because it seems to somehow cast Config to Env and then call fromEnv, which relies on .version to exist):

bind(Config).toDynamicValue(ctx => {
const env = ctx.container.get<Env>(Env);
return EnvConfig.fromEnv(env);
}).inSingletonScope();

But maybe this is actually fine and I just don't understand this code.


An alternative fix could be to not move version, but give a default value as second parameter to getEnvVar (thus the call wouldn't fail even if VERSION isn't set).

For example like so (still in AbstractComponentEnv):

-    readonly version: string = getEnvVar('VERSION');
+    readonly version: string = getEnvVar('VERSION', 'unknown');

/hold

@roboquat
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7d61502ede12f9ab6f28417d2c5ffd942ae01e9a

@roboquat
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jankeromnes

Associated issue: #5187

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JanKoehnlein
Copy link
Contributor Author

Thanks @jankeromnes for the review. I think you are very legitimate to judge this change.

except maybe for this part which looks suspicious to me (because it seems to somehow cast Config to Env and then call fromEnv, which relies on .version to exist)

That should be fine, because a) the source is Env which has version and b) it's in the server component that has the env variable VERSION set in its values.yaml.

An alternative fix could be to not move version, but give a default value as second parameter to getEnvVar

That's what I was considering as well, but in the end I decided it's safer to not have a field declared than to allow it have a bogus value.

@JanKoehnlein
Copy link
Contributor Author

/uncc @laushinka

@roboquat roboquat removed the request for review from laushinka August 16, 2021 08:08
@JanKoehnlein
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit 6f70036 into main Aug 16, 2021
@roboquat roboquat deleted the jankoehnlein/payment-endpoint-is-5187 branch August 16, 2021 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Payment-endpoint is crash-looping
3 participants