STOR-2893: add storage BYOK feature tests#30786
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
|
@Phaow: This pull request references STOR-2893 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.22.0" version, but no target version was set. DetailsIn response to this: 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. |
|
@Phaow: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
@Phaow: This pull request references STOR-2893 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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. |
Signed-off-by: Penghao <pewang@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Phaow The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retitle STOR-2893: add storage BYOK feature tests |
WalkthroughThis pull request adds IBM Cloud support to the cluster discovery provider system and introduces a CSI provisioner configuration framework for testing Bring-Your-Own-Key (BYOK) functionality across multiple cloud platforms and storage provisioners. Changes
Sequence DiagramsequenceDiagram
participant Test as BYOK Test Suite
participant Cluster as Kubernetes Cluster
participant Config as Config Module
participant CSI as ClusterCSIDriver
participant SC as Storage Classes
Test->>Config: GetBYOKProvisioners(platform)
Config-->>Test: Provisioner list
loop For each provisioner
Test->>Config: GetProvisionerInfo(name)
Config-->>Test: Provisioner details
Test->>CSI: Read ClusterCSIDriver resource
CSI-->>Test: Driver config with BYOK key
Test->>Test: Extract BYOK key by driver type
Test->>Config: GetPresetStorageClassNames(provisioner)
Config-->>Test: Storage class names
Test->>SC: Query storage classes
SC-->>Test: Storage class definitions
Test->>Test: Validate provisioner matches<br/>& BYOK key present
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. 🔧 golangci-lint (2.5.0)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
|
@Phaow: This pull request references STOR-2893 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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. |
|
/payload 4.22 nightly blocking |
|
@Phaow: trigger 14 job(s) of type blocking for the nightly release of OCP 4.22
See details on https://pr-payload-tests.ci.openshift.org/runs/ci/59ff5e70-1967-11f1-8951-ff2be3f06a63-0 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/extended/storage/csi_byok.go`:
- Around line 64-67: The current test silently skips when
oc.AdminKubeClient().StorageV1().StorageClasses().Get(...) returns an error
(using g.Skip), which masks failures; change the behavior to fail the test
instead — replace the g.Skip(...) call for the StorageClasses().Get error with a
test failure call (e.g., e2e.Failf or the test suite's Failf) and include the
storage class name and error in the failure message; ensure this change is
applied around the retrieval of scName so missing managed storage classes cause
a test failure rather than a skip.
- Around line 48-51: The test currently treats an empty result from
getByokKeyIDFromClusterCSIDriver as "not BYOK" and skips, which hides API/read
failures; change getByokKeyIDFromClusterCSIDriver to return (string, error)
instead of just string, propagate the error to the caller in the test (where
byokKeyID := getByokKeyIDFromClusterCSIDriver(oc, provisioner) is called), and
update the test to fail (e.g., g.Fatal/g.Fatalf) when err != nil while only
calling g.Skip when err == nil and the returned key ID is empty; update all call
sites accordingly so real API errors surface as test failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 85f78b6f-b37d-4d55-9930-99e31dd09b5b
📒 Files selected for processing (4)
pkg/clioptions/clusterdiscovery/cluster.gopkg/clioptions/clusterdiscovery/provider.gotest/extended/storage/const.gotest/extended/storage/csi_byok.go
| byokKeyID := getByokKeyIDFromClusterCSIDriver(oc, provisioner) | ||
| if len(byokKeyID) == 0 { | ||
| g.Skip("Skipped: the cluster is not byok cluster, no key settings in clustercsidriver/" + provisioner) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n test/extended/storage/csi_byok.goRepository: openshift/origin
Length of output: 5921
🏁 Script executed:
rg -n "getByokKeyIDFromClusterCSIDriver" test/extended/storage/csi_byok.goRepository: openshift/origin
Length of output: 214
Differentiate "not BYOK-configured" from API/read failures.
When ClusterCSIDriver fetch fails, the function returns "" and the test skips instead of failing. This masks real infrastructure issues and regressions—API errors should cause test failure, not silent skips.
🔧 Proposed fix
import (
"context"
"fmt"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
e2e "k8s.io/kubernetes/test/e2e/framework"
admissionapi "k8s.io/pod-security-admission/api"
@@
- byokKeyID := getByokKeyIDFromClusterCSIDriver(oc, provisioner)
- if len(byokKeyID) == 0 {
+ byokKeyID, byokConfigured, err := getByokKeyIDFromClusterCSIDriver(oc, provisioner)
+ o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("failed to get ClusterCSIDriver/%s", provisioner))
+ if !byokConfigured {
g.Skip("Skipped: the cluster is not byok cluster, no key settings in clustercsidriver/" + provisioner)
}
@@
-func getByokKeyIDFromClusterCSIDriver(oc *exutil.CLI, provisioner string) string {
+func getByokKeyIDFromClusterCSIDriver(oc *exutil.CLI, provisioner string) (string, bool, error) {
clusterCSIDriver, err := oc.AdminOperatorClient().OperatorV1().ClusterCSIDrivers().Get(context.Background(), provisioner, metav1.GetOptions{})
if err != nil {
- e2e.Logf("Failed to get ClusterCSIDriver %s: %v", provisioner, err)
- return ""
+ if apierrors.IsNotFound(err) {
+ return "", false, nil
+ }
+ return "", false, err
}
@@
driverConfig := clusterCSIDriver.Spec.DriverConfig
if driverConfig.DriverType == "" {
- return ""
+ return "", false, nil
}
@@
case "AWS":
if driverConfig.AWS != nil {
- return driverConfig.AWS.KMSKeyARN
+ return driverConfig.AWS.KMSKeyARN, true, nil
}
@@
case "IBMCloud":
if driverConfig.IBMCloud != nil {
- return driverConfig.IBMCloud.EncryptionKeyCRN
+ return driverConfig.IBMCloud.EncryptionKeyCRN, true, nil
}
}
- return ""
+ return "", false, nil
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@test/extended/storage/csi_byok.go` around lines 48 - 51, The test currently
treats an empty result from getByokKeyIDFromClusterCSIDriver as "not BYOK" and
skips, which hides API/read failures; change getByokKeyIDFromClusterCSIDriver to
return (string, error) instead of just string, propagate the error to the caller
in the test (where byokKeyID := getByokKeyIDFromClusterCSIDriver(oc,
provisioner) is called), and update the test to fail (e.g., g.Fatal/g.Fatalf)
when err != nil while only calling g.Skip when err == nil and the returned key
ID is empty; update all call sites accordingly so real API errors surface as
test failures.
| sc, err := oc.AdminKubeClient().StorageV1().StorageClasses().Get(context.Background(), scName, metav1.GetOptions{}) | ||
| if err != nil { | ||
| g.Skip(fmt.Sprintf("Storage class %s not found in cluster: %v", scName, err)) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's see the broader context of this test function
head -n 100 test/extended/storage/csi_byok.go | tail -n 80Repository: openshift/origin
Length of output: 3168
🏁 Script executed:
# Let's also check the full test function that contains lines 64-67
sed -n '1,100p' test/extended/storage/csi_byok.go | cat -nRepository: openshift/origin
Length of output: 4283
🏁 Script executed:
# Search for similar storage class retrieval patterns in test files
rg "StorageClasses\(\)\.Get" test/ -A 3 -B 1Repository: openshift/origin
Length of output: 2315
Fail when expected managed StorageClasses are absent.
Skipping on StorageClasses().Get() error hides regressions in managed class creation. Since presetStorageClassNames is populated from configuration, missing classes indicate a provisioning issue, not an environmental skip condition. This pattern contradicts the test's assertion that "managed storage classes should be set with the specified encryption key"—if they don't exist, that's a test failure. Other storage tests in the suite (e.g., test/extended/storage/storageclass.go) use e2e.Failf() for similar retrieval errors, establishing the correct pattern.
Proposed fix
sc, err := oc.AdminKubeClient().StorageV1().StorageClasses().Get(context.Background(), scName, metav1.GetOptions{})
- if err != nil {
- g.Skip(fmt.Sprintf("Storage class %s not found in cluster: %v", scName, err))
- }
+ o.Expect(err).NotTo(o.HaveOccurred(),
+ fmt.Sprintf("expected managed storage class %s to exist", scName))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@test/extended/storage/csi_byok.go` around lines 64 - 67, The current test
silently skips when oc.AdminKubeClient().StorageV1().StorageClasses().Get(...)
returns an error (using g.Skip), which masks failures; change the behavior to
fail the test instead — replace the g.Skip(...) call for the
StorageClasses().Get error with a test failure call (e.g., e2e.Failf or the test
suite's Failf) and include the storage class name and error in the failure
message; ensure this change is applied around the retrieval of scName so missing
managed storage classes cause a test failure rather than a skip.
|
Scheduling required tests: |
Why we need this?
Test records
Summary by CodeRabbit
New Features
Tests