diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java index 09516a0..0689a97 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java @@ -193,7 +193,33 @@ public class K8sGenericStub updateStatus(O object, + Function status, int retries) throws ApiException { + while (true) { + try { + return K8s.optional(api.updateStatus(object, status)); + } catch (ApiException e) { + if (HttpURLConnection.HTTP_CONFLICT != e.getCode() + || retries-- <= 0) { + throw e; + } + } + } + } + + /** + * Updates the object's status, retrying up to 16 times if there + * is a conflict. * * @param object the current state of the object (passed to `status`) * @param status function that returns the new status @@ -202,7 +228,7 @@ public class K8sGenericStub updateStatus(O object, Function status) throws ApiException { - return K8s.optional(api.updateStatus(object, status)); + return updateStatus(object, status, 16); } /**