@@ -195,6 +195,7 @@ private static void begin() {
195195 // this would happen when the Domain was running BEFORE the Operator starts up
196196 LOGGER .info (MessageKeys .LISTING_DOMAINS );
197197 for (String ns : targetNamespaces ) {
198+ initialized .put (ns , Boolean .TRUE );
198199 Step domainList = callBuilderFactory .create ().listDomainAsync (ns , new ResponseStep <DomainList >(null ) {
199200 @ Override
200201 public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
@@ -208,25 +209,12 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
208209 @ Override
209210 public NextAction onSuccess (Packet packet , DomainList result , int statusCode ,
210211 Map <String , List <String >> responseHeaders ) {
211- initialized .put (ns , Boolean .TRUE );
212212 if (result != null ) {
213213 for (Domain dom : result .getItems ()) {
214214 doCheckAndCreateDomainPresence (dom );
215215 }
216216 }
217217
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-
230218 // main logic now happens in the watch handlers
231219 domainWatchers .put (ns , createDomainWatcher (ns , result != null ? result .getMetadata ().getResourceVersion () : "" ));
232220 return doNext (packet );
@@ -361,6 +349,18 @@ public void onThrowable(Packet packet, Throwable throwable) {
361349 }
362350 });
363351 }
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+ }
364364 } catch (Throwable e ) {
365365 LOGGER .warning (MessageKeys .EXCEPTION , e );
366366 } finally {
@@ -577,6 +577,9 @@ private static void doCheckAndCreateDomainPresence(
577577 normalizeDomainSpec (spec );
578578 String domainUID = spec .getDomainUID ();
579579
580+ // TEST
581+ System .out .println ("**** -1 **** domainUID: " + domainUID );
582+
580583 DomainPresenceInfo created = new DomainPresenceInfo (dom );
581584 DomainPresenceInfo info = domains .putIfAbsent (domainUID , created );
582585 if (info == null ) {
0 commit comments