Skip to content

Commit aea8b95

Browse files
committed
Merge branch 'prep/v4.0.0' into testing
2 parents 54747b2 + d27339b commit aea8b95

File tree

20 files changed

+432
-414
lines changed

20 files changed

+432
-414
lines changed

org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public JsonObject data() {
102102
*
103103
* @return the JSON object describing the status
104104
*/
105-
public JsonObject status() {
105+
public JsonObject statusJson() {
106106
return data.getAsJsonObject("status");
107107
}
108108

org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -193,42 +193,41 @@ public Optional<O> model() throws ApiException {
193193
}
194194

195195
/**
196-
* Updates the object's status, retrying for the given number of times
197-
* if the update fails due to a conflict.
196+
* Updates the object's status.
198197
*
199198
* @param object the current state of the object (passed to `status`)
200199
* @param status function that returns the new status
201-
* @param retries the retries
202-
* @return the updated model or empty if not successful
200+
* @return the updated model or empty if the object was not found
203201
* @throws ApiException the api exception
204202
*/
205203
@SuppressWarnings("PMD.AssignmentInOperand")
206-
public Optional<O> updateStatus(O object,
207-
Function<O, Object> status, int retries) throws ApiException {
208-
while (true) {
209-
try {
210-
return K8s.optional(api.updateStatus(object, status));
211-
} catch (ApiException e) {
212-
if (HttpURLConnection.HTTP_CONFLICT != e.getCode()
213-
|| retries-- <= 0) {
214-
throw e;
215-
}
216-
}
217-
}
204+
public Optional<O> updateStatus(O object, Function<O, Object> status)
205+
throws ApiException {
206+
return K8s.optional(api.updateStatus(object, status));
218207
}
219208

220209
/**
221-
* Updates the object's status, retrying up to 16 times if there
222-
* is a conflict.
210+
* Gets the object and updates the status. In case of conflict, retries
211+
* up to `retries` times.
223212
*
224-
* @param object the current state of the object (passed to `status`)
225-
* @param status function that returns the new status
226-
* @return the updated model or empty if not successful
213+
* @param status the status
214+
* @param retries the retries in case of conflict
215+
* @return the updated model or empty if the object was not found
227216
* @throws ApiException the api exception
228217
*/
229-
public Optional<O> updateStatus(O object,
230-
Function<O, Object> status) throws ApiException {
231-
return updateStatus(object, status, 16);
218+
@SuppressWarnings({ "PMD.AssignmentInOperand", "PMD.UnusedAssignment" })
219+
public Optional<O> updateStatus(Function<O, Object> status, int retries)
220+
throws ApiException {
221+
try {
222+
return updateStatus(api.get(namespace, name).throwsApiException()
223+
.getObject(), status);
224+
} catch (ApiException e) {
225+
if (HttpURLConnection.HTTP_CONFLICT != e.getCode()
226+
|| retries-- <= 0) {
227+
throw e;
228+
}
229+
}
230+
return Optional.empty();
232231
}
233232

234233
/**
@@ -241,8 +240,7 @@ public Optional<O> updateStatus(O object,
241240
*/
242241
public Optional<O> updateStatus(Function<O, Object> status)
243242
throws ApiException {
244-
return updateStatus(
245-
api.get(namespace, name).throwsApiException().getObject(), status);
243+
return updateStatus(status, 16);
246244
}
247245

248246
/**

0 commit comments

Comments
 (0)