@@ -535,17 +535,16 @@ var _ = Describe("Configuration Anomaly Detection", Ordered, func() {
535
535
536
536
defer func () {
537
537
fmt .Println ("Restore: Restore backup configmap" )
538
- err = k8s .Update (ctx , backupCM )
538
+ err = retry .RetryOnConflict (retry .DefaultRetry , func () error {
539
+ currentCM := & corev1.ConfigMap {}
540
+ if err := k8s .Get (ctx , configMapName , namespace , currentCM ); err != nil {
541
+ return err
542
+ }
543
+ currentCM .Data = backupCM .Data
544
+ currentCM .BinaryData = backupCM .BinaryData
545
+ return k8s .Update (ctx , currentCM )
546
+ })
539
547
Expect (err ).ToNot (HaveOccurred (), "Restore the backup ConfigMap" )
540
-
541
- fmt .Println ("Restore: Get restore backup configmap" )
542
- restoreBackupCM := & corev1.ConfigMap {}
543
- err = k8s .Get (ctx , configMapName , namespace , restoreBackupCM )
544
- Expect (err ).ToNot (HaveOccurred (), "Failed to backup original ConfigMap" )
545
-
546
- fmt .Println ("Restore: Comparing backup and restored ConfigMaps" )
547
- Expect (restoreBackupCM .Data ).To (Equal (backupCM .Data ), "Restored ConfigMap data does not match the backup" )
548
- Expect (restoreBackupCM .BinaryData ).To (Equal (backupCM .BinaryData ), "Restored ConfigMap binary data does not match the backup" )
549
548
}()
550
549
551
550
fmt .Println ("Step 3: Injecting invalid config to simulate misconfiguration" )
0 commit comments