Skip to content

Add secrets for Helm release upgrade#16787

Open
sowmya-sl wants to merge 3 commits into
openshift:mainfrom
sowmya-sl:add-secrets-helm-upgrade
Open

Add secrets for Helm release upgrade#16787
sowmya-sl wants to merge 3 commits into
openshift:mainfrom
sowmya-sl:add-secrets-helm-upgrade

Conversation

@sowmya-sl

@sowmya-sl sowmya-sl commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Analysis / Root cause:

Kubernetes Secret object is used to store username and password for authentication when trying to create a Helm release. If a Helm release is created using a URL and selecting a particular secret for authentication, the users are unable to change the secrets during upgrade. This poses a problem if the secret's name has been changed or removed.

Solution description:

Create a dropdown where the secret can be entered during upgrade. If no secret is entered, it will go with the existing secret name if it exists, otherwise the new secret will override the old one.
Screenshots / screen recording:

https://docs.google.com/document/d/1LDRXScwr_jOnvdWU0siqW1gBMM8hrhm3D0oz831gUPA/edit?tab=t.mcv80hqh092h#heading=h.2jo1jtiyytic
Test setup:

An OCI registry and a Helm repository requiring authentication via username and password.

Additional Information:
Rebased on #16676

Reviewers and assignees:

Summary by CodeRabbit

  • New Features
    • Added support for selecting or creating Kubernetes Secrets for basic authentication when installing or upgrading Helm charts from URLs.
    • Added a modal to create basic-auth Secrets (username and password/token) and integrated it into the Helm URL/installation flow.
  • Bug Fixes
    • Improved handling and messaging when registries require credentials (e.g., unauthorized/401 scenarios) and when secrets are missing.
    • Preserved and correctly propagated authentication and chart installation annotations during upgrades.
  • Documentation
    • Updated user-facing wizard text ordering and added new localization strings for basic-auth secret creation and labels.

…tching

- Pass basicAuthSecretName through UpgradeReleaseAsync to support
  auth credentials during chart upgrades
- Use __none__ sentinel to allow users to explicitly clear a secret
- Preserve installation annotation on upgrade to maintain URL-install
  tracking across revisions
- Return errors instead of logging on auth credential failures so
  the frontend can surface them
- Add 401/unauthorized detection in GetChartFromURL, InstallChartFromURL,
  and UpgradeReleaseAsync with actionable error messages
- Update handler signature, mock, and tests for the new parameter
…orms

- Add HelmCreateBasicAuthSecretModal for creating kubernetes.io/basic-auth
  secrets with username/password from within the Helm forms
- Add auth secret dropdown with 'None' and 'Create Secret' options to
  HelmInstallUpgradeForm, shown when upgrading a URL-installed chart
- Detect URL-installed charts via 'installation' annotation and read
  initial auth secret from 'helm.openshift.io/auth-secret' annotation
- Pass basicAuthSecretName through to the upgrade API payload
- Use __none__ sentinel to allow explicitly clearing a previously set secret
- Show warning when a previously referenced secret no longer exists
- Add auth secret dropdown to HelmURLChartForm for URL-based chart installs
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 17f5736d-268b-4ace-929e-f450603d1da0

📥 Commits

Reviewing files that changed from the base of the PR and between d346f64 and 505162d.

📒 Files selected for processing (6)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • pkg/helm/actions/get_chart.go
  • pkg/helm/actions/install_chart.go
  • pkg/helm/actions/upgrade_release.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/helm/actions/get_chart.go
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • pkg/helm/actions/upgrade_release.go

Walkthrough

Helm URL installations and upgrades now support selecting or creating Kubernetes basic-auth Secrets. Secret names flow from chart annotations through frontend forms and handlers into Helm actions, which add authentication-specific errors and explicit Secret-clearing behavior.

Changes

Helm basic-auth authentication

