Skip to content

Param sets override persisted --param values on upgrade#3600

Merged
kichristensen merged 3 commits into
getporter:mainfrom
kichristensen:issue3599
Jun 26, 2026
Merged

Param sets override persisted --param values on upgrade#3600
kichristensen merged 3 commits into
getporter:mainfrom
kichristensen:issue3599

Conversation

@kichristensen

@kichristensen kichristensen commented May 27, 2026

Copy link
Copy Markdown
Contributor

What does this change

When running porter upgrade with a parameter set, Porter was ignoring
the parameter set values for any parameter that had been previously set
via --param in an earlier invocation. The old persisted value would
silently win, making it impossible to update a parameter's value by
switching to a parameter set.

The fix corrects the precedence order so that:

  1. Current --param CLI flags win over everything
  2. Named parameter set values win over old persisted values
  3. Old persisted values are used only as a fallback when neither a CLI flag nor a parameter set provides a value

The same precedence is applied in the porter apply (reconcile) path: parameters specified inline in the installation YAML are treated as current overrides and win over parameter sets.

What issue does it fix

Closes #3599

Notes for the reviewer

Root cause was in applyActionOptionsToInstallation (pkg/porter/parameters.go):

  1. loadParameterSets() received inst.Parameters.Parameters (all persisted params from previous runs) as its overridenParameters argument, causing it to skip resolving parameter set values for any param that had ever been set via --param.
  2. The subsequent merge loop applied all resolvedOverrides (resolved inst.Parameters) on top of parameter set values, so old persisted values always won.

The fix builds cliOverridesList containing only params from the current invocation's --param flags (step 3), and changes the merge loop (step 5) to only let resolvedOverrides win when the key is a current CLI override or not already provided by a parameter set.

For the porter apply path, ReconcileInstallation now sets CurrentParamOverrides on BundleExecutionOptions directly (a secrets.StrategyList) instead of serializing inline params to name=value strings. This avoids a string round-trip through ParseVariableAssignments that would have (a) skipped sanitized SourceSecret params on subsequent reconciles, (b) silently stripped leading/trailing whitespace from values, and (c) re-injected params removed from the bundle definition.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

When upgrading, parameters previously set via --param were
persisted on the installation and incorrectly suppressed
resolution of values from a named parameter set. Parameter
sets should take precedence over old persisted values, with
only current-invocation --param flags able to override them.

Fixes getporter#3599

Signed-off-by: Kim Christensen <kimworking@gmail.com>
In `installation apply`, parameters from the YAML are the user's
current explicit desired state. The existing fix for getporter#3599 only
treated CLI `--param` flags as current overrides, so param set
values were incorrectly winning over YAML-specified parameters.

Add value-source parameters from the installation YAML to
lifecycleOpts.Params in ReconcileInstallation, so they are
treated as current overrides in applyActionOptionsToInstallation.

Signed-off-by: Kim Christensen <kimworking@gmail.com>
Replace string round-trip serialization in ReconcileInstallation
with a CurrentParamOverrides field on BundleExecutionOptions.
All parameter strategies (SourceValue, SourceSecret, etc.) are
now handled correctly, and TrimSpace corruption of whitespace
in values is eliminated.

Signed-off-by: Kim Christensen <kimworking@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a parameter-resolution precedence bug where named parameter sets on porter upgrade were silently ignored for any parameter that had previously been set via --param. The fix distinguishes "current invocation overrides" (CLI --param flags and inline YAML params from the apply path) from "old persisted values" so that parameter sets correctly take precedence over the latter.

Changes:

  • In applyActionOptionsToInstallation, build cliOverridesList containing only current-invocation overrides (passed to loadParameterSets), and update the final merge loop so old persisted values only fill gaps not covered by a parameter set.
  • Add CurrentParamOverrides secrets.StrategyList to BundleExecutionOptions, and have ReconcileInstallation populate it with opts.Installation.Parameters.Parameters instead of round-tripping through string serialization.
  • Add a unit regression test plus two integration tests (with a small new test bundle) covering: param set overrides previous --param, and --param overrides param set.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/porter/parameters.go Reworks parameter set resolution and final merge to distinguish current overrides from old persisted values.
pkg/porter/lifecycle.go Adds CurrentParamOverrides field to BundleExecutionOptions.
pkg/porter/reconcile.go Passes inline YAML installation parameters through CurrentParamOverrides instead of serializing them.
pkg/porter/lifecycle_test.go Unit regression test for the precedence fix.
tests/integration/upgrade_test.go Integration tests covering both precedence directions.
tests/integration/testdata/bundles/bundle-with-param-set-upgrade/porter.yaml New tiny test bundle echoing the name parameter for the integration tests.
tests/integration/testdata/bundles/bundle-with-param-set-upgrade/helpers.sh Helper script invoked by the test bundle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kichristensen kichristensen changed the title fix: param sets override persisted --param values on upgrade Param sets override persisted --param values on upgrade Jun 11, 2026
@kichristensen kichristensen marked this pull request as ready for review June 11, 2026 21:50
@kichristensen kichristensen requested a review from a team as a code owner June 11, 2026 21:50
@kichristensen kichristensen merged commit 5497e64 into getporter:main Jun 26, 2026
49 checks passed
@kichristensen kichristensen deleted the issue3599 branch June 26, 2026 11:35
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.

Parameters are not being properly wired when using parameter sets.

2 participants