@@ -279,14 +279,14 @@ func TestEncryptionRotation(ctx context.Context, t testing.TB, scenario Rotation
279279}
280280
281281// InvalidImageRecoveryScenario tests that an invalid KMS plugin image causes
282- // the cluster to degrade and that correcting the image restores normal operation.
282+ // the operator to degrade (even when switching to aescbc) and that providing
283+ // a valid KMS image restores normal operation.
283284//
284- // Arda's scenario:
285- // 1. Enable KMS with invalid image
286- // 2. Attempt to switch to aescbc (cluster should be stuck on KMS)
287- // 3. See degraded
288- // 4. Update with KMS with valid image
289- // 5. See everything works
285+ // Flow:
286+ // 1. Enable KMS with invalid (non-existent) plugin image
287+ // 2. Switch to aescbc — cluster should remain stuck on KMS (rollout blocked)
288+ // 3. Operator reports degraded (stuck NodeInstaller, ImagePullBackOff, etc.)
289+ // 4. Fix by applying KMS with valid image and wait for full encryption migration
290290type InvalidImageRecoveryScenario struct {
291291 BasicScenario
292292 // InvalidImageProvider is the KMS EncryptionProvider configured with an invalid
@@ -297,19 +297,15 @@ type InvalidImageRecoveryScenario struct {
297297 ValidImageProvider EncryptionProvider
298298 // WaitForDegraded should block until the operator reports a degraded condition.
299299 WaitForDegraded func (ctx context.Context , t testing.TB )
300- // WaitForRecovery should block until the operator reports a healthy condition
301- // and encryption is fully operational.
302- WaitForRecovery func (ctx context.Context , t testing.TB )
303300}
304301
305302// TestEncryptionInvalidImageRecovery tests that:
306- // 1. Enabling KMS with an invalid plugin image causes degradation
307- // 2. The cluster remains stuck and cannot migrate to another mode (e.g. aescbc )
308- // 3. Fixing the KMS config with a valid image restores the cluster
303+ // 1. Enabling KMS with an invalid plugin image causes the operator to degrade
304+ // 2. Switching to aescbc does NOT recover (cluster is stuck on the failed KMS rollout )
305+ // 3. Providing a valid KMS image restores the cluster (uses SetAndWaitForEncryptionType)
309306func TestEncryptionInvalidImageRecovery (ctx context.Context , t testing.TB , scenario InvalidImageRecoveryScenario ) {
310307 e := NewE (t , PrintEventsOnFailure (scenario .OperatorNamespace ))
311308 require .NotNil (t , scenario .WaitForDegraded , "WaitForDegraded must not be nil" )
312- require .NotNil (t , scenario .WaitForRecovery , "WaitForRecovery must not be nil" )
313309 require .Equal (t , configv1 .EncryptionTypeKMS , scenario .InvalidImageProvider .Type , "InvalidImageProvider must be KMS type" )
314310 require .Equal (t , configv1 .EncryptionTypeKMS , scenario .ValidImageProvider .Type , "ValidImageProvider must be KMS type" )
315311
@@ -326,32 +322,25 @@ func TestEncryptionInvalidImageRecovery(ctx context.Context, t testing.TB, scena
326322 _ , err = cs .ApiServerConfig .Update (ctx , apiServer , metav1.UpdateOptions {})
327323 require .NoError (t , err )
328324
329- // step 2: attempt to switch to aescbc — cluster should remain stuck on KMS
325+ // step 2: attempt to switch to aescbc — the cluster should remain stuck on KMS
326+ // because the static pod rollout with the invalid image is blocking progress
330327 t .Log ("Attempting to switch to aescbc (cluster should remain stuck on KMS)" )
331328 apiServer , err = cs .ApiServerConfig .Get (ctx , "cluster" , metav1.GetOptions {})
332329 require .NoError (t , err )
333330 apiServer .Spec .Encryption = configv1.APIServerEncryption {Type : configv1 .EncryptionTypeAESCBC }
334331 _ , err = cs .ApiServerConfig .Update (ctx , apiServer , metav1.UpdateOptions {})
335332 require .NoError (t , err )
336333
337- // step 3: wait for degraded
334+ // step 3: wait for degraded — the operator is stuck because the invalid KMS image
335+ // prevents the NodeInstaller from completing the rollout
338336 t .Log ("Waiting for operator to report degraded status" )
339337 scenario .WaitForDegraded (ctx , e )
340338
341- // step 4: fix the config with valid KMS image
342- t .Log ("Updating KMS encryption with valid plugin image to recover" )
343- if scenario .ValidImageProvider .Setup != nil {
344- scenario .ValidImageProvider .Setup (ctx , e )
345- }
346- apiServer , err = cs .ApiServerConfig .Get (ctx , "cluster" , metav1.GetOptions {})
347- require .NoError (t , err )
348- apiServer .Spec .Encryption = scenario .ValidImageProvider .APIServerEncryption
349- _ , err = cs .ApiServerConfig .Update (ctx , apiServer , metav1.UpdateOptions {})
350- require .NoError (t , err )
351-
352- // step 5: wait for recovery — everything should work
353- t .Log ("Waiting for operator to recover with valid KMS image" )
354- scenario .WaitForRecovery (ctx , e )
339+ // step 4: fix by applying KMS with valid image and wait for full recovery
340+ // (uses SetAndWaitForEncryptionType which waits for encryption key migration,
341+ // same as the standard encryption on/off and migration tests)
342+ t .Log ("Recovering: applying KMS with valid plugin image and waiting for full migration" )
343+ SetAndWaitForEncryptionType (ctx , e , scenario .ValidImageProvider , scenario .TargetGRs , scenario .Namespace , scenario .LabelSelector )
355344
356345 t .Log ("Invalid image recovery test passed" )
357346}
0 commit comments