Skip to content

Commit 90a2828

Browse files
committed
address review comments- update changes to runDomainPlan, set initial activeDeadlineSeconds for introspector job to 120s, and increment 1 minute for each subsequent retries
1 parent 0908cdc commit 90a2828

File tree

3 files changed

+51
-30
lines changed

3 files changed

+51
-30
lines changed

operator/src/main/java/oracle/kubernetes/operator/DomainProcessorImpl.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,7 @@ void runDomainPlan(
813813
new CompletionCallback() {
814814
@Override
815815
public void onCompletion(Packet packet) {
816-
DomainPresenceInfo existing = getExistingDomainPresenceInfo(ns, domainUID);
817-
if (existing != null) {
818-
existing.resetFailureCount();
819-
}
816+
// no-op
820817
}
821818

822819
@Override
@@ -840,29 +837,33 @@ public void onThrowable(Packet packet, Throwable throwable) {
840837
}
841838
});
842839

843-
DomainPresenceInfo existing = getExistingDomainPresenceInfo(ns, domainUID);
844-
if (existing != null) {
845-
int failureCount = existing.incrementAndGetFailureCount();
846-
LOGGER.fine(
847-
"Failure count for DomainPresenceInfo: " + existing + " is now: " + failureCount);
848-
if (failureCount > DomainPresence.getDomainPresenceFailureRetryMaxCount()) {
849-
LOGGER.warning(
850-
MessageKeys.CANNOT_START_DOMAIN_AFTER_MAX_RETRIES,
851-
domainUID,
852-
ns,
853-
DomainPresence.getDomainPresenceFailureRetryMaxCount(),
854-
throwable);
855-
} else {
856-
gate.getExecutor()
857-
.schedule(
858-
() -> {
859-
existing.setPopulated(false);
840+
gate.getExecutor()
841+
.schedule(
842+
() -> {
843+
DomainPresenceInfo existing = getExistingDomainPresenceInfo(ns, domainUID);
844+
if (existing != null) {
845+
existing.setPopulated(false);
846+
// proceed only if we have not already retried max number of times
847+
int retryCount = existing.incrementAndGetFailureCount();
848+
LOGGER.fine(
849+
"Failure count for DomainPresenceInfo: "
850+
+ existing
851+
+ " is now: "
852+
+ retryCount);
853+
if (retryCount <= DomainPresence.getDomainPresenceFailureRetryMaxCount()) {
860854
makeRightDomainPresence(existing, true, isDeleting, false);
861-
},
862-
DomainPresence.getDomainPresenceFailureRetrySeconds(),
863-
TimeUnit.SECONDS);
864-
}
865-
}
855+
} else {
856+
LOGGER.severe(
857+
MessageKeys.CANNOT_START_DOMAIN_AFTER_MAX_RETRIES,
858+
domainUID,
859+
ns,
860+
DomainPresence.getDomainPresenceFailureRetryMaxCount(),
861+
throwable);
862+
}
863+
}
864+
},
865+
DomainPresence.getDomainPresenceFailureRetrySeconds(),
866+
TimeUnit.SECONDS);
866867
}
867868
};
868869

operator/src/main/java/oracle/kubernetes/operator/helpers/DomainPresenceInfo.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class DomainPresenceInfo {
2929
private final AtomicReference<Domain> domain;
3030
private final AtomicBoolean isDeleting = new AtomicBoolean(false);
3131
private final AtomicBoolean isPopulated = new AtomicBoolean(false);
32-
private final AtomicInteger failureCount = new AtomicInteger(0);
32+
private final AtomicInteger retryCount = new AtomicInteger(0);
3333
private final AtomicReference<Collection<ServerStartupInfo>> serverStartupInfo;
3434

3535
private final ConcurrentMap<String, ServerKubernetesObjects> servers = new ConcurrentHashMap<>();
@@ -78,11 +78,15 @@ public void setPopulated(boolean populated) {
7878
}
7979

8080
public void resetFailureCount() {
81-
failureCount.set(0);
81+
retryCount.set(0);
8282
}
8383

8484
public int incrementAndGetFailureCount() {
85-
return failureCount.incrementAndGet();
85+
return retryCount.incrementAndGet();
86+
}
87+
88+
public int getRetryCount() {
89+
return retryCount.get();
8690
}
8791

8892
/**
@@ -97,6 +101,7 @@ public DateTime getLastCompletionTime() {
97101
/** Sets the last completion time to now */
98102
public void complete() {
99103
this.lastCompletionTime = new DateTime();
104+
resetFailureCount();
100105
}
101106

102107
/**

operator/src/main/java/oracle/kubernetes/operator/helpers/JobStepContext.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public abstract class JobStepContext implements StepContextConstants {
2121

2222
private final DomainPresenceInfo info;
2323
private V1Job jobModel;
24+
final long DEFAULT_ACTIVE_DEADLINE_SECONDS = 120L;
25+
final long DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS = 60L;
2426

2527
JobStepContext(Packet packet) {
2628
info = packet.getSPI(DomainPresenceInfo.class);
@@ -165,9 +167,22 @@ V1ObjectMeta createMetadata() {
165167
return metadata;
166168
}
167169

170+
private long getActiveDeadlineSeconds() {
171+
return DEFAULT_ACTIVE_DEADLINE_SECONDS
172+
+ (DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS * info.getRetryCount());
173+
}
174+
168175
protected V1JobSpec createJobSpec(TuningParameters tuningParameters) {
176+
LOGGER.fine(
177+
"Creating job "
178+
+ getJobName()
179+
+ " with activeDeadlineSeconds = "
180+
+ getActiveDeadlineSeconds());
169181
V1JobSpec jobSpec =
170-
new V1JobSpec().backoffLimit(0).template(createPodTemplateSpec(tuningParameters));
182+
new V1JobSpec()
183+
.backoffLimit(0)
184+
.activeDeadlineSeconds(getActiveDeadlineSeconds())
185+
.template(createPodTemplateSpec(tuningParameters));
171186

172187
return jobSpec;
173188
}

0 commit comments

Comments
 (0)