Skip to content

OCPBUGS-83767: Helm upgrade — preserve release values when changing chart version#16364

Open
vikram-raj wants to merge 1 commit intoopenshift:mainfrom
vikram-raj:ocpbugs-83767
Open

OCPBUGS-83767: Helm upgrade — preserve release values when changing chart version#16364
vikram-raj wants to merge 1 commit intoopenshift:mainfrom
vikram-raj:ocpbugs-83767

Conversation

@vikram-raj
Copy link
Copy Markdown
Member

@vikram-raj vikram-raj commented Apr 28, 2026

Jira Bug fixes: https://redhat.atlassian.net/browse/OCPBUGS-83767

Analysis / Root cause:
On upgrade, changing the chart version replaced the editor with chart defaults only. The async upgrade API then received a non-empty values object, so Helm did not take the “empty new vals → reuse last release config” path and prior release settings were effectively dropped—unlike helm upgrade merge expectations and bad for Software Catalog charts (e.g. FlightControl/RHEM).

Solution description:
What changed

  • helm-utils.ts: Added mergeHelmChartVersionUpgradeValues, getCurrentHelmUserValuesForUpgradeMerge, and mergeHelmValuesOnChartVersionChange (chart defaults merged under current form/YAML values so user/release wins).
  • HelmChartVersionDropdown.tsx: Uses mergeHelmValuesOnChartVersionChange after fetching the new chart version.
    Copy: version-change modal text updated to describe merge + review.
  • helm-utils.spec.ts: Unit tests for merge behavior, editor precedence, invalid YA ML fallback, and an end-to-end merge scenario.
    yarn i18n for new/changed strings (if included in the same PR).

Screenshots / screen recording:

Before:

Helm-upgrade-before.mov

After:

Helm.upgrade.After.mov

Test setup:

  • Install a release with non-default values.
  • Upgrade, pick a new chart version without hand-editing YAML.
  • Confirm submitted values (or resulting workload) still reflect prior settings plus new chart defaults where applicable.

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Helm chart upgrades now merge your current release values with new chart defaults instead of resetting all configuration, preserving your existing settings during version changes.
  • Documentation

    • Updated messaging guides users to review merged configuration in YAML or form view before proceeding with chart version upgrades.

@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Apr 28, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@vikram-raj: This pull request references Jira Issue OCPBUGS-83767, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Jira Bug fixes: https://redhat.atlassian.net/browse/OCPBUGS-83767

Analysis / Root cause:
On upgrade, changing the chart version replaced the editor with chart defaults only. The async upgrade API then received a non-empty values object, so Helm did not take the “empty new vals → reuse last release config” path and prior release settings were effectively dropped—unlike helm upgrade merge expectations and bad for Software Catalog charts (e.g. FlightControl/RHEM).

Solution description:
What changed

  • helm-utils.ts: Added mergeHelmChartVersionUpgradeValues, getCurrentHelmUserValuesForUpgradeMerge, and mergeHelmValuesOnChartVersionChange (chart defaults merged under current form/YAML values so user/release wins).
  • HelmChartVersionDropdown.tsx: Uses mergeHelmValuesOnChartVersionChange after fetching the new chart version.
    Copy: version-change modal text updated to describe merge + review.
  • helm-utils.spec.ts: Unit tests for merge behavior, editor precedence, invalid YA ML fallback, and an end-to-end merge scenario.
    yarn i18n for new/changed strings (if included in the same PR).

Screenshots / screen recording:

Before:

Helm-upgrade-before.mov

After:

Helm.upgrade.After.mov

Test setup:

  • Install a release with non-default values.
  • Upgrade, pick a new chart version without hand-editing YAML.
  • Confirm submitted values (or resulting workload) still reflect prior settings plus new chart defaults where applicable.

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from rhamilto and sg00dwin April 28, 2026 11:39
@openshift-ci openshift-ci Bot added component/helm Related to helm-plugin kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Apr 28, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 28, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vikram-raj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 28, 2026
@vikram-raj
Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Apr 28, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@vikram-raj: This pull request references Jira Issue OCPBUGS-83767, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@vikram-raj: This pull request references Jira Issue OCPBUGS-83767, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Jira Bug fixes: https://redhat.atlassian.net/browse/OCPBUGS-83767

