Skip to content

WIP: test csi snapshot metadata in openshift - #2742

Open
dobsonj wants to merge 3 commits into
openshift:masterfrom
dobsonj:test-csi-snapshot-metadata-openshift
Open

WIP: test csi snapshot metadata in openshift#2742
dobsonj wants to merge 3 commits into
openshift:masterfrom
dobsonj:test-csi-snapshot-metadata-openshift

Conversation

@dobsonj

@dobsonj dobsonj commented Aug 11, 2026

Copy link
Copy Markdown
Member

This tests #2739 by temporarily hard coding CSI_PROW_ENABLE_SNAPSHOT_METADATA=true so we can see test results when the environment variable is true.

  • e2e: move snapshot metadata resource handling to PrepareTest
  • DO NOT MERGE: pre-merge testing CSI_PROW_ENABLE_SNAPSHOT_METADATA=true

/cc @RomanBednar
/hold

Summary by CodeRabbit

  • Tests
    • Improved storage integration test coverage for snapshot metadata capabilities.
    • Snapshot metadata resources are now automatically prepared when supported.
    • Added safer deferred cleanup, with cleanup failures reported as warnings rather than interrupting test execution.
    • Removed redundant setup and teardown steps from the snapshot metadata test suite.
    • Updated the snapshot metadata verification environment for more reliable test execution.

RomanBednar and others added 2 commits August 11, 2026 10:25
When CSI_PROW_ENABLE_SNAPSHOT_METADATA is true, PrepareTest deploys
the csi-hostpath StatefulSet with the csi-snapshot-metadata sidecar
that mounts a TLS secret volume. Previously, the secret, Service,
and SnapshotMetadataService CR were only created in the snapshot
metadata test suite's BeforeEach. Non-snapshot-metadata tests never
created these resources, causing FailedMount errors on the secret
volume.

Move resource creation to PrepareTest so all tests that deploy the
sidecar also have the backing resources. This fixes mixed test
suites (e.g. OpenShift CI) that run snapshot-metadata and
non-snapshot-metadata tests together. Upstream CI didn't catch this
because it runs snapshot metadata tests in isolation with
FOCUS=[Feature:snapshotmetadata].
@openshift-merge-bot

Copy link
Copy Markdown

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

@openshift-ci
openshift-ci Bot requested a review from RomanBednar August 11, 2026 16:50
@openshift-ci-robot openshift-ci-robot added the backports/unvalidated-commits Indicates that not all commits come to merged upstream PRs. label Aug 11, 2026
@openshift-ci openshift-ci Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Aug 11, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@dobsonj: the contents of this pull request could not be automatically validated.

The following commits could not be validated and must be approved by a top-level approver:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dobsonj
Once this PR has been reviewed and has the lgtm label, please assign jacobsee for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

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: 3cbcaf7a-ae19-461a-a303-f6a2d2c75881

📥 Commits

Reviewing files that changed from the base of the PR and between b1f4285 and 2ba62a4.

📒 Files selected for processing (1)
  • test/e2e/storage/testsuites/snapshot-metadata.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/storage/testsuites/snapshot-metadata.go

Included review availability: Your plan includes up to 12 reviews per rolling hour; 11 remain after this review.


Walkthrough

The HostPath CSI driver setup enables snapshot metadata detection and manages snapshot metadata resources. The snapshot metadata test suite removes duplicate resource management and updates its verifier installer image.

Changes

Snapshot metadata setup

Layer / File(s) Summary
Driver snapshot metadata lifecycle
test/e2e/storage/drivers/csi.go
InitHostPathCSIDriver enables CSI_PROW_ENABLE_SNAPSHOT_METADATA. PrepareTest creates resources after driver deployment and defers cleanup.
Test suite lifecycle alignment
test/e2e/storage/testsuites/snapshot-metadata.go
The verifier installer image changes to golang:1.26.1. Duplicate resource creation and cleanup are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2ba62

This PR temporarily enables snapshot metadata handling for pre-merge testing; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: romanbednar

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning The PR forces CapSnapshotMetadata true, activating existing Ginkgo tests whose pod pulls golang:1.26.1 and runs go install from github.com; both require public connectivity. Use an internal mirror and vendored verifier, or add [Skipped:Disconnected]. Run the IPv6 CI job periodic-ci-openshift-release-master-nightly-4.22-e2e-metal-ipi-ovn-ipv6.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: testing CSI snapshot metadata in OpenShift.
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 The PR adds no dynamic Ginkgo test titles. Its only It() titles are literal, stable strings: “should verify GetMetadataDelta” and “should verify GetAllocatedMetadata”.
Test Structure And Quality ✅ Passed The diff registers cleanup for snapshot metadata resources in PrepareTest, uses repository-standard context-based waits, and adds meaningful failure messages; the two It blocks retain single behavi...
Microshift Test Compatibility ✅ Passed The aggregate diff adds no Ginkgo It/Describe/Context/When tests. The modified suite uses standard Kubernetes/CSI resources and adds no listed MicroShift-incompatible API or assumption.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds no Ginkgo tests. It activates existing snapshot-metadata tests, whose changed setup uses APIs and same-node scheduling, with no HA or multi-node assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The PR changes only CSI e2e test logic and a verifier image tag. The diff adds no deployment manifests, operator/controller code, or topology scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR adds no stdout writes. It only sets an environment variable and uses framework/GinkgoWriter APIs; PrepareTest runs from It/BeforeEach, while driver registration only sets capabilities.
No-Weak-Crypto ✅ Passed The PR diff adds snapshot-metadata setup, cleanup, an environment variable, and an image-version change; it introduces no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The diff changes Go test setup and an image tag only; it adds no privilege fields. Existing hostpath manifest privileged:true entries are unchanged and therefore are not PR-caused.
No-Sensitive-Data-In-Logs ✅ Passed The PR adds only generic Setenv, resource-creation, and cleanup error logs; no passwords, tokens, keys, PII, hostnames, or customer data are logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@dobsonj

dobsonj commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown

Scheduling required tests:
/test configmap-scale
/test e2e-aws-ovn-cgroupsv2
/test e2e-aws-ovn-crun
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp
/test e2e-metal-ipi-ovn-ipv6
/test k8s-e2e-conformance-aws
/test k8s-e2e-gcp-ovn
/test k8s-e2e-gcp-serial

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn-hypershift

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/e2e/storage/drivers/csi.go (1)

393-396: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Return cleanup errors from the helper or remove this branch.

CleanupSnapshotMetadataResources logs each deletion error and returns nil in test/e2e/storage/utils/snapshot-metadata.go, Line 248 through Line 274. Therefore, the err != nil branch at Line 394 through Line 396 cannot execute.

Either aggregate and return cleanup errors from the helper, or keep the warning in the helper and remove this dead check.

🤖 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 `@test/e2e/storage/drivers/csi.go` around lines 393 - 396, Remove the
unreachable err != nil warning branch after CleanupSnapshotMetadataResources in
the surrounding cleanup flow, since that helper currently logs deletion failures
and returns nil. Keep the helper’s existing warning behavior unchanged.
🤖 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 `@test/e2e/storage/drivers/csi.go`:
- Around line 384-391: Reorder snapshot-metadata setup in the driver
initialization flow: register DeferCleanup before
CreateSnapshotMetadataResources, create the TLS Secret before
utils.CreateFromManifests, and retain cleanup for any partial failure. Ensure
CleanupSnapshotMetadataResources is invoked for resources created before
subsequent setup errors.

---

Nitpick comments:
In `@test/e2e/storage/drivers/csi.go`:
- Around line 393-396: Remove the unreachable err != nil warning branch after
CleanupSnapshotMetadataResources in the surrounding cleanup flow, since that
helper currently logs deletion failures and returns nil. Keep the helper’s
existing warning behavior unchanged.
🪄 Autofix

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: a307d51b-2da9-4f81-847b-9629e751eca2

📥 Commits

Reviewing files that changed from the base of the PR and between e63ab41 and b1f4285.

📒 Files selected for processing (2)
  • test/e2e/storage/drivers/csi.go
  • test/e2e/storage/testsuites/snapshot-metadata.go
💤 Files with no reviewable changes (1)
  • test/e2e/storage/testsuites/snapshot-metadata.go

Comment on lines +384 to +391
if h.driverInfo.Capabilities[storageframework.CapSnapshotMetadata] {
// Create snapshot metadata resources (CRD is already created by test runner script)
ginkgo.By("Creating snapshot metadata resources")
err = utils.CreateSnapshotMetadataResources(ctx, f, config.Driver.GetDriverInfo().Name, driverns)
if err != nil {
framework.Failf("failed to create snapshot metadata resources: %v", err)
}
ginkgo.DeferCleanup(func(ctx context.Context) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 12 \
  'func CreateFromManifests|csi-snapshot-metadata-server-certs|CreateSnapshotMetadataResources|CleanupSnapshotMetadataResources' \
  test/e2e/storage test/e2e/testing-manifests

Repository: openshift/kubernetes

Length of output: 20683


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- csi.go ---'
sed -n '310,415p' test/e2e/storage/drivers/csi.go

printf '%s\n' '--- create.go ---'
sed -n '130,235p' test/e2e/storage/utils/create.go

printf '%s\n' '--- snapshot-metadata.go ---'
sed -n '219,290p' test/e2e/storage/utils/snapshot-metadata.go

printf '%s\n' '--- manifest workload and secret references ---'
sed -n '300,465p' test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-plugin.yaml

Repository: openshift/kubernetes

Length of output: 15313


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

csi = Path("test/e2e/storage/drivers/csi.go").read_text()
create = Path("test/e2e/storage/utils/create.go").read_text()
snapshot = Path("test/e2e/storage/utils/snapshot-metadata.go").read_text()
manifest = Path("test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-plugin.yaml").read_text()

def body(text, signature):
    start = text.index(signature)
    brace = text.index("{", start)
    depth = 0
    for i in range(brace, len(text)):
        if text[i] == "{":
            depth += 1
        elif text[i] == "}":
            depth -= 1
            if depth == 0:
                return text[start:i+1]
    raise RuntimeError(signature)

create_body = body(create, "func CreateFromManifestsTCtx")
snapshot_body = body(snapshot, "func CreateSnapshotMetadataResources")
cleanup_body = body(snapshot, "func CleanupSnapshotMetadataResources")

print("CreateFromManifestsTCtx creates items after loading/patching:")
for token in ("LoadFromManifests", "PatchItemsTCtx", "CreateItem", "Wait"):
    print(f"  {token}: {token in create_body}")

print("CreateSnapshotMetadataResources write order:")
for token in ("createTLSSecret", "createSnapshotMetadataSVC", "createSnapshotMetdataServiceCR"):
    print(f"  {token}: offset {snapshot_body.find(token)}")
print("Cleanup registration relative to helper call:")
print("  helper call offset:", csi.find("utils.CreateSnapshotMetadataResources"))
print("  DeferCleanup offset:", csi.find("ginkgo.DeferCleanup", csi.find("utils.CreateSnapshotMetadataResources")))

print("Manifest Secret reference count:")
print("  volume secretName:", len(re.findall(r"secretName:\s*csi-snapshot-metadata-server-certs", manifest)))
print("  volume mount name:", len(re.findall(r"name:\s*csi-snapshot-metadata-server-certs", manifest)))

print("CleanupSnapshotMetadataResources returns an error:")
print("  return statements:", re.findall(r"(?m)^\s*return\b.*$", cleanup_body))
PY

Repository: openshift/kubernetes

Length of output: 738


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- snapshot resource creators ---'
sed -n '80,220p' test/e2e/storage/utils/snapshot-metadata.go

printf '%s\n' '--- corrected CreateFromManifests verifier ---'
python3 - <<'PY'
from pathlib import Path

text = Path("test/e2e/storage/utils/create.go").read_text()
start = text.index("func CreateFromManifestsTCtx")
end = text.index("// What is a subset", start)
body = text[start:end]

for token in ("LoadFromManifests", "PatchItemsTCtx", "patch(item)", "createItems"):
    print(f"{token}: {token in body}")

print("wait-like calls in CreateFromManifestsTCtx section:")
for line in body.splitlines():
    if any(token in line.lower() for token in ("wait", "poll", "observe")):
        print(line.strip())
PY

Repository: openshift/kubernetes

Length of output: 5245


Create snapshot-metadata resources before starting the driver and register cleanup early.

  • Create the TLS Secret before utils.CreateFromManifests. The StatefulSet references this Secret and reports FailedMount until it exists.
  • Register ginkgo.DeferCleanup before CreateSnapshotMetadataResources, or add rollback. A later creation failure leaves earlier resources behind. CleanupSnapshotMetadataResources always returns nil, so cleanup errors cannot reach the caller.
🤖 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 `@test/e2e/storage/drivers/csi.go` around lines 384 - 391, Reorder
snapshot-metadata setup in the driver initialization flow: register DeferCleanup
before CreateSnapshotMetadataResources, create the TLS Secret before
utils.CreateFromManifests, and retain cleanup for any partial failure. Ensure
CleanupSnapshotMetadataResources is invoked for resources created before
subsequent setup errors.

Source: MCP tools

@dobsonj

dobsonj commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

/test ?

@dobsonj

dobsonj commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

/test e2e-aws-csi
/test e2e-aws

@dobsonj

dobsonj commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-serial-1of2
/test e2e-aws-ovn-techpreview-serial-2of2

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

@dobsonj: 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-aws-ovn-fips b1f4285 link true /test e2e-aws-ovn-fips
ci/prow/k8s-e2e-gcp-serial b1f4285 link true /test k8s-e2e-gcp-serial
ci/prow/e2e-metal-ipi-ovn-ipv6 b1f4285 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-gcp b1f4285 link true /test e2e-gcp
ci/prow/e2e-aws-ovn-serial-2of2 b1f4285 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-aws-ovn-cgroupsv2 b1f4285 link true /test e2e-aws-ovn-cgroupsv2
ci/prow/k8s-e2e-gcp-ovn b1f4285 link true /test k8s-e2e-gcp-ovn
ci/prow/e2e-aws-ovn-serial-1of2 b1f4285 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-aws b1f4285 link false /test e2e-aws
ci/prow/e2e-aws-ovn-crun b1f4285 link true /test e2e-aws-ovn-crun

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.

@openshift-ci-robot

Copy link
Copy Markdown

@dobsonj: the contents of this pull request could not be automatically validated.

The following commits could not be validated and must be approved by a top-level approver:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@dobsonj

dobsonj commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-serial-1of2
/test e2e-aws-ovn-techpreview-serial-2of2

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

Labels

backports/unvalidated-commits Indicates that not all commits come to merged upstream PRs. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants