-
Notifications
You must be signed in to change notification settings - Fork 180
fix: performance issues yq #261 #288
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
Conversation
Using jq for faster recursive key deletion. fix #261
0-sv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome that the performance is improved now. It might be a "nice to have" and not a "must have" for this change, but since the generate_loose_schema function is a module in the bin/bootstrap.sh script (ie. it can be tested by bats by importing the function), you could add a test to bin/tests with an example sourcePath and targetPath testing this function.
Morriz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please ditch the "tests" that were just added
bin/tests/bootstrap.bats
Outdated
| result=$(yq r "$PWD/values-schema.yaml" '**.required.' | wc -l) | ||
| [ "$result" -ne 0 ] | ||
| result=$(yq r "$PWD/values-schema.yaml" 'properties.toolsVersion' | wc -l) | ||
| [ "$result" -ne 0 ] | ||
| result=$(yq r "$PWD/values-schema.yaml" 'properties.cluster' | wc -l) | ||
| [ "$result" -ne 0 ] | ||
|
|
||
| result=$(yq r "$ENV_DIR/.vscode/values-schema.yaml" '**.required.' | wc -l) | ||
| [ "$result" -eq 0 ] | ||
| result=$(yq r "$ENV_DIR/.vscode/values-schema.yaml" 'properties.toolsVersion' | wc -l) | ||
| [ "$result" -eq 0 ] | ||
| result=$(yq r "$ENV_DIR/.vscode/values-schema.yaml" 'properties.cluster' | wc -l) | ||
| [ "$result" -eq 0 ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we suddenly addings tests that only test the workings of yq here? Can we discuss these things first? This is undesirable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Morriz was discussed as desirable during standup.
It is not testing the workings of yq, but verifying that the original yaml contains these keys, and the new yaml does not contain these keys.
So it verifies that the (now speed optimized) removes these fields correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is testing nothing of our code. It is merely testing if yq does what you ask it to do. Call me if you want further clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Morriz we could've discussed this during stand-up. It can't be that you have to micro-manage every piece of code, it's like you don't trust anyone.
I'm just going to lay out how I experienced it. First you create an issue that the performance of the bats testing is not good. That's true, it takes about 30 seconds. Of course there's yq to blame, but it's not nice to reproach me about code you added. Then when I mention the performance gain of piping to jq, you don't believe me.
Now this test will actually test if the behaviour is the same of pre-jq and post-jq. It's about 6 lines of code and to me it seems like this would improve coverage because the logic is actually in the function generate_loose_schema. If someone adds a different piece of logic, say, we don't need to remove the required keys anymore (I don't actually understand why those need to be removed in the first place, since it's valid json schema), then this test will complain and that makes it easier to debug.
Of course, if there is anything wrong about my reasoning then I'm open to learn from you, as always.
Dunky13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Morriz why use the v for version?
|
@Morriz could it be that since you had me remove the "toolsVersion" definition in I don't know how to proceed to fix this and have CI stop complaining. And it also seems out-of-scope for this issue/task. Should we revert & recreate in separate issue? |
|
It is about relationship with a version the context expects. Indeed it can happen that all contexts demand an upgrade (like for kubectl minor bumps), but a one for all approach could introduce a breaking change that breaks a context demanding the old image.
Maybe I see this wrong but now we have control over that. If we can avoid such breakages and instead use one for all that would be great. But we have to rely on code for that, not human process.
I don’t see that go away easily.
|
I can agree with this proposition, and I definitely see the benefits. Of course, I could also argue that detecting breaking changes should be part of our CI. Besides that, I don't see why this should be part of this task, it seems like something we should discuss. I hope we can enter a discourse on this topic. |
|
@Dunky13 can you resolve these conflicts? You can ask help from me tomorrow if needed... |
I would love to, but have not been able to resolve this (yet). Help is necessary |
|
@Morriz but can we please stay within the issue of improving yq performance? |
Had some merge conflicts when merging from master. Resolved in this commit #288
Discussed with @j-zimnowoda t oadd this docs line #288
The issue was that the schema did not contain the toolsVersion, and therefor threw an error. As suggested by @j-zimnowoda the toolsVersion is added back, with a readOnly tag and a description. If this is not present, the merged values from the env.gotmpl will fail during testing. #288
@Morriz, adding |
|
Then that was caught by our update. Great! So it should be removed from the values. |
Morriz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small potatoes left
core.yaml
Outdated
| @@ -1,3 +1,4 @@ | |||
| # NOTE: This file is merged with other values in ./helmfile.d/snippets/env.gotmpl | |||
| toolsVersion: 1.4.9 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line has to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That line was suggested by @j-zimnowoda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I suggested it because it is not obvious that core.yaml is part of merged values.
Our colleagues spend a significant time on finding out the root cause of the validation issue, because they did not know about that. I think it is worth to have this command if it can save someone's time in the future.
Removing toolsVersion from all yaml files, as well as updating the BATS docs #288
Morriz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAY!
Using jq for faster recursive key deletion.
fix #261