3
3
4
4
package oracle .kubernetes .operator .helpers ;
5
5
6
+ import java .time .OffsetDateTime ;
6
7
import java .util .ArrayList ;
7
8
import java .util .Collections ;
8
9
import java .util .List ;
50
51
import oracle .kubernetes .weblogic .domain .model .ManagedServer ;
51
52
import oracle .kubernetes .weblogic .domain .model .ServerEnvVars ;
52
53
54
+ import static java .time .temporal .ChronoUnit .SECONDS ;
53
55
import static oracle .kubernetes .operator .DomainSourceType .FromModel ;
54
56
import static oracle .kubernetes .operator .DomainStatusUpdater .INSPECTING_DOMAIN_PROGRESS_REASON ;
55
57
import static oracle .kubernetes .operator .DomainStatusUpdater .createProgressingStartedEventStep ;
@@ -96,7 +98,7 @@ private static boolean runIntrospector(Packet packet, DomainPresenceInfo info) {
96
98
LOGGER .fine ("isModelInImageUpdate: " + isModelInImageUpdate (packet , info ));
97
99
return topology == null
98
100
|| isBringingUpNewDomain (packet , info )
99
- || introspectionRequested (packet )
101
+ || isIntrospectionRequestedAndRemove (packet )
100
102
|| isModelInImageUpdate (packet , info )
101
103
|| isIntrospectVersionChanged (packet , info );
102
104
}
@@ -105,7 +107,7 @@ private static boolean isBringingUpNewDomain(Packet packet, DomainPresenceInfo i
105
107
return runningServersCount (info ) == 0 && creatingServers (info ) && isGenerationChanged (packet , info );
106
108
}
107
109
108
- private static boolean introspectionRequested (Packet packet ) {
110
+ private static boolean isIntrospectionRequestedAndRemove (Packet packet ) {
109
111
return packet .remove (ProcessingConstants .DOMAIN_INTROSPECT_REQUESTED ) != null ;
110
112
}
111
113
@@ -399,7 +401,7 @@ public NextAction apply(Packet packet) {
399
401
if (runIntrospector (packet , info )) {
400
402
JobStepContext context = new DomainIntrospectorJobStepContext (packet );
401
403
402
- packet .putIfAbsent (START_TIME , System . currentTimeMillis ());
404
+ packet .putIfAbsent (START_TIME , OffsetDateTime . now ());
403
405
404
406
return doNext (
405
407
Step .chain (
@@ -455,7 +457,7 @@ public NextAction onSuccess(Packet packet, CallResponse callResponse) {
455
457
456
458
if (job != null ) {
457
459
packet .putIfAbsent (START_TIME , Optional .ofNullable (job .getMetadata ())
458
- .map (m -> m .getCreationTimestamp ()).map ( t -> t . toInstant (). toEpochMilli ()). orElse ( 0L ));
460
+ .map (m -> m .getCreationTimestamp ()).orElse ( OffsetDateTime . now () ));
459
461
return doNext (Step .chain (
460
462
createProgressingStartedEventStep (info , INSPECTING_DOMAIN_PROGRESS_REASON , true , null ),
461
463
readDomainIntrospectorPodLogStep (null ),
@@ -465,7 +467,7 @@ public NextAction onSuccess(Packet packet, CallResponse callResponse) {
465
467
new DomainProcessorImpl .IntrospectionRequestStep (info ),
466
468
createDomainIntrospectorJobStep (getNext ())), packet );
467
469
} else {
468
- packet .putIfAbsent (START_TIME , System . currentTimeMillis ());
470
+ packet .putIfAbsent (START_TIME , OffsetDateTime . now ());
469
471
return doNext (Step .chain (
470
472
ConfigMapHelper .readExistingIntrospectorConfigMap (namespace , info .getDomainUid ()),
471
473
createDomainIntrospectorJobStep (getNext ())), packet );
@@ -543,7 +545,10 @@ public NextAction onSuccess(Packet packet, CallResponse<String> callResponse) {
543
545
}
544
546
//Introspector job is incomplete, update domain status and terminate processing
545
547
Step nextStep = null ;
546
- if (System .currentTimeMillis () > getJobLazyDeletionTime (domainIntrospectorJob )) {
548
+ int retryIntervalSeconds = TuningParameters .getInstance ().getMainTuning ().domainPresenceRecheckIntervalSeconds ;
549
+
550
+ if (OffsetDateTime .now ().isAfter (
551
+ getJobCreationTime (domainIntrospectorJob ).plus (retryIntervalSeconds , SECONDS ))) {
547
552
//Introspector job is incomplete and current time is greater than the lazy deletion time for the job,
548
553
//update the domain status and execute the next step
549
554
nextStep = getNext ();
@@ -560,11 +565,9 @@ public NextAction onSuccess(Packet packet, CallResponse<String> callResponse) {
560
565
return doNext (packet );
561
566
}
562
567
563
- private Long getJobLazyDeletionTime (V1Job domainIntrospectorJob ) {
564
- int retryIntervalSeconds = TuningParameters .getInstance ().getMainTuning ().domainPresenceRecheckIntervalSeconds ;
568
+ private OffsetDateTime getJobCreationTime (V1Job domainIntrospectorJob ) {
565
569
return Optional .ofNullable (domainIntrospectorJob .getMetadata ())
566
- .map (m -> m .getCreationTimestamp ()).map (t -> t .toInstant ().toEpochMilli ()).orElse (0L )
567
- + (retryIntervalSeconds * 1000L );
570
+ .map (m -> m .getCreationTimestamp ()).orElse (OffsetDateTime .now ());
568
571
}
569
572
570
573
private boolean isNotComplete (V1Job domainIntrospectorJob ) {
0 commit comments