Skip to content

Commit bc7da27

Browse files
gcs278claude
andcommitted
OCPBUGS-81751: Fix GatewayClass update conflict in markTestDone
Add retry logic to markTestDone to handle optimistic locking conflicts when updating GatewayClass annotations. The CIO actively manages the GatewayClass (updating conditions, status, finalizers) which can cause 409 Conflict errors when tests try to update annotations. Using RetryOnConflict ensures the test automatically retries with the latest resourceVersion when concurrent updates occur. Fixes flake: Operation cannot be fulfilled on gatewayclasses.gateway.networking.k8s.io "openshift-default": the object has been modified; please apply your changes to the latest version and try again https://redhat.atlassian.net/browse/OCPBUGS-81751 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e14c7a9 commit bc7da27

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
@@ -34,6 +34,7 @@ import (
3434
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3535
"k8s.io/apimachinery/pkg/util/wait"
3636
"k8s.io/apiserver/pkg/storage/names"
37+
"k8s.io/client-go/util/retry"
3738
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
3839
)
3940

@@ -1101,14 +1102,19 @@ func annotationKeyForTest(testName string) string {
11011102
// These annotations are used to determine whether it is safe to clean up the
11021103
// gatewayclass and other shared resources.
11031104
func markTestDone(oc *exutil.CLI, testName string) {
1104-
gwc, err := oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Get(context.Background(), gatewayClassName, metav1.GetOptions{})
1105-
o.Expect(err).NotTo(o.HaveOccurred())
1105+
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
1106+
gwc, err := oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Get(context.Background(), gatewayClassName, metav1.GetOptions{})
1107+
if err != nil {
1108+
return err
1109+
}
11061110

1107-
if gwc.Annotations == nil {
1108-
gwc.Annotations = map[string]string{}
1109-
}
1110-
gwc.Annotations[annotationKeyForTest(testName)] = ""
1111-
_, err = oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Update(context.Background(), gwc, metav1.UpdateOptions{})
1111+
if gwc.Annotations == nil {
1112+
gwc.Annotations = map[string]string{}
1113+
}
1114+
gwc.Annotations[annotationKeyForTest(testName)] = ""
1115+
_, err = oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Update(context.Background(), gwc, metav1.UpdateOptions{})
1116+
return err
1117+
})
11121118
o.Expect(err).NotTo(o.HaveOccurred())
11131119
}
11141120

0 commit comments

Comments
 (0)