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

left-pad helm chart filenames with 0s to fix sorting #4106

Conversation

laverya
Copy link
Contributor

@laverya laverya commented Feb 21, 2024

Description

Fixes # (issue)

Currently, helm chart apply order is determined by sorting the helm chart manifest filenames. The order is included as the first element in the filename, resulting in names like 1_helm_extension_chartname.yaml.

Manifests are fetched here, which uses filepath.Glob, which calls sort on the results.

Unfortunately, this breaks at 10 - 10_helm_extension_anothername.yaml is alphabetically before 1_helm_extension_chartname.yaml.

This PR adds a fmt directive to left-pad these integers to 9 digits, which allows sorting to work properly - see https://go.dev/play/p/THZg3TD6eHI.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@laverya
Copy link
Contributor Author

laverya commented Feb 21, 2024

I'm trying to work out how to add an auto test - is there a way to specify a config to be applied in CI? If so, I can just have two charts order 1 and 10 where 1 provides resources used by 10 😄

@laverya laverya force-pushed the laverya/pad-helm-chart-names-with-zeros-to-maintain-order branch from 23fd02e to 380e32e Compare February 21, 2024 21:09
@laverya laverya marked this pull request as ready for review February 21, 2024 21:21
@laverya laverya requested a review from a team as a code owner February 21, 2024 21:21
@twz123
Copy link
Member

twz123 commented Feb 22, 2024

Thanks for looking into this. Can you provide an example of what you'd like to fix, so that we can cover this in an integration test? K0s does offer the order field on Helm extensions, but this may not work quite as expected. The file names control the order in which chart resources are applied to the cluster, but the actual installation happens when those resources are reconciled. Not sure if the order is guaranteed in any way on that end.

Previous related PRs:

@laverya
Copy link
Contributor Author

laverya commented Feb 26, 2024

Well, we've seen pretty consistent behavior where charts are initially applied in the order of their sorted filenames - and we recently merged a change to increase all 'order' values by 100 to allow orders 10-90 to work properly. (we also have a 'is this pod older than this other pod' check in CI now, to ensure that things are actually being applied in the right order) I'm not sure if the reconciliation order is guaranteed either, but I don't think we've seen it run outside of that order upon initial install yet!

@laverya
Copy link
Contributor Author

laverya commented Feb 26, 2024

Let me get an example spec in a moment.

@laverya
Copy link
Contributor Author

laverya commented Feb 26, 2024

(we had initially discovered this due to a demo helm chart with incorrect configuration that was applied before the ones we actually required, and never completed, blocking installation of the other charts until the timeout, and so I need to create a better example)

Copy link
Contributor

The PR is marked as stale since no activity has been recorded in 30 days

@github-actions github-actions bot added Stale and removed Stale labels Mar 27, 2024
Copy link
Contributor

The PR is marked as stale since no activity has been recorded in 30 days

@github-actions github-actions bot added the Stale label Apr 27, 2024
@github-actions github-actions bot closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants