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(upgrade-job): avoid quotes when setting yaml bools, null, int #334

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

niladrih
Copy link
Member

@niladrih niladrih commented Aug 29, 2023

This PR fixes a the case when yq sets a value other than a string on to a yaml file (i.e. a bool or a null). This removes the " character surrounding the set value when the value set is 'true', 'false', an int or 'null'.

Description

This upgrade-job needs to be idempotent. The job may restart, and it has to be able to avoid repeating itself. The yq_set_string_value() method sets values with "" surrounding the values. This works well with the other set values that the helm::values module uses, however, with eventing.enabled, the value that is expected is a bool, but the yq_set_string_value() method's quotes sets it as a string. The first helm upgrade run (without restarts), works fine, as helm is able to derive the bool value out of the string. However, the helm::chart module expects the eventing.enabled key to have a value of type bool.

This change in the this PR, matches the boolean values 'true' and 'false' to decide if it should avoid using "" around the value before setting it. This change also handles the cases for 'null' and integer values.

How Has This Been Tested?

Tested manually using a kubeadm cluster.

Copy link
Member

@avishnu avishnu left a comment

Choose a reason for hiding this comment

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

Looks ok. Do we need any better fix in the future?

@niladrih niladrih changed the title fix(upgrade-job): avoid quotes when setting yaml bools and null fix(upgrade-job): avoid quotes when setting yaml bools, null, int Aug 29, 2023
@niladrih
Copy link
Member Author

Looks ok. Do we need any better fix in the future?

I think we could make it look prettier, with better syntax. Functionally, we should be good. We could simplify by giving each of these types their own set function -- IMO this is unnecessary. WDYT @tiagolobocastro?

@niladrih
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented Aug 29, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 4ee31f6 into develop Aug 29, 2023
@bors bors bot deleted the fix-yq-set branch August 29, 2023 16:30
bors bot pushed a commit that referenced this pull request Aug 29, 2023
335: Cherry-pick PR #334 to release/2.4 branch r=niladrih a=niladrih

This PR cherry-picks the commits from the following PRs to release/2.4 branch:
- #334 

Co-authored-by: Niladri Halder <[email protected]>
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.

3 participants