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

Don't rewrite manifests when values don't change #2457

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

brandond
Copy link
Member

@brandond brandond commented Feb 9, 2022

Proposed Changes

Don't rewrite manifests when values don't change.

RKE2 injects cluster configuration into HelmChart manifests on startup, including into user-provided HelmCharts, by rewriting the files on disk. These manifests were rewritten on startup every time, even if cluster configuration values did not change. This rewrite causes the Deploy controller to re-apply the manifest, and in turn the Helm controller to trigger a helm upgrade of the affected chart - even if there was not in fact any change to apply.

These no-op helm upgrades could cause issues if they triggered hooks in the Helm chart, or resulted in the Helm release getting stuck pending due to simultaneous upgrades to cluster infrastructure triggered by the restart.

Types of Changes

bugfix

Verification

  1. Create /var/lib/rancher/rke2/server/manifests.
  2. Place a custom HelmChart manifest in that directory.
  3. Install and start RKE2.
  4. Note that cluster configuration files are injected into the manifest on disk, and the log contains a "Updated HelmChart" message referencing the manifest filename.
  5. Restart RKE2.
  6. Note that the manifest file modification time has not been changed, and the log contains a "No cluster configuration value changes necessary for HelmChart" message referencing the manifest filename.

Linked Issues

Further Comments

Note that manifests for packaged components will still get rewritten every time, as they are copied out of the runtime image every startup.

@brandond brandond force-pushed the helmchart_conditional_rewrite branch from eeedd2c to d7e319f Compare February 10, 2022 19:53
@brandond brandond requested review from briandowns and a team February 10, 2022 19:54
chart.Spec.Set[k] = intstr.FromString(v)
val := intstr.FromString(v)
if cur, ok := chart.Spec.Set[k]; ok {
curBytes, _ := cur.MarshalJSON()
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we ignore the error check here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The new value is guaranteed to be valid since we just generated it, and if the current value is invalid and returns an error we'll handle comparing the empty byte slice to the new value properly anyway despite the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense

@brandond brandond merged commit 7774c3b into rancher:master Feb 11, 2022
@brandond brandond deleted the helmchart_conditional_rewrite branch June 6, 2024 23:11
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