Analysis / Root cause:
On upgrade, changing the chart version replaced the editor with chart defaults only. The async upgrade API then received a non-empty values object, so Helm did not take the “empty new vals → reuse last release config” path and prior release settings were effectively dropped—unlike helm upgrade merge expectations and bad for Software Catalog charts (e.g. FlightControl/RHEM).

Solution description:
What changed

  • helm-utils.ts: Added mergeHelmChartVersionUpgradeValues, getCurrentHelmUserValuesForUpgradeMerge, and mergeHelmValuesOnChartVersionChange (chart defaults merged under current form/YAML values so user/release wins).
  • HelmChartVersionDropdown.tsx: Uses mergeHelmValuesOnChartVersionChange after fetching the new chart version.
    Copy: version-change modal text updated to describe merge + review.
  • helm-utils.spec.ts: Unit tests for merge behavior, editor precedence, invalid YA ML fallback, and an end-to-end merge scenario.
    yarn i18n for new/changed strings (if included in the same PR).

Screenshots / screen recording:

Before:

Helm-upgrade-before.mov

After:

Helm.upgrade.After.mov

Test setup:

  • Install a release with non-default values.
  • Upgrade, pick a new chart version without hand-editing YAML.
  • Confirm submitted values (or resulting workload) still reflect prior settings plus new chart defaults where applicable.

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

  • Helm chart upgrades now merge your current release values with new chart defaults instead of resetting all configuration, preserving your existing settings during version changes.

  • Documentation

  • Updated messaging guides users to review merged configuration in YAML or form view before proceeding with chart version upgrades.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

This pull request refactors Helm chart version upgrade behavior to merge current release values with new chart defaults rather than replacing them entirely. The change spans four files: updated English localization messaging, modified dropdown component logic that invokes new merge utilities, three new exported helper functions handling value extraction and merge semantics with array replacement behavior, and comprehensive test coverage validating merge logic across Form and YAML editor modes. User-entered configuration now takes precedence over new chart defaults, while arrays replace entirely rather than merge by index.

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: preserving release values during Helm chart version upgrades, directly aligned with the changeset.
Description check ✅ Passed The description covers all required template sections: root cause analysis, detailed solution with code changes, before/after videos, test setup, test cases, and browser conformance testing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR modifies frontend TypeScript/React code using Jest/Jasmine tests, not Ginkgo framework. Test names in helm-utils.spec.ts are static and descriptive with no dynamic elements. Ginkgo validation check not applicable.
Test Structure And Quality ✅ Passed PR contains frontend TypeScript/Jest tests incompatible with Ginkgo test framework patterns; check does not apply to React/TypeScript Helm plugin changes.
Microshift Test Compatibility ✅ Passed PR contains only JavaScript/TypeScript Jest unit tests, not Go Ginkgo e2e tests, so MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies only frontend TypeScript/JavaScript code for the Helm plugin with Jest unit tests. No Go files, Ginkgo e2e tests, or cluster topology interactions are present.
Topology-Aware Scheduling Compatibility ✅ Passed PR contains only frontend Helm plugin UI code, utility functions for value merging, and unit tests. No Kubernetes manifests, Pod specifications, or scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed OTE Binary Stdout Contract check not applicable; PR contains only frontend code changes with no Go binaries or test infrastructure.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains only TypeScript/React frontend components and Jest unit tests; no Ginkgo e2e tests present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/packages/helm-plugin/src/utils/__tests__/helm-utils.spec.ts (1)

382-396: Consider adding Form mode end-to-end test.

The current end-to-end test covers YAML mode. A complementary test in Form mode would strengthen coverage of the editor type branching:

🧪 Optional: Add Form mode test
it('mergeHelmValuesOnChartVersionChange should merge chart defaults with formData in Form mode', () => {
  const newChartValues = { image: { tag: '2.0.0' }, replicas: 1 };
  const yamlData = 'replicas: 99\n'; // Should be ignored in Form mode
  const formData = { replicas: 3, customSetting: true };
  const merged = mergeHelmValuesOnChartVersionChange(
    newChartValues,
    yamlData,
    formData,
    EditorType.Form,
  );
  expect(merged).toEqual({
    image: { tag: '2.0.0' },
    replicas: 3,
    customSetting: true,
  });
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/helm-plugin/src/utils/__tests__/helm-utils.spec.ts` around
lines 382 - 396, Add a new unit test mirroring the existing YAML-mode spec but
exercising the EditorType.Form branch: call mergeHelmValuesOnChartVersionChange
with newChartValues, a yamlData string that should be ignored, and a formData
object (e.g., { replicas: 3, customSetting: true }) and pass EditorType.Form;
assert the returned merged object preserves formData values (replicas: 3),
merges chart defaults where formData lacks keys (image.tag: '2.0.0'), and
includes other form fields (customSetting: true). Reference
mergeHelmValuesOnChartVersionChange and EditorType.Form to locate where to add
the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmChartVersionDropdown.tsx`:
- Around line 202-210: The catch block that handles safeDump failures (around
setFieldValue calls in HelmChartVersionDropdown) doesn't update the form's
'yamlData', which can leave the YAML view showing stale content; update
'yamlData' in the same error fallback — e.g. setFieldValue('yamlData',
JSON.stringify(mergedValues, null, 2)) or set it to an empty string/previous
value with a warning — so that switching to YAML reflects the mergedValues; keep
the other fallbacks (editorType, formSchema, formData, chartReadme,
setInitialFormData) as-is.

---

Nitpick comments:
In `@frontend/packages/helm-plugin/src/utils/__tests__/helm-utils.spec.ts`:
- Around line 382-396: Add a new unit test mirroring the existing YAML-mode spec
but exercising the EditorType.Form branch: call
mergeHelmValuesOnChartVersionChange with newChartValues, a yamlData string that
should be ignored, and a formData object (e.g., { replicas: 3, customSetting:
true }) and pass EditorType.Form; assert the returned merged object preserves
formData values (replicas: 3), merges chart defaults where formData lacks keys
(image.tag: '2.0.0'), and includes other form fields (customSetting: true).
Reference mergeHelmValuesOnChartVersionChange and EditorType.Form to locate
where to add the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 02797b10-2a2d-4cfd-a82f-7084e19d7ef1

📥 Commits

Reviewing files that changed from the base of the PR and between 1298e98 and ad25721.

📒 Files selected for processing (4)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmChartVersionDropdown.tsx
  • frontend/packages/helm-plugin/src/utils/__tests__/helm-utils.spec.ts
  • frontend/packages/helm-plugin/src/utils/helm-utils.ts
📜 Review details
🔇 Additional comments (9)
frontend/packages/helm-plugin/locales/en/helm-plugin.json (1)

104-104: LGTM!

The updated copy accurately describes the new merge-and-review behavior. Clear guidance for users to review values before upgrading.

frontend/packages/helm-plugin/src/utils/helm-utils.ts (4)

1-11: LGTM on imports!

Good choice using safeLoad for YAML parsing - avoids arbitrary code execution risks that load would introduce with untrusted input.


376-387: LGTM!

Solid merge logic. Using mergeWith with an empty target object prevents input mutation, and the array replacement semantics align with Helm's typical usage patterns (e.g., tolerations, env arrays should be replaced wholesale rather than merged by index).


393-420: LGTM!

The fallback chain is sensible: Form mode prefers formData, YAML mode prefers parsed YAML with formData fallback on parse failure. The safeLoad try/catch guards against malformed YAML, and the object type checks prevent unexpected return types.


422-431: LGTM!

Clean orchestration function. The ?? {} fallback for newChartValues handles charts without default values gracefully.

frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmChartVersionDropdown.tsx (3)

7-7: LGTM!

Both safeDump (line 194) and safeLoad (line 129) are used in this component.


55-59: LGTM!

editorType is correctly extracted from Formik context. Per HelmInstallUpgradePage.tsx, it's always initialized to either EditorType.Form or EditorType.YAML.


88-94: LGTM!

Modal text accurately describes the merge-and-review workflow. Proper JSX escaping of the apostrophe.

frontend/packages/helm-plugin/src/utils/__tests__/helm-utils.spec.ts (1)

314-397: Good test coverage!

Solid coverage of the key merge scenarios: user overrides, new chart keys, array replacement, editor mode preferences, and invalid YAML fallback. The tests align well with the documented behavior.

Comment on lines +202 to +210
} catch (err) {
console.error('Failed to serialize merged values:', err); // eslint-disable-line no-console
// Fall back to using the merged values object without YAML serialization
setFieldValue('editorType', nextEditorType);
setFieldValue('formSchema', valuesSchema);
setFieldValue('formData', mergedValues);
setFieldValue('chartReadme', chartReadme);
setInitialFormData(mergedValues);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing yamlData update in error fallback may cause stale YAML view.

When safeDump fails, yamlData isn't updated while formData gets the merged values. If the user later switches to YAML view, they'll see stale YAML that doesn't reflect the merge. Consider setting yamlData to an empty string or the previous value with a warning, or attempting a best-effort serialization:

🛡️ Proposed fix to handle yamlData in error path
         } catch (err) {
           console.error('Failed to serialize merged values:', err); // eslint-disable-line no-console
           // Fall back to using the merged values object without YAML serialization
           setFieldValue('editorType', nextEditorType);
           setFieldValue('formSchema', valuesSchema);
+          // Keep yamlData in sync as best we can - use empty or preserve previous
+          setFieldValue('yamlData', '');
+          setInitialYamlData('');
           setFieldValue('formData', mergedValues);
           setFieldValue('chartReadme', chartReadme);
           setInitialFormData(mergedValues);
         }

Alternatively, if safeDump fails on complex objects, you could try JSON.stringify(mergedValues, null, 2) as a fallback representation in YAML view.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (err) {
console.error('Failed to serialize merged values:', err); // eslint-disable-line no-console
// Fall back to using the merged values object without YAML serialization
setFieldValue('editorType', nextEditorType);
setFieldValue('formSchema', valuesSchema);
setFieldValue('formData', mergedValues);
setFieldValue('chartReadme', chartReadme);
setInitialFormData(mergedValues);
}
} catch (err) {
console.error('Failed to serialize merged values:', err); // eslint-disable-line no-console
// Fall back to using the merged values object without YAML serialization
setFieldValue('editorType', nextEditorType);
setFieldValue('formSchema', valuesSchema);
// Keep yamlData in sync as best we can - use empty or preserve previous
setFieldValue('yamlData', '');
setInitialYamlData('');
setFieldValue('formData', mergedValues);
setFieldValue('chartReadme', chartReadme);
setInitialFormData(mergedValues);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmChartVersionDropdown.tsx`
around lines 202 - 210, The catch block that handles safeDump failures (around
setFieldValue calls in HelmChartVersionDropdown) doesn't update the form's
'yamlData', which can leave the YAML view showing stale content; update
'yamlData' in the same error fallback — e.g. setFieldValue('yamlData',
JSON.stringify(mergedValues, null, 2)) or set it to an empty string/previous
value with a warning — so that switching to YAML reflects the mergedValues; keep
the other fallbacks (editorType, formSchema, formData, chartReadme,
setInitialFormData) as-is.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 28, 2026

@vikram-raj: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/helm Related to helm-plugin jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants