29
29
import oracle .kubernetes .operator .DomainStatusUpdater ;
30
30
import oracle .kubernetes .operator .KubernetesConstants ;
31
31
import oracle .kubernetes .operator .LabelConstants ;
32
- import oracle .kubernetes .operator .PodWatcher ;
32
+ import oracle .kubernetes .operator .PodAwaiterStepFactory ;
33
33
import oracle .kubernetes .operator .ProcessingConstants ;
34
34
import oracle .kubernetes .operator .TuningParameters ;
35
35
import oracle .kubernetes .operator .TuningParameters .PodTuning ;
40
40
import oracle .kubernetes .operator .logging .MessageKeys ;
41
41
import oracle .kubernetes .operator .wlsconfig .WlsClusterConfig ;
42
42
import oracle .kubernetes .operator .wlsconfig .WlsServerConfig ;
43
- import oracle .kubernetes .operator .work .Container ;
43
+ import oracle .kubernetes .operator .work .Component ;
44
44
import oracle .kubernetes .operator .work .ContainerResolver ;
45
45
import oracle .kubernetes .operator .work .NextAction ;
46
46
import oracle .kubernetes .operator .work .Packet ;
@@ -75,12 +75,10 @@ public AdminPodStep(Step next) {
75
75
76
76
@ Override
77
77
public NextAction apply (Packet packet ) {
78
- Container c = ContainerResolver .getInstance ().getContainer ();
79
- CallBuilderFactory factory = c .getSPI (CallBuilderFactory .class );
80
- TuningParameters configMapHelper = c .getSPI (TuningParameters .class );
78
+ TuningParameters tuningParameters = TuningParameters .getInstance ();
81
79
82
80
// Compute the desired pod configuration for the admin server
83
- V1Pod adminPod = computeAdminPodConfig (configMapHelper , packet );
81
+ V1Pod adminPod = computeAdminPodConfig (tuningParameters , packet );
84
82
85
83
// Verify if Kubernetes api server has a matching Pod
86
84
// Create or replace, if necessary
@@ -99,8 +97,7 @@ public NextAction apply(Packet packet) {
99
97
100
98
// First, verify existing Pod
101
99
Step read =
102
- factory
103
- .create ()
100
+ new CallBuilder ()
104
101
.readPodAsync (
105
102
podName ,
106
103
namespace ,
@@ -120,8 +117,7 @@ public NextAction onSuccess(Packet packet, CallResponse<V1Pod> callResponse) {
120
117
info .getExplicitRestartAdmin ().set (false );
121
118
info .getExplicitRestartServers ().remove (asName );
122
119
Step create =
123
- factory
124
- .create ()
120
+ new CallBuilder ()
125
121
.createPodAsync (
126
122
namespace ,
127
123
adminPod ,
@@ -187,7 +183,7 @@ && validateCurrentPod(adminPod, result)) {
187
183
}
188
184
189
185
// Make this protected so that it can be unit tested
190
- protected V1Pod computeAdminPodConfig (TuningParameters configMapHelper , Packet packet ) {
186
+ protected V1Pod computeAdminPodConfig (TuningParameters tuningParameters , Packet packet ) {
191
187
DomainPresenceInfo info = packet .getSPI (DomainPresenceInfo .class );
192
188
193
189
Domain dom = info .getDomain ();
@@ -282,7 +278,7 @@ protected V1Pod computeAdminPodConfig(TuningParameters configMapHelper, Packet p
282
278
container .addCommandItem (spec .getAsName ());
283
279
container .addCommandItem (weblogicDomainName );
284
280
285
- PodTuning tuning = configMapHelper .getPodTuning ();
281
+ PodTuning tuning = tuningParameters .getPodTuning ();
286
282
287
283
V1Probe readinessProbe = new V1Probe ();
288
284
V1ExecAction readinessAction = new V1ExecAction ();
@@ -319,7 +315,7 @@ protected V1Pod computeAdminPodConfig(TuningParameters configMapHelper, Packet p
319
315
}
320
316
321
317
// Add internal-weblogic-operator-service certificate to Admin Server pod
322
- String internalOperatorCert = getInternalOperatorCertFile (configMapHelper , packet );
318
+ String internalOperatorCert = getInternalOperatorCertFile (tuningParameters , packet );
323
319
addEnvVar (container , INTERNAL_OPERATOR_CERT_ENV , internalOperatorCert );
324
320
325
321
// Override the weblogic domain and admin server related environment variables that
@@ -356,8 +352,8 @@ protected V1Pod computeAdminPodConfig(TuningParameters configMapHelper, Packet p
356
352
}
357
353
358
354
// Make it protected to so that it can be unit tested:
359
- protected String getInternalOperatorCertFile (TuningParameters configMapHelper , Packet packet ) {
360
- return configMapHelper .get (INTERNAL_OPERATOR_CERT_FILE );
355
+ protected String getInternalOperatorCertFile (TuningParameters tuningParameters , Packet packet ) {
356
+ return tuningParameters .get (INTERNAL_OPERATOR_CERT_FILE );
361
357
}
362
358
}
363
359
@@ -403,8 +399,7 @@ public NextAction apply(Packet packet) {
403
399
CallBuilderFactory factory =
404
400
ContainerResolver .getInstance ().getContainer ().getSPI (CallBuilderFactory .class );
405
401
Step delete =
406
- factory
407
- .create ()
402
+ new CallBuilder ()
408
403
.deletePodAsync (
409
404
podName ,
410
405
namespace ,
@@ -427,8 +422,7 @@ public NextAction onSuccess(
427
422
}
428
423
info .getExplicitRestartServers ().contains (serverName );
429
424
Step create =
430
- factory
431
- .create ()
425
+ new CallBuilder ()
432
426
.createPodAsync (
433
427
namespace ,
434
428
newPod ,
@@ -455,7 +449,7 @@ public NextAction onSuccess(
455
449
sko .getPod ().set (result );
456
450
}
457
451
458
- PodWatcher pw = packet . getSPI ( PodWatcher . class );
452
+ PodAwaiterStepFactory pw = getPodAwaiterStepFactory ( packet );
459
453
return doNext (pw .waitForReady (result , getNext ()), packet );
460
454
}
461
455
});
@@ -466,6 +460,18 @@ public NextAction onSuccess(
466
460
}
467
461
}
468
462
463
+ public static void addToPacket (Packet packet , PodAwaiterStepFactory pw ) {
464
+ packet
465
+ .getComponents ()
466
+ .put (
467
+ ProcessingConstants .PODWATCHER_COMPONENT_NAME ,
468
+ Component .createFor (PodAwaiterStepFactory .class , pw ));
469
+ }
470
+
471
+ static PodAwaiterStepFactory getPodAwaiterStepFactory (Packet packet ) {
472
+ return packet .getSPI (PodAwaiterStepFactory .class );
473
+ }
474
+
469
475
/**
470
476
* Factory for {@link Step} that creates managed server pod
471
477
*
@@ -554,12 +560,10 @@ public ManagedPodStep(Step next) {
554
560
555
561
@ Override
556
562
public NextAction apply (Packet packet ) {
557
- Container c = ContainerResolver .getInstance ().getContainer ();
558
- CallBuilderFactory factory = c .getSPI (CallBuilderFactory .class );
559
- TuningParameters configMapHelper = c .getSPI (TuningParameters .class );
563
+ TuningParameters tuningParameters = TuningParameters .getInstance ();
560
564
561
565
// Compute the desired pod configuration for the managed server
562
- V1Pod pod = computeManagedPodConfig (configMapHelper , packet );
566
+ V1Pod pod = computeManagedPodConfig (tuningParameters , packet );
563
567
564
568
// Verify if Kubernetes api server has a matching Pod
565
569
// Create or replace, if necessary
@@ -582,8 +586,7 @@ public NextAction apply(Packet packet) {
582
586
583
587
// First, verify there existing Pod
584
588
Step read =
585
- factory
586
- .create ()
589
+ new CallBuilder ()
587
590
.readPodAsync (
588
591
podName ,
589
592
namespace ,
@@ -609,8 +612,7 @@ public NextAction onSuccess(
609
612
if (result == null ) {
610
613
info .getExplicitRestartServers ().remove (weblogicServerName );
611
614
Step create =
612
- factory
613
- .create ()
615
+ new CallBuilder ()
614
616
.createPodAsync (
615
617
namespace ,
616
618
pod ,
@@ -699,7 +701,7 @@ public NextAction onSuccess(
699
701
}
700
702
701
703
// Make this protected so that it can be unit tested
702
- protected V1Pod computeManagedPodConfig (TuningParameters configMapHelper , Packet packet ) {
704
+ protected V1Pod computeManagedPodConfig (TuningParameters tuningParameters , Packet packet ) {
703
705
DomainPresenceInfo info = packet .getSPI (DomainPresenceInfo .class );
704
706
705
707
Domain dom = info .getDomain ();
@@ -807,7 +809,7 @@ protected V1Pod computeManagedPodConfig(TuningParameters configMapHelper, Packet
807
809
container .addCommandItem (spec .getAsName ());
808
810
container .addCommandItem (String .valueOf (spec .getAsPort ()));
809
811
810
- PodTuning tuning = configMapHelper .getPodTuning ();
812
+ PodTuning tuning = tuningParameters .getPodTuning ();
811
813
812
814
V1Probe readinessProbe = new V1Probe ();
813
815
V1ExecAction readinessAction = new V1ExecAction ();
@@ -900,6 +902,7 @@ private static void overrideContainerWeblogicEnvVars(
900
902
addEnvVar (container , "ADMIN_USERNAME" , null );
901
903
addEnvVar (container , "ADMIN_PASSWORD" , null );
902
904
905
+ if (envList == null ) return ;
903
906
// resolve tokens in externally specified env that refers to internal env via $(XXX)
904
907
for (V1EnvVar ev : envList ) {
905
908
String oldValue = ev .getValue ();
@@ -952,11 +955,8 @@ public NextAction apply(Packet packet) {
952
955
// Set pod to null so that watcher doesn't try to recreate pod
953
956
V1Pod oldPod = sko .getPod ().getAndSet (null );
954
957
if (oldPod != null ) {
955
- CallBuilderFactory factory =
956
- ContainerResolver .getInstance ().getContainer ().getSPI (CallBuilderFactory .class );
957
958
return doNext (
958
- factory
959
- .create ()
959
+ new CallBuilder ()
960
960
.deletePodAsync (
961
961
oldPod .getMetadata ().getName (),
962
962
namespace ,
0 commit comments