Layer / File(s) Summary
Create and select authentication Secrets
frontend/packages/helm-plugin/src/components/forms/url-chart/*, frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx, frontend/packages/helm-plugin/locales/en/helm-plugin.json
Adds a basic-auth Secret creation modal, dropdown actions, Secret filtering, missing-Secret warnings, and localized labels.
Propagate URL-install authentication
frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradePage.tsx, pkg/helm/handlers/handlers.go, pkg/helm/handlers/handler_test.go
Reads chart annotations, initializes authentication form values, and passes the selected Secret name through the upgrade handler.
Chart lookup and upgrade authentication
pkg/helm/actions/get_chart.go, pkg/helm/actions/install_chart.go, pkg/helm/actions/upgrade_release.go
Adds authentication-specific lookup errors, credential failure returns, explicit Secret clearing, and installation annotation propagation.
Upgrade call-site updates
pkg/helm/actions/upgrade_release_test.go
Updates asynchronous upgrade test calls for the new authentication argument.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant HelmInstallUpgradePage
  participant HelmInstallUpgradeForm
  participant HelmHandler
  participant HelmUpgradeRelease
  User->>HelmInstallUpgradePage: open URL-based Helm install or upgrade
  HelmInstallUpgradePage->>HelmInstallUpgradeForm: provide Secret name and URL-install state
  HelmInstallUpgradeForm->>HelmHandler: submit basic-auth Secret name
  HelmHandler->>HelmUpgradeRelease: pass basicAuthSecretName
  HelmUpgradeRelease->>HelmUpgradeRelease: locate chart with Secret authentication
  HelmUpgradeRelease-->>HelmHandler: return release or authentication error
Loading

Possibly related PRs

  • openshift/console#16775: Implements closely related Helm basic-auth Secret workflow and backend propagation changes.

Suggested reviewers: baijum, webbnh

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main change: adding secret support for Helm release upgrades.
Description check ✅ Passed The description covers the root cause, solution, screenshots, test setup, and additional info, with only some non-critical sections left blank.
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 All changed test titles are static literal strings; none embed generated names, timestamps, or other run-to-run values.
Test Structure And Quality ✅ Passed PASS: the changed tests are plain testing.T unit tests, not Ginkgo; no Eventually/Consistently or cluster-wait patterns were introduced.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e test blocks or MicroShift-sensitive APIs were added in the patch; the diff is UI/Helm logic only.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed tests are standard Go unit tests with no Ginkgo imports or It/Describe usage.
Topology-Aware Scheduling Compatibility ✅ Passed Only frontend and Helm auth-handling code changed; no manifests/controllers or pod scheduling constructs (affinity, nodeSelector, spread constraints) were added.
Ote Binary Stdout Contract ✅ Passed PR only changes non-entrypoint functions/files; no new stdout writes in main/init/TestMain/setup or top-level init code were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests were added; the changed tests are plain Go unit tests and show no IPv4/external connectivity assumptions.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons appear in the modified files; auth code only reads Secret data and configures registry auth.
Container-Privileges ✅ Passed No changed files are container/K8s manifests, and the touched files contain no privileged or securityContext settings.
No-Sensitive-Data-In-Logs ✅ Passed No new logging of secrets/PII was introduced; the diff only changes error handling and UI state, not log statements.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
frontend/packages/helm-plugin/locales/en/helm-plugin.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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

@openshift-ci
openshift-ci Bot requested review from baijum and webbnh July 21, 2026 09:25
@openshift-ci openshift-ci Bot added component/backend Related to backend component/helm Related to helm-plugin approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/helm/actions/install_chart.go (1)

339-347: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Missing "none" sentinel handling — mirrors a gap fixed in upgrade_release.go.

upgrade_release.go's UpgradeReleaseAsync treats basicAuthSecretName == "__none__" as an explicit "no auth" request and clears it before doing anything else. InstallChartFromURL has no equivalent handling, so if a user selects "None" in HelmInstallUpgradeForm.tsx during a fresh Create/install flow (the dropdown's "None" action item isn't gated to Upgrade-only), the literal string "__none__" is sent as basicAuthSecretName here, and GetUserCredentials(coreClient, ns, "__none__") will fail looking up a Secret literally named "__none__" — producing a confusing error instead of the intended "no basic auth" behavior.

🐛 Suggested fix (mirrors upgrade_release.go)
+	if basicAuthSecretName == "__none__" {
+		basicAuthSecretName = ""
+	}
 	if basicAuthSecretName != "" {
 		userCredentials, err := GetUserCredentials(coreClient, ns, basicAuthSecretName)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/helm/actions/install_chart.go` around lines 339 - 347, Update
InstallChartFromURL before the basic-auth credential lookup to treat
basicAuthSecretName == "__none__" as an explicit no-auth request by clearing it.
Preserve the existing credential retrieval and applyBasicAuthFromUserCredentials
flow for all other non-empty secret names.
🧹 Nitpick comments (2)
pkg/helm/actions/upgrade_release_test.go (1)

703-793: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test coverage for the "__none__" explicit-clear sentinel.

TestUpgradeAfterURLInstallWithSecrets verifies the auth-secret annotation is preserved across an upgrade, but there's no test asserting that passing basicAuthSecretName = "__none__" actually clears auth_secret and skips credential lookup (the new explicitlyClearedSecret logic in upgrade_release.go). A regression there would silently restore the old secret via the annotation fallback instead of honoring the user's explicit "None" selection.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/helm/actions/upgrade_release_test.go` around lines 703 - 793, The test
suite needs coverage for the "__none__" explicit-clear path in
TestUpgradeAfterURLInstallWithSecrets. Add a case that passes
basicAuthSecretName as "__none__", verifies the upgrade does not look up
credentials, and asserts the resulting chart metadata clears auth_secret instead
of restoring the annotated secret through fallback.
pkg/helm/actions/get_chart.go (1)

87-89: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Extract the duplicated "registry requires authentication" detection into a shared helper.

The same strings.Contains(err.Error(), "401") || strings.Contains(err.Error(), "unauthorized") check, guarded by an empty basicAuthSecretName, is copy-pasted into three files. A single isAuthRequiredError(err error) bool (or similar) helper in the actions package would keep the heuristic (and any future refinement, e.g. adding "403"/"forbidden") consistent across all three call sites instead of relying on manual sync.

  • pkg/helm/actions/get_chart.go#L87-L89: replace the inline strings.Contains check in GetChartFromURL with a call to the shared helper.
  • pkg/helm/actions/install_chart.go#L361-L363: replace the inline check in InstallChartFromURL with the same helper.
  • pkg/helm/actions/upgrade_release.go#L225-L241: replace the inline check in UpgradeReleaseAsync with the same helper.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/helm/actions/get_chart.go` around lines 87 - 89, The
authentication-required error detection is duplicated across three call sites;
extract it into one shared actions-package helper and reuse it while preserving
the existing empty basicAuthSecretName guard. Update GetChartFromURL in
pkg/helm/actions/get_chart.go (lines 87-89), InstallChartFromURL in
pkg/helm/actions/install_chart.go (lines 361-363), and UpgradeReleaseAsync in
pkg/helm/actions/upgrade_release.go (lines 225-241) to call the helper instead
of inline strings.Contains checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx`:
- Around line 83-84: Update the Helm install path to handle the __none__ secret
sentinel consistently with the upgrade path. In the install chart action,
recognize the NONE_SECRET_KEY value and skip secret creation or attachment when
selected, while preserving existing behavior for CREATE_SECRET_KEY and actual
secret keys.

---

Outside diff comments:
In `@pkg/helm/actions/install_chart.go`:
- Around line 339-347: Update InstallChartFromURL before the basic-auth
credential lookup to treat basicAuthSecretName == "__none__" as an explicit
no-auth request by clearing it. Preserve the existing credential retrieval and
applyBasicAuthFromUserCredentials flow for all other non-empty secret names.

---

Nitpick comments:
In `@pkg/helm/actions/get_chart.go`:
- Around line 87-89: The authentication-required error detection is duplicated
across three call sites; extract it into one shared actions-package helper and
reuse it while preserving the existing empty basicAuthSecretName guard. Update
GetChartFromURL in pkg/helm/actions/get_chart.go (lines 87-89),
InstallChartFromURL in pkg/helm/actions/install_chart.go (lines 361-363), and
UpgradeReleaseAsync in pkg/helm/actions/upgrade_release.go (lines 225-241) to
call the helper instead of inline strings.Contains checks.

In `@pkg/helm/actions/upgrade_release_test.go`:
- Around line 703-793: The test suite needs coverage for the "__none__"
explicit-clear path in TestUpgradeAfterURLInstallWithSecrets. Add a case that
passes basicAuthSecretName as "__none__", verifies the upgrade does not look up
credentials, and asserts the resulting chart metadata clears auth_secret instead
of restoring the annotated secret through fallback.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 048661ba-b60c-46bf-aafa-b785af51ccd5

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0dcf1 and d346f64.

📒 Files selected for processing (11)
  • frontend/packages/helm-plugin/locales/en/helm-plugin.json
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx
  • frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradePage.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmCreateBasicAuthSecretModal.tsx
  • frontend/packages/helm-plugin/src/components/forms/url-chart/HelmURLChartForm.tsx
  • pkg/helm/actions/get_chart.go
  • pkg/helm/actions/install_chart.go
  • pkg/helm/actions/upgrade_release.go
  • pkg/helm/actions/upgrade_release_test.go
  • pkg/helm/handlers/handler_test.go
  • pkg/helm/handlers/handlers.go

Comment on lines +83 to +84
const CREATE_SECRET_KEY = 'create-secret';
const NONE_SECRET_KEY = '__none__';

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

"None" option reachable during fresh install, but install path lacks the "none" sentinel handling that upgrade has.

This will be covered together with the backend gap in a consolidated comment anchored at pkg/helm/actions/install_chart.go, since the root fix belongs there.

Also applies to: 234-243

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@frontend/packages/helm-plugin/src/components/forms/install-upgrade/HelmInstallUpgradeForm.tsx`
around lines 83 - 84, Update the Helm install path to handle the __none__ secret
sentinel consistently with the upgrade path. In the install chart action,
recognize the NONE_SECRET_KEY value and skip secret creation or attachment when
selected, while preserving existing behavior for CREATE_SECRET_KEY and actual
secret keys.

- Make 401/unauthorized error detection case-insensitive across
  get_chart, install_chart, and upgrade_release
- Capitalize 'Basic' in 'Secret for Basic authentication' label
- Extract secretName.trim() to a single variable in the modal
- Remove duplicate locale key for 'Secret for Basic authentication'

Co-authored-by: Cursor <cursoragent@cursor.com>
@martinszuc

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: martinszuc, sowmya-sl

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

@martinszuc martinszuc removed their assignment Jul 21, 2026
@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@sowmya-sl: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console 505162d link true /test e2e-gcp-console
ci/prow/e2e-playwright 505162d link false /test e2e-playwright

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/backend Related to backend component/helm Related to helm-plugin kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants