Repository navigation
fake bump kmstokms test #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 1.25 | ||
| 1.25 | ||
| 1.25 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .ci-operator.yaml: 1.25 | ||
| go.mod: 1.25 | ||
| Dockerfile: 1.25 |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,12 +19,20 @@ import ( | |||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| var _ = g.Describe("[sig-openshift-apiserver] cluster-openshift-apiserver-operator", func() { | ||||||||||||
| g.It("TestKMSEncryptionOnOff [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| testKMSEncryptionOnOff(ctx, g.GinkgoTB()) | ||||||||||||
| //g.It("TestKMSEncryptionOnOff [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| // testKMSEncryptionOnOff(ctx, g.GinkgoTB()) | ||||||||||||
| //}) | ||||||||||||
|
|
||||||||||||
| //g.It("TestKMSEncryptionProvidersMigration [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| // testKMSEncryptionProvidersMigration(ctx, g.GinkgoTB()) | ||||||||||||
| //}) | ||||||||||||
|
|
||||||||||||
| g.It("TestKMSToKMSMigration [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| testKMSToKMSMigration(ctx, g.GinkgoTB()) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| g.It("TestKMSEncryptionProvidersMigration [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| testKMSEncryptionProvidersMigration(ctx, g.GinkgoTB()) | ||||||||||||
| g.It("TestKMSToKMSOnOff [OCPFeatureGate:KMSEncryption][Serial][Timeout:120m]", func(ctx context.Context) { | ||||||||||||
| testKMSToKMSOnOff(ctx, g.GinkgoTB()) | ||||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
|
|
@@ -108,3 +116,65 @@ func testKMSEncryptionProvidersMigration(ctx context.Context, t testing.TB) { | |||||||||||
| }), | ||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // testKMSToKMSMigration tests KMS-to-KMS migration (primary → secondary → primary → identity). | ||||||||||||
| func testKMSToKMSMigration(ctx context.Context, t testing.TB) { | ||||||||||||
| cs := operatorencryption.GetClients(t) | ||||||||||||
|
|
||||||||||||
| ns := fmt.Sprintf("test-kms-to-kms-migration-%d", rand.IntN(4)) | ||||||||||||
| _, err := cs.KubeClient.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}}, metav1.CreateOptions{}) | ||||||||||||
| require.NoError(t, err) | ||||||||||||
| defer cs.KubeClient.CoreV1().Namespaces().Delete(ctx, ns, metav1.DeleteOptions{}) | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate the file and check its content around the specified lines
wc -l test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 136 🏁 Script executed: # Read the file around lines 127 and 158 to verify the issue
sed -n '120,165p' test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 3107 🏁 Script executed: # Check the imports in the file to see if require is available
head -30 test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 1260 🏁 Script executed: # Check for other Delete() calls that might have similar issues
grep -n "\.Delete(" test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 436 🏁 Script executed: # Also search for similar patterns with deferred operations that might ignore errors
grep -n "defer.*\\.Delete\\|defer.*\\.Delete(" test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 436 Fix ignored errors in deferred namespace cleanup across all instances. Lines 57, 94, 127, and 158 all ignore errors from 🛠️ Suggested fix- defer cs.KubeClient.CoreV1().Namespaces().Delete(ctx, ns, metav1.DeleteOptions{})
+ defer func() {
+ err := cs.KubeClient.CoreV1().Namespaces().Delete(ctx, ns, metav1.DeleteOptions{})
+ require.NoError(t, err)
+ }()Apply this pattern to all four occurrences (lines 57, 94, 127, and 158). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||
|
|
||||||||||||
| library.TestKMSToKMSMigration(ctx, t, library.KMSToKMSMigrationScenario{ | ||||||||||||
| BasicScenario: library.BasicScenario{ | ||||||||||||
| Namespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||||||||||||
| LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + operatorclient.TargetNamespace, | ||||||||||||
| EncryptionConfigSecretName: fmt.Sprintf("encryption-config-%s", operatorclient.TargetNamespace), | ||||||||||||
| EncryptionConfigSecretNamespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||||||||||||
| OperatorNamespace: operatorclient.OperatorNamespace, | ||||||||||||
| TargetGRs: operatorencryption.DefaultTargetGRs, | ||||||||||||
| AssertFunc: operatorencryption.AssertRoutes, | ||||||||||||
| }, | ||||||||||||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||||||||||||
| return operatorencryption.CreateAndStoreRouteOfLife(context.TODO(), t, operatorencryption.GetClients(t), ns) | ||||||||||||
| }, | ||||||||||||
|
Comment on lines
+140
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -t f encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 132 🏁 Script executed: wc -l test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 136 🏁 Script executed: sed -n '130,180p' test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 3466 🏁 Script executed: sed -n '100,145p' test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 3141 🏁 Script executed: sed -n '155,180p' test/e2e-encryption-kms/encryption_kms.goRepository: openshift/cluster-openshift-apiserver-operator Length of output: 1880 🏁 Script executed: sed -n '70,130p' test/e2e-encryption-kms/encryption_kms.go | head -70Repository: openshift/cluster-openshift-apiserver-operator Length of output: 3774 Replace Lines 140 and 171 use Suggested fixesLine 140: - return operatorencryption.CreateAndStoreRouteOfLife(context.TODO(), t, operatorencryption.GetClients(t), ns)
+ return operatorencryption.CreateAndStoreRouteOfLife(ctx, t, operatorencryption.GetClients(t), ns)Line 171: - return operatorencryption.CreateAndStoreRouteOfLife(context.TODO(), t, operatorencryption.GetClients(t), ns)
+ return operatorencryption.CreateAndStoreRouteOfLife(ctx, t, operatorencryption.GetClients(t), ns)📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||
| AssertResourceEncryptedFunc: operatorencryption.AssertRouteOfLifeEncrypted, | ||||||||||||
| AssertResourceNotEncryptedFunc: operatorencryption.AssertRouteOfLifeNotEncrypted, | ||||||||||||
| ResourceFunc: func(t testing.TB, _ string) runtime.Object { return operatorencryption.RouteOfLife(t, ns) }, | ||||||||||||
| ResourceName: "RouteOfLife", | ||||||||||||
| PrimaryProvider: librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||||||||||||
| SecondaryProvider: librarykms.SecondaryVaultEncryptionProvider(ctx, t), | ||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // testKMSToKMSOnOff tests KMS on/off cycle with two distinct KMS providers. | ||||||||||||
| func testKMSToKMSOnOff(ctx context.Context, t testing.TB) { | ||||||||||||
| cs := operatorencryption.GetClients(t) | ||||||||||||
|
|
||||||||||||
| ns := fmt.Sprintf("test-kms-to-kms-onoff-%d", rand.IntN(4)) | ||||||||||||
| _, err := cs.KubeClient.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}}, metav1.CreateOptions{}) | ||||||||||||
| require.NoError(t, err) | ||||||||||||
| defer cs.KubeClient.CoreV1().Namespaces().Delete(ctx, ns, metav1.DeleteOptions{}) | ||||||||||||
|
|
||||||||||||
| library.TestKMSToKMSOnOff(ctx, t, library.KMSToKMSMigrationScenario{ | ||||||||||||
| BasicScenario: library.BasicScenario{ | ||||||||||||
| Namespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||||||||||||
| LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + operatorclient.TargetNamespace, | ||||||||||||
| EncryptionConfigSecretName: fmt.Sprintf("encryption-config-%s", operatorclient.TargetNamespace), | ||||||||||||
| EncryptionConfigSecretNamespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||||||||||||
| OperatorNamespace: operatorclient.OperatorNamespace, | ||||||||||||
| TargetGRs: operatorencryption.DefaultTargetGRs, | ||||||||||||
| AssertFunc: operatorencryption.AssertRoutes, | ||||||||||||
| }, | ||||||||||||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||||||||||||
| return operatorencryption.CreateAndStoreRouteOfLife(context.TODO(), t, operatorencryption.GetClients(t), ns) | ||||||||||||
| }, | ||||||||||||
| AssertResourceEncryptedFunc: operatorencryption.AssertRouteOfLifeEncrypted, | ||||||||||||
| AssertResourceNotEncryptedFunc: operatorencryption.AssertRouteOfLifeNotEncrypted, | ||||||||||||
| ResourceFunc: func(t testing.TB, _ string) runtime.Object { return operatorencryption.RouteOfLife(t, ns) }, | ||||||||||||
| ResourceName: "RouteOfLife", | ||||||||||||
| PrimaryProvider: librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||||||||||||
| SecondaryProvider: librarykms.SecondaryVaultEncryptionProvider(ctx, t), | ||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase namespace entropy to avoid test collisions.
Line 124 and Line 155 use
rand.IntN(4), which gives only 4 possible namespace names; this is prone toAlreadyExistsflakes across reruns/shards.💡 Suggested fix
Also applies to: 155-156
🤖 Prompt for AI Agents