@@ -195,6 +195,7 @@ private static void begin() {
195
195
// this would happen when the Domain was running BEFORE the Operator starts up
196
196
LOGGER .info (MessageKeys .LISTING_DOMAINS );
197
197
for (String ns : targetNamespaces ) {
198
+ initialized .put (ns , Boolean .TRUE );
198
199
Step domainList = callBuilderFactory .create ().listDomainAsync (ns , new ResponseStep <DomainList >(null ) {
199
200
@ Override
200
201
public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
@@ -208,25 +209,12 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
208
209
@ Override
209
210
public NextAction onSuccess (Packet packet , DomainList result , int statusCode ,
210
211
Map <String , List <String >> responseHeaders ) {
211
- initialized .put (ns , Boolean .TRUE );
212
212
if (result != null ) {
213
213
for (Domain dom : result .getItems ()) {
214
214
doCheckAndCreateDomainPresence (dom );
215
215
}
216
216
}
217
217
218
- // delete stranded resources
219
- for (Map .Entry <String , DomainPresenceInfo > entry : domains .entrySet ()) {
220
- String domainUID = entry .getKey ();
221
- DomainPresenceInfo info = entry .getValue ();
222
- if (info != null ) {
223
- if (info .getDomain () == null ) {
224
- // no domain resource
225
- deleteDomainPresence (info .getNamespace (), domainUID );
226
- }
227
- }
228
- }
229
-
230
218
// main logic now happens in the watch handlers
231
219
domainWatchers .put (ns , createDomainWatcher (ns , result != null ? result .getMetadata ().getResourceVersion () : "" ));
232
220
return doNext (packet );
@@ -361,6 +349,18 @@ public void onThrowable(Packet packet, Throwable throwable) {
361
349
}
362
350
});
363
351
}
352
+
353
+ // delete stranded resources
354
+ for (Map .Entry <String , DomainPresenceInfo > entry : domains .entrySet ()) {
355
+ String domainUID = entry .getKey ();
356
+ DomainPresenceInfo info = entry .getValue ();
357
+ if (info != null ) {
358
+ if (info .getDomain () == null ) {
359
+ // no domain resource
360
+ deleteDomainPresence (info .getNamespace (), domainUID );
361
+ }
362
+ }
363
+ }
364
364
} catch (Throwable e ) {
365
365
LOGGER .warning (MessageKeys .EXCEPTION , e );
366
366
} finally {
@@ -577,6 +577,9 @@ private static void doCheckAndCreateDomainPresence(
577
577
normalizeDomainSpec (spec );
578
578
String domainUID = spec .getDomainUID ();
579
579
580
+ // TEST
581
+ System .out .println ("**** -1 **** domainUID: " + domainUID );
582
+
580
583
DomainPresenceInfo created = new DomainPresenceInfo (dom );
581
584
DomainPresenceInfo info = domains .putIfAbsent (domainUID , created );
582
585
if (info == null ) {
0 commit comments