Skip to content

Generalize rancher-upgrade pipeline to a TEST_MODULE selector - #1027

Open
floatingman wants to merge 21 commits into
rancher:mainfrom
floatingman:feat/rancher-upgrade-module-selector
Open

floatingman wants to merge 21 commits into
rancher:mainfrom
floatingman:feat/rancher-upgrade-module-selector

Conversation

@floatingman

Copy link
Copy Markdown
Contributor

Scoped to #968 (pipeline slice; parent PRD #946). Generalizes the six-stage rancher-upgrade pipeline from Longhorn-only dispatch to a per-module selector, so the same pipeline runs any validation/rancherupgrade suite end to end. This also discharges the #986 review discussion asking for generic post-upgrade stages as modules land (khushboo-rancher's comment on Jenkinsfile.rancher-upgrade.e2e:929).

Stacking note: built on #986 (floatingman:rancherupgrade-longhorn-suite), so the file list includes #986's commits until that PR merges. Merge #986 first, or review this PR by commit range (single commit 96940e5b).

Change

  • New TEST_MODULE parameter (longhorn | neuvector | fleet | observability, default longhorn, preserving current behavior exactly).
  • The three hardcoded Longhorn -run regexes become an UPGRADE_TEST_MODULES map of per-phase selectors consumed by the pre/post/chart-upgrade stage dispatches.
  • The Checkout stage resolves the module before any infrastructure spend: unknown module names fail fast with the valid list, and the log records which regex each stage will run (the Slice 3: Dedicated Rancher-upgrade Jenkins job (JJB) and six-stage Jenkinsfile, community leg #968 acceptance criterion: "visible in CI logs which regex each stage ran").
  • Stages renamed to module-agnostic names (Pre-Upgrade Tests, Post-Upgrade Tests, Chart-Upgrade Tests); build description now carries the module.
  • fleet ships inside Rancher with no standalone chart, so its map has no chart phase: the chart-upgrade stage is skipped via a when guard, and the post-upgrade stage completes the shared Qase run for such modules (the post{always} fallback still covers failure paths for every module).

Verification

Merge order

#986 → this PR → #1024 (neuvector) → #1025 (fleet) → #1026 (observability). Once #986 merges, this PR retargets cleanly since its only delta is the pipeline file.

Implements the Longhorn vertical of the Rancher server upgrade validation
(rancher#967, parent PRD rancher#946).

New validation/rancherupgrade package with a LonghornUpgradeTestSuite whose
phase methods run as separate go test invocations selected via -run, one per
pipeline stage:

- TestLonghornPreUpgrade: create project, install the Longhorn chart at the
  cluster-scoped catalog latest, create a checksum workload (PVC + nginx
  deployment with deterministic names) on a Longhorn volume.
- TestLonghornPostUpgrade: gate on the management server-version setting
  reaching rancherUpgradeInput.targetVersion, assert the Longhorn chart
  survived the server upgrade, verify the checksum workload data.
- TestLonghornChartUpgrade: gate on server version, resolve latest from the
  cluster-scoped catalog, upgrade longhorn + longhorn-crd, assert the
  installed chart version, verify the checksum workload again.

Supporting actions:

- actions/clusters: WaitRancherVersion polls the server-version setting until
  it semver-equals the target, retrying transient read errors.
- actions/storage: CreateChecksumWorkload/VerifyChecksumWorkload build and
  verify a deterministically named PVC/deployment pair whose sha256-verified
  data file must survive across processes; no session cleanup is registered
  by design.
- actions/charts: UpgradeLonghornChart upgrades longhorn and longhorn-crd with
  the deletingConfirmationFlag value preserved and OpenAPI validation
  disabled, waits for Deployed, then gates on deployments and daemonsets.

TearDownSuite deliberately skips session.Cleanup and the suite is admin-only:
upgrade-subject resources must survive into later phases and the pipeline
environment teardown is the cleanup. Both deviations are documented in the
package README, along with the token-rotation and catalog-follower-restart
notes for the pipeline.

Includes schemas/pit_schemas.yaml for the three phase methods.

Verified live against a 2.14.3 HA env with a node-driver downstream RKE2
cluster: pre-upgrade PASS (Longhorn 109.3.1+up1.11.2, checksum seeded), server
upgraded to 2.15.2 via qa-infra-automation, post-upgrade PASS, chart upgrade
PASS (109.3.1+up1.11.2 -> 110.1.0+up1.12.1, checksum intact).
…estrator

Dedicated pipeline for the Rancher server upgrade validation (issue rancher#968,
PRD rancher#946), community leg: deploy 2.14-latest env, pre-upgrade Longhorn
phase, in-place server upgrade via make rancher-upgrade with rotated-token
re-injection, post-upgrade and chart-upgrade phases against one shared Qase
run, destroy-always with failure-only diagnostics. Versions resolve at
runtime via make rancher-resolve-version when the params are empty.

Structurally cloned from validation/Jenkinsfile.e2e and the airgap
Jenkinsfile call shapes; runs go-pit-validation-job per phase with
-runs TestLonghornUpgradeTestSuite/<phase> selectors.
The per-phase executor job can land on a different Jenkins agent than
the orchestrator (observed in the first rancher-upgrade run: default-n367q
vs default-xj00w). The LB ingress on the tofu-created ephemeral SG only
allows the orchestrator's detected public IP, so a phase on another agent
could not reach the Rancher API and rancher.NewClient timed out after 22
minutes of retries. awsNodeTemplate carries the three keys the executor's
Authorize Security Group stage reads (securityGroup, vpcId, region) so it
authorizes its own runner IP on tf-<prefix>-sg before dispatching to the
API, matching the shape Jenkinsfile.e2e ships for the same reason.
A declarative pipeline re-applies its parameters{} block to the job
definition after each run, which silently overwrote the JJB-configured
staging values (fork repos + slice branches) with the hard-coded main
defaults on the mower job: the first run deployed from the fork, the
next one fell back to upstream main and lost make
rancher-resolve-version ('No rule to make target'). Defaulting these
five params to their current value when set keeps the per-controller
JJB configuration authoritative instead of racing it.
The one-minute bind wait raced a freshly installed Longhorn: the first
volume's provisioning (engine-image pull, instance-manager startup, CSI
registration) can exceed a minute on a cold cluster, which failed the
pre-upgrade phase with 'context deadline exceeded' in the mower run
(the same step passed when the volume bound faster). Ten minutes
matches the bound used for the rest of the storage waits.
Jenkins evaluates declarative post conditions in a fixed order with
always before failure, so the failure-block diagnostics ran after the
always block had already run infra-down and docker rmi: kubectl/helm
had no rancher-infra-tools image left to run in (pull access denied,
exit 125) and the cluster was already gone regardless. Diagnostics now
run first inside always, gated on a non-SUCCESS result, while the
images and the live cluster still exist; the failure block keeps only
the DESTROY_ON_FAILURE fallback destroy.
The post-upgrade phase failed with an instant 401 from
rancher.NewClient even though the rotated token had been extracted
(length 66) and yq-injected into the dispatched config. Two fail-fast
checks now pinpoint which side is broken: the injected token must get
HTTP 200 from the upgraded Rancher API before any phase is dispatched,
and the config about to be dispatched must byte-match the token in
generated.tfvars. Both run under set +x so the token value stays out
of the xtrace (the previous run echoed it into the build log).
The smoke-check curl died with exit 60 (TLS verification) against
pitupgrade.qa.rancher.space before it ever reached auth — the same
endpoint the tests already call with insecure: true. Pass -k so the
check actually adjudicates the token.
token=$(awk ...) creates an unexported shell variable, but yq's
strenv() reads the process environment, so the injection silently
wrote an empty string into rancher.adminToken — the post-upgrade
phase then authenticated with an empty bearer token (instant 401).
curl in the same step still worked because its header uses shell
expansion, which is why the smoke-check passed while the config
check failed (expected length 66, got length 0). export the variable
so the child yq process can see it.
- logrus milestone logs in each upgrade phase (version resolution, chart
  install/upgrade, workload seed, checksum verification) so the job log
  shows where each phase is without reading the assertions backwards.
- rancher-infra-tools/rancher-go-test now carry a build-scoped tag
  (pitupgrade-<BUILD_NUMBER>) used by every direct docker invocation in
  this pipeline, so this job no longer depends on whatever another job
  last built or removed under the shared :latest tag on the same agent;
  the :latest alias is still applied for qa-jenkins-library's
  make.runTarget image resolution.
Jenkins evaluates post conditions in a fixed order (always before
failure, cleanup last), so the failure{} destroy block could never
work: always had already shredded workspace_name.txt and tfvars and
removed the infra-tools image teardown depends on, and with
DESTROY_AFTER_TESTS=false + DESTROY_ON_FAILURE=true a failed run
skipped teardown entirely, leaking the AWS environment.

Fold the destroy decision into always (after diagnostics and Qase
completion), gated on DESTROY_AFTER_TESTS or failure+DESTROY_ON_
FAILURE; move the docker rmi and sensitive-artifact shredding into a
cleanup block so they run last.
…ard, flavor plumbing

- actions/storage: reject checksum content outside [A-Za-z0-9-] before sh -c interpolation
- rancherupgrade: fail fast when resolved latest equals the installed chart version (stale cluster-scoped catalog follower)
- Jenkinsfile.rancher-upgrade.e2e: document timeout budget, plumb RANCHER_CHART_REPO_FLAVOR into make args, resolve kubeconfig via INFRA_DIR, select deploy repo by flavor
- README + pit_schemas: correct downstream-cluster wording to the Rancher local cluster
- actions/clusters: debug logging on server-version read/parse failures
…ersion scope

- pvc.go: createNginxDeploymentWithPVC takes an explicit deploymentName, so
  CreatePVCWorkload keeps random names while CreateChecksumWorkload passes its
  deterministic one; shared construction replaces ~25 duplicated lines
- checksum.go: reuse the shared helper; drop now-unused charts/wloads imports
- README: previous-release-line-to-latest wording (pipeline default, not a suite
  constraint) and a deliberate-deviation bullet for the out-of-band server upgrade
…r#968)

Replace the three hardcoded Longhorn -run regexes with an
UPGRADE_TEST_MODULES map (longhorn, neuvector, fleet, observability)
selected by a new TEST_MODULE parameter (default longhorn, preserving
existing behavior). The checkout stage fails fast on an unknown module
before any infra spend and logs the selected regexes per stage.

Stages renamed to module-agnostic names; the chart-upgrade stage is
skipped for fleet (no standalone chart), which closes the shared Qase
run in the post-upgrade stage instead. Discharges the rancher#986 review
discussion about generic post-upgrade stages as modules land.
@floatingman
floatingman requested a review from a team as a code owner October 22, 2026 14:09
The fleet suite serves its GitRepo over SSH from a downstream node, but
downstream executors mount no .ssh, so the suite cannot reach a key by
itself. For TEST_MODULE=fleet the config-creation stage injects the
orchestrator's node PEM and the tfvars ssh user into the sshNode section
of the cattle-config; other modules are unaffected.
The observability suite requires the stackstateConfigs operator inputs
(license, url, cluster API key, admin password); the pipeline injects
them for TEST_MODULE=observability: the license from the
STACKSTATE_LICENSE folder credential (failing fast before infra spend
when absent), a STACKSTATE_URL parameter defaulting to the in-cluster
router service the co-located agent can always reach, and a
self-consistent cluster API key the suite installs the server with.
Build 24 showed the license check firing only after the pre-upgrade
environment was already deployed, burning the deploy on a missing
credential. The version-resolution stage now verifies
STACKSTATE_LICENSE exists and is non-empty before any infra spend; the
post-deploy config injection reuses it.
@floatingman floatingman self-assigned this Oct 26, 2026
@floatingman floatingman added the team/pit-crew slack notifier for pit crew label Oct 26, 2026
@floatingman
floatingman removed the request for review from a team October 27, 2026 12:00
floatingman and others added 2 commits October 27, 2026 07:13
Add an all entry to UPGRADE_TEST_MODULES whose broad per-phase regex
picks up every module suite in the package (and future ones); thread
the fleet ssh key and the observability license when TEST_MODULE=all,
and pre-deploy-guard the license for it too. Fleet has no chart
subtest, so the chart phase runs its Setup/TearDown with zero matched
methods.
Take the Jenkinsfile from the integration branch verbatim: in
all-mode dispatch the observability chart upgrade before longhorn's
(Longhorn's engine live-upgrades stall a concurrent observability
rollout's volume reattach; build 52).
Comment on lines +66 to +79
neuvector: [
pre: '-run "TestNeuVectorUpgradeTestSuite/TestNeuVectorPreUpgrade"',
post: '-run "TestNeuVectorUpgradeTestSuite/TestNeuVectorPostUpgrade"',
chart: '-run "TestNeuVectorUpgradeTestSuite/TestNeuVectorChartUpgrade"'
],
fleet: [
pre: '-run "TestFleetUpgradeTestSuite/TestFleetPreUpgrade"',
post: '-run "TestFleetUpgradeTestSuite/TestFleetPostUpgrade"'
],
observability: [
pre: '-run "TestObservabilityUpgradeTestSuite/TestObservabilityPreUpgrade"',
post: '-run "TestObservabilityUpgradeTestSuite/TestObservabilityPostUpgrade"',
chart: '-run "TestObservabilityUpgradeTestSuite/TestObservabilityChartUpgrade"'
],

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.

We do not have these tests on this branch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We will once all related PRs are merged.

@lscalabrini01 lscalabrini01 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.

Looks good, but we should wait for the related PRs be merged

This branch has not been deployed

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

Labels

team/pit-crew slack notifier for pit crew

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants