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

fix(artifact): more resilient app version parsing #948

Merged
merged 2 commits into from
Mar 31, 2020

Conversation

emjburns
Copy link
Contributor

This PR name might lead you to think that this is less hacky than before. It's not. It's just more wacky-input-safe.

@emjburns emjburns requested review from a team, asher, robfletcher, lorin, luispollo and gal-yardeni and removed request for a team March 31, 2020 00:13
Comment on lines +165 to +175
val appversion = AppVersion.parseName(version)
if (appversion?.version != null) {
summary = summary.copy(displayName = appversion.version)
}
if (appversion?.buildNumber != null) {
summary = summary.copy(build = BuildMetadata(id = appversion.buildNumber.toInt()))
}
if (appversion?.commit != null) {
summary = summary.copy(git = GitMetadata(commit = appversion.commit))
}
summary
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm failing to see how this is different from what you had before, other than setting displayName outside this block above. I find this format harder to read than the one with the property names and inline if statements to the left. It's also potentially copying the whole object 3 times over which I know is not a huge deal but I feel if we just let these spread they may become a problem.

Copy link
Contributor

@lorin lorin Mar 31, 2020

Choose a reason for hiding this comment

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

I believe the current problem is that appversion.buildNumber is null for one of the artifacts, so the appversion.buildNumber.toInt() call fails on line 162. In the new implementation, this call is guarded by a null chcek in line 169.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lorin is correct. Again, this code should be replaced in Q2.

@lorin
Copy link
Contributor

lorin commented Mar 31, 2020

I'd love to see a unit test against the problematic artifact version to verify that the code no longer throws an exception on it.

// todo: replace, this is brittle
val appversion = AppVersion.parseName(version)
if (appversion?.version != null) {
summary = summary.copy(displayName = appversion.version)
Copy link
Contributor

@lorin lorin Mar 31, 2020

Choose a reason for hiding this comment

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

Do we ever expect fields of appversion to be null during normal operation? If not, if this if check fails, I'd put a WARN level log statement with the value of theversion function argument to make it easier to debug in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we might fail, we might not fail if that's the case. it definitely puts us into a weird state. once we pull the appversion off the ami though it shouldn't be null. we don't rely on any of the other fields that i'm using here (if i remember correctly). Logging would probably be helpful, you're right.

Copy link
Contributor

@lorin lorin left a comment

Choose a reason for hiding this comment

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

I made comments, but would like to see this get out to put us back in a good state.

@luispollo luispollo added the ready to merge Approved and ready for merge label Mar 31, 2020
@mergify mergify bot merged commit a977f01 into spinnaker:master Mar 31, 2020
@mergify mergify bot added the auto merged label Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged ready to merge Approved and ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants