@@ -186,19 +186,44 @@ private Step createDomainStatusReplaceStep(DomainStatusUpdaterContext context, D
186
186
if (LOGGER .isFinerEnabled ()) {
187
187
LOGGER .finer ("status change: " + createPatchString (context , newStatus ));
188
188
}
189
+ /* MARKER-2.6.0-ONLY */
190
+ boolean useDomainStatusEndpoint = Main .useDomainStatusEndpoint .get ();
191
+ /* END-2.6.0-ONLY */
189
192
Domain oldDomain = context .getDomain ();
190
193
Domain newDomain = new Domain ()
191
194
.withKind (KubernetesConstants .DOMAIN )
192
195
.withApiVersion (oldDomain .getApiVersion ())
193
196
.withMetadata (oldDomain .getMetadata ())
194
- .withSpec (null )
197
+ /* MARKER-2.6.0-ONLY */
198
+ // WAS .withSpec(null)
199
+ .withSpec (useDomainStatusEndpoint ? null : oldDomain .getSpec ())
200
+ /* END-2.6.0-ONLY */
195
201
.withStatus (newStatus );
196
202
203
+ /* MARKER-2.6.0-ONLY */
204
+ /* WAS
197
205
return new CallBuilder().replaceDomainStatusAsync(
198
206
context.getDomainName(),
199
207
context.getNamespace(),
200
208
newDomain,
201
209
createResponseStep(context, getNext()));
210
+ */
211
+ if (useDomainStatusEndpoint ) {
212
+ return new CallBuilder ()
213
+ .replaceDomainStatusAsync (
214
+ context .getDomainName (),
215
+ context .getNamespace (),
216
+ newDomain ,
217
+ createResponseStep (context , newStatus , useDomainStatusEndpoint , getNext ()));
218
+ } else {
219
+ return new CallBuilder ()
220
+ .replaceDomainAsync (
221
+ context .getDomainName (),
222
+ context .getNamespace (),
223
+ newDomain ,
224
+ createResponseStep (context , newStatus , useDomainStatusEndpoint , getNext ()));
225
+ }
226
+ /* END-2.6.0-ONLY */
202
227
}
203
228
204
229
private String createPatchString (DomainStatusUpdaterContext context , DomainStatus newStatus ) {
@@ -207,24 +232,57 @@ private String createPatchString(DomainStatusUpdaterContext context, DomainStatu
207
232
return builder .build ().toString ();
208
233
}
209
234
210
- private ResponseStep <Domain > createResponseStep (DomainStatusUpdaterContext context , Step next ) {
211
- return new StatusReplaceResponseStep (this , context , next );
235
+ private ResponseStep <Domain > createResponseStep (DomainStatusUpdaterContext context ,
236
+ /* MARKER-2.6.0-ONLY */
237
+ DomainStatus newStatus , boolean useDomainStatusEndpoint ,
238
+ /* END-2.6.0-ONLY */
239
+ Step next ) {
240
+ return new StatusReplaceResponseStep (this ,
241
+ /* MARKER-2.6.0-ONLY */
242
+ newStatus , useDomainStatusEndpoint ,
243
+ /* END-2.6.0-ONLY */
244
+ context , next );
212
245
}
213
246
}
214
247
215
248
static class StatusReplaceResponseStep extends DefaultResponseStep <Domain > {
216
249
private final DomainStatusUpdaterStep updaterStep ;
217
250
private final DomainStatusUpdaterContext context ;
251
+ /* MARKER-2.6.0-ONLY */
252
+ private final DomainStatus newStatus ;
253
+ private final boolean useDomainStatusEndpoint ;
254
+ /* END-2.6.0-ONLY */
218
255
219
256
public StatusReplaceResponseStep (DomainStatusUpdaterStep updaterStep ,
257
+ /* MARKER-2.6.0-ONLY */
258
+ DomainStatus newStatus ,
259
+ boolean useDomainStatusEndpoint ,
260
+ /* END-2.6.0-ONLY */
220
261
DomainStatusUpdaterContext context , Step nextStep ) {
221
262
super (nextStep );
222
263
this .updaterStep = updaterStep ;
223
264
this .context = context ;
265
+ /* MARKER-2.6.0-ONLY */
266
+ this .newStatus = newStatus ;
267
+ this .useDomainStatusEndpoint = useDomainStatusEndpoint ;
268
+ /* END-2.6.0-ONLY */
224
269
}
225
270
226
271
@ Override
227
272
public NextAction onSuccess (Packet packet , CallResponse <Domain > callResponse ) {
273
+ /* MARKER-2.6.0-ONLY */
274
+ // If the 3.0.0 operator updated the CRD to use status endpoint while this operator is running
275
+ // then these domain replace calls will succeed, but the proposed domain status will have been
276
+ // ignored. Check if the status on the returned domain is expected
277
+ if (!useDomainStatusEndpoint && !newStatus .equals (callResponse .getResult ().getStatus ())) {
278
+ // TEST
279
+ System .out .println ("**** **** ****: Domain status update ignored; switching to status endpoint" );
280
+
281
+ // FIXME: would be better to recheck CRD
282
+ Main .useDomainStatusEndpoint .set (true );
283
+ return doNext (createRetry (context , getNext ()), packet );
284
+ }
285
+ /* END-2.6.0-ONLY */
228
286
packet .getSpi (DomainPresenceInfo .class ).setDomain (callResponse .getResult ());
229
287
return doNext (packet );
230
288
}
@@ -239,7 +297,7 @@ public NextAction onFailure(Packet packet, CallResponse<Domain> callResponse) {
239
297
}
240
298
241
299
public Step createRetry (DomainStatusUpdaterContext context , Step next ) {
242
- return Step .chain (createDomainRefreshStep (context ), updaterStep );
300
+ return Step .chain (createDomainRefreshStep (context ), updaterStep , next );
243
301
}
244
302
245
303
private Step createDomainRefreshStep (DomainStatusUpdaterContext context ) {
0 commit comments