Skip to content

Commit c2c4593

Browse files
Merge pull request #30964 from gcs278/fix-ensure-gc-sail-finalizer-flake
OCPBUGS-81751: Fix GatewayClass update conflict in markTestDone
2 parents e7e6de2 + 8e4e43a commit c2c4593

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

test/extended/router/gatewayapicontroller.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434
"k8s.io/apimachinery/pkg/util/wait"
3535
"k8s.io/apiserver/pkg/storage/names"
36+
"k8s.io/client-go/util/retry"
3637
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
3738
)
3839

@@ -1121,14 +1122,19 @@ func annotationKeyForTest(testName string) string {
11211122
// These annotations are used to determine whether it is safe to clean up the
11221123
// gatewayclass and other shared resources.
11231124
func markTestDone(oc *exutil.CLI, testName string) {
1124-
gwc, err := oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Get(context.Background(), gatewayClassName, metav1.GetOptions{})
1125-
o.Expect(err).NotTo(o.HaveOccurred())
1125+
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
1126+
gwc, err := oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Get(context.Background(), gatewayClassName, metav1.GetOptions{})
1127+
if err != nil {
1128+
return err
1129+
}
11261130

1127-
if gwc.Annotations == nil {
1128-
gwc.Annotations = map[string]string{}
1129-
}
1130-
gwc.Annotations[annotationKeyForTest(testName)] = ""
1131-
_, err = oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Update(context.Background(), gwc, metav1.UpdateOptions{})
1131+
if gwc.Annotations == nil {
1132+
gwc.Annotations = map[string]string{}
1133+
}
1134+
gwc.Annotations[annotationKeyForTest(testName)] = ""
1135+
_, err = oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Update(context.Background(), gwc, metav1.UpdateOptions{})
1136+
return err
1137+
})
11321138
o.Expect(err).NotTo(o.HaveOccurred())
11331139
}
11341140

0 commit comments

Comments
 (0)