Skip to content

Conversation

@Dunky13
Copy link
Contributor

@Dunky13 Dunky13 commented Jan 22, 2021

Using jq for faster recursive key deletion.

fix #261

Using jq for faster recursive key deletion.

fix #261
@Dunky13 Dunky13 requested review from 0-sv and Morriz January 22, 2021 10:35
@Dunky13 Dunky13 self-assigned this Jan 22, 2021
Copy link
Contributor

@0-sv 0-sv left a 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.

Copy link
Contributor

@Morriz Morriz left a 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

Comment on lines 67 to 79
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 ]
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Removed a couple of "configurable" options and made them hard coded as well as fixing a couple of
bash issues like `"$@"`

#261 #288
Copy link
Contributor Author

@Dunky13 Dunky13 left a 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?

@Dunky13
Copy link
Contributor Author

Dunky13 commented Jan 29, 2021

@Morriz could it be that since you had me remove the "toolsVersion" definition in value-schema.yaml that since there is still a "toolsVersion" key/value in core.yaml and chars/team-ns/values.yaml that the validate-values complains?

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?

@Morriz
Copy link
Contributor

Morriz commented Jan 29, 2021 via email

@0-sv
Copy link
Contributor

0-sv commented Feb 1, 2021

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.

@Morriz
Copy link
Contributor

Morriz commented Feb 2, 2021

@Dunky13 can you resolve these conflicts? You can ask help from me tomorrow if needed...

@Dunky13
Copy link
Contributor Author

Dunky13 commented Feb 2, 2021

@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

@0-sv
Copy link
Contributor

0-sv commented Feb 3, 2021

@Morriz but can we please stay within the issue of improving yq performance?

Marc Went added 3 commits February 3, 2021 11:16
Had some merge conflicts when merging from master. Resolved in this commit

#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
@j-zimnowoda
Copy link
Contributor

@Morriz could it be that since you had me remove the "toolsVersion" definition in value-schema.yaml that since there is still a "toolsVersion" key/value in core.yaml and chars/team-ns/values.yaml that the validate-values complains?

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?

@Morriz, adding toolsVersion value in core.yaml file and not defining this property in values-schema.yaml causes validation error. Before requesting changes and enforcing them, please think about how does it work. Otherwise you are providing very confusing requirements that people cannot meet.

@Morriz
Copy link
Contributor

Morriz commented Feb 3, 2021

Then that was caught by our update. Great! So it should be removed from the values.

Copy link
Contributor

@Morriz Morriz left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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 Morriz self-requested a review February 4, 2021 17:08
Copy link
Contributor

@Morriz Morriz left a comment

Choose a reason for hiding this comment

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

YAY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

performance issues yq

5 participants