12
12
import io .kubernetes .client .models .V1Service ;
13
13
import io .kubernetes .client .models .V1beta1Ingress ;
14
14
import io .kubernetes .client .util .Watch ;
15
- import java .util .Map ;
16
15
import java .util .concurrent .ScheduledFuture ;
17
16
import java .util .concurrent .TimeUnit ;
18
17
import java .util .concurrent .atomic .AtomicInteger ;
@@ -82,11 +81,11 @@ static void dispatchPodWatch(Watch.Response<V1Pod> item) {
82
81
case "DELETED" :
83
82
sko .getLastKnownStatus ().set (WebLogicConstants .SHUTDOWN_STATE );
84
83
V1Pod oldPod = sko .getPod ().getAndSet (null );
85
- if (oldPod != null ) {
84
+ if (oldPod != null && ! info . isDeleting () ) {
86
85
// Pod was deleted, but sko still contained a non-null entry
87
86
LOGGER .info (
88
87
MessageKeys .POD_DELETED , domainUID , metadata .getNamespace (), serverName );
89
- makeRightDomainPresence (info , info .getDomain (), false , false , true );
88
+ makeRightDomainPresence (info , domainUID , info .getDomain (), false , false , true );
90
89
}
91
90
break ;
92
91
@@ -150,14 +149,14 @@ static void dispatchServiceWatch(Watch.Response<V1Service> item) {
150
149
if (sko != null ) {
151
150
if (channelName != null ) {
152
151
V1Service oldService = sko .getChannels ().remove (channelName );
153
- if (oldService != null ) {
152
+ if (oldService != null && ! info . isDeleting () ) {
154
153
// Service was deleted, but sko still contained a non-null entry
155
154
LOGGER .info (
156
155
MessageKeys .SERVER_SERVICE_DELETED ,
157
156
domainUID ,
158
157
metadata .getNamespace (),
159
158
serverName );
160
- makeRightDomainPresence (info , info .getDomain (), false , false , true );
159
+ makeRightDomainPresence (info , domainUID , info .getDomain (), false , false , true );
161
160
}
162
161
} else {
163
162
V1Service oldService = sko .getService ().getAndSet (null );
@@ -168,7 +167,7 @@ static void dispatchServiceWatch(Watch.Response<V1Service> item) {
168
167
domainUID ,
169
168
metadata .getNamespace (),
170
169
serverName );
171
- makeRightDomainPresence (info , info .getDomain (), false , false , true );
170
+ makeRightDomainPresence (info , domainUID , info .getDomain (), false , false , true );
172
171
}
173
172
}
174
173
} else if (clusterName != null ) {
@@ -180,7 +179,7 @@ static void dispatchServiceWatch(Watch.Response<V1Service> item) {
180
179
domainUID ,
181
180
metadata .getNamespace (),
182
181
clusterName );
183
- makeRightDomainPresence (info , info .getDomain (), false , false , true );
182
+ makeRightDomainPresence (info , domainUID , info .getDomain (), false , false , true );
184
183
}
185
184
}
186
185
break ;
@@ -214,11 +213,11 @@ static void dispatchIngressWatch(Watch.Response<V1beta1Ingress> item) {
214
213
break ;
215
214
case "DELETED" :
216
215
V1beta1Ingress oldIngress = info .getIngresses ().remove (clusterName );
217
- if (oldIngress != null ) {
216
+ if (oldIngress != null && ! info . isDeleting () ) {
218
217
// Ingress was deleted, but sko still contained a non-null entry
219
218
LOGGER .info (
220
219
MessageKeys .INGRESS_DELETED , domainUID , metadata .getNamespace (), clusterName );
221
- makeRightDomainPresence (info , info .getDomain (), false , false , true );
220
+ makeRightDomainPresence (info , domainUID , info .getDomain (), false , false , true );
222
221
}
223
222
break ;
224
223
@@ -288,22 +287,30 @@ static void dispatchDomainWatch(Watch.Response<Domain> item) {
288
287
Domain d ;
289
288
String domainUID ;
290
289
DomainPresenceInfo existing ;
290
+ boolean added = false ;
291
291
switch (item .type ) {
292
292
case "ADDED" :
293
+ added = true ;
293
294
case "MODIFIED" :
294
295
d = item .object ;
295
296
domainUID = d .getSpec ().getDomainUID ();
296
297
LOGGER .info (MessageKeys .WATCH_DOMAIN , domainUID );
297
298
existing = DomainPresenceInfoManager .lookup (domainUID );
298
- makeRightDomainPresence (existing , d , false , false , true );
299
+ if (existing != null && added ) {
300
+ existing .setDeleting (false );
301
+ }
302
+ makeRightDomainPresence (existing , domainUID , d , added , false , true );
299
303
break ;
300
304
301
305
case "DELETED" :
302
306
d = item .object ;
303
307
domainUID = d .getSpec ().getDomainUID ();
304
308
LOGGER .info (MessageKeys .WATCH_DOMAIN_DELETED , domainUID );
305
309
existing = DomainPresenceInfoManager .lookup (domainUID );
306
- makeRightDomainPresence (existing , d , false , true , true );
310
+ if (existing != null ) {
311
+ existing .setDeleting (true );
312
+ }
313
+ makeRightDomainPresence (existing , domainUID , d , true , true , true );
307
314
break ;
308
315
309
316
case "ERROR" :
@@ -427,15 +434,22 @@ public void onThrowable(Packet packet, Throwable throwable) {
427
434
428
435
static void makeRightDomainPresence (
429
436
DomainPresenceInfo existing ,
437
+ String domainUID ,
430
438
Domain dom ,
431
439
boolean explicitRecheck ,
432
440
boolean isDeleting ,
433
441
boolean isWillInterrupt ) {
434
442
LOGGER .entering ();
435
443
436
- DomainSpec spec = dom .getSpec ();
437
- DomainPresenceControl .normalizeDomainSpec (spec );
438
- String domainUID = spec .getDomainUID ();
444
+ DomainSpec spec = null ;
445
+ String ns ;
446
+ if (dom != null ) {
447
+ spec = dom .getSpec ();
448
+ DomainPresenceControl .normalizeDomainSpec (spec );
449
+ ns = dom .getMetadata ().getNamespace ();
450
+ } else {
451
+ ns = existing .getNamespace ();
452
+ }
439
453
440
454
if (existing != null ) {
441
455
Domain current = existing .getDomain ();
@@ -446,7 +460,7 @@ static void makeRightDomainPresence(
446
460
return ;
447
461
}
448
462
// Has the spec actually changed? We will get watch events for status updates
449
- if (!explicitRecheck && spec .equals (current .getSpec ())) {
463
+ if (!explicitRecheck && spec != null && spec .equals (current .getSpec ())) {
450
464
// nothing in the spec has changed, but status likely did; update current
451
465
existing .setDomain (dom );
452
466
LOGGER .fine (MessageKeys .NOT_STARTING_DOMAINUID_THREAD , domainUID );
@@ -455,8 +469,7 @@ static void makeRightDomainPresence(
455
469
}
456
470
}
457
471
458
- internalMakeRightDomainPresence (
459
- existing , dom , domainUID , dom .getMetadata ().getNamespace (), isDeleting , isWillInterrupt );
472
+ internalMakeRightDomainPresence (existing , dom , domainUID , ns , isDeleting , isWillInterrupt );
460
473
}
461
474
462
475
private static void internalMakeRightDomainPresence (
@@ -469,7 +482,9 @@ private static void internalMakeRightDomainPresence(
469
482
if (isDeleting || !Main .isNamespaceStopping (ns ).get ()) {
470
483
LOGGER .info (MessageKeys .PROCESSING_DOMAIN , domainUID );
471
484
Step .StepAndPacket plan =
472
- isDeleting ? createDomainDownPlan (existing , ns , domainUID ) : createDomainUpPlan (dom , ns );
485
+ isDeleting || (existing != null && existing .isDeleting ())
486
+ ? createDomainDownPlan (existing , ns , domainUID )
487
+ : createDomainUpPlan (dom , ns );
473
488
474
489
runDomainPlan (dom , domainUID , plan , isDeleting , isWillInterrupt );
475
490
}
@@ -580,7 +595,7 @@ public NextAction apply(Packet packet) {
580
595
.getComponents ()
581
596
.put (
582
597
ProcessingConstants .DOMAIN_COMPONENT_NAME ,
583
- Component .createFor (info , Main .getVersion (), pw ));
598
+ Component .createFor (info , Main .getVersion (), PodAwaiterStepFactory . class , pw ));
584
599
packet .put (ProcessingConstants .PRINCIPAL , Main .getPrincipal ());
585
600
scheduleDomainStatusUpdating (info );
586
601
return doNext (packet );
@@ -604,7 +619,7 @@ public NextAction apply(Packet packet) {
604
619
.getComponents ()
605
620
.put (
606
621
ProcessingConstants .DOMAIN_COMPONENT_NAME ,
607
- Component .createFor (info , Main .getVersion (), pw ));
622
+ Component .createFor (info , Main .getVersion (), PodAwaiterStepFactory . class , pw ));
608
623
packet .put (ProcessingConstants .PRINCIPAL , Main .getPrincipal ());
609
624
return doNext (packet );
610
625
}
@@ -637,31 +652,4 @@ private static Step bringAdminServerUp(Domain dom, Step next) {
637
652
private static Step bringManagedServersUp (Step next ) {
638
653
return new ManagedServersUpStep (next );
639
654
}
640
-
641
- static void deleteStrandedResources () {
642
- for (Map .Entry <String , DomainPresenceInfo > entry :
643
- DomainPresenceInfoManager .getDomainPresenceInfos ().entrySet ()) {
644
- String domainUID = entry .getKey ();
645
- DomainPresenceInfo existing = entry .getValue ();
646
- if (existing != null ) {
647
- Domain current = existing .getDomain ();
648
- internalMakeRightDomainPresence (
649
- existing , current , domainUID , existing .getNamespace (), true , false );
650
- }
651
- }
652
- }
653
-
654
- static void deleteDomainPresence (Domain dom ) {
655
- String domainUID = dom .getSpec ().getDomainUID ();
656
- DomainPresenceInfo existing = DomainPresenceInfoManager .lookup (domainUID );
657
- Domain current = null ;
658
- if (existing != null ) {
659
- current = existing .getDomain ();
660
- if (current != null && isOutdatedWatchEvent (current .getMetadata (), dom .getMetadata ())) {
661
- return ;
662
- }
663
- }
664
- internalMakeRightDomainPresence (
665
- existing , current , domainUID , dom .getMetadata ().getNamespace (), true , true );
666
- }
667
655
}
0 commit comments