Skip to content

Commit ca066ea

Browse files
committed
add introspectorJobActiveDeadlineSeconds tuning parameter
1 parent e63f614 commit ca066ea

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,23 @@ public static class PodTuning {
201201
public final int livenessProbeInitialDelaySeconds;
202202
public final int livenessProbeTimeoutSeconds;
203203
public final int livenessProbePeriodSeconds;
204+
public final long introspectorJobActiveDeadlineSeconds;
204205

205206
public PodTuning(
206207
int readinessProbeInitialDelaySeconds,
207208
int readinessProbeTimeoutSeconds,
208209
int readinessProbePeriodSeconds,
209210
int livenessProbeInitialDelaySeconds,
210211
int livenessProbeTimeoutSeconds,
211-
int livenessProbePeriodSeconds) {
212+
int livenessProbePeriodSeconds,
213+
long introspectorJobActiveDeadlineSeconds) {
212214
this.readinessProbeInitialDelaySeconds = readinessProbeInitialDelaySeconds;
213215
this.readinessProbeTimeoutSeconds = readinessProbeTimeoutSeconds;
214216
this.readinessProbePeriodSeconds = readinessProbePeriodSeconds;
215217
this.livenessProbeInitialDelaySeconds = livenessProbeInitialDelaySeconds;
216218
this.livenessProbeTimeoutSeconds = livenessProbeTimeoutSeconds;
217219
this.livenessProbePeriodSeconds = livenessProbePeriodSeconds;
220+
this.introspectorJobActiveDeadlineSeconds = introspectorJobActiveDeadlineSeconds;
218221
}
219222

220223
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ private void update() {
7777
(int) readTuningParameter("readinessProbePeriodSeconds", 5),
7878
(int) readTuningParameter("livenessProbeInitialDelaySeconds", 30),
7979
(int) readTuningParameter("livenessProbeTimeoutSeconds", 5),
80-
(int) readTuningParameter("livenessProbePeriodSeconds", 45));
80+
(int) readTuningParameter("livenessProbePeriodSeconds", 45),
81+
readTuningParameter("introspectorJobActiveDeadlineSeconds", 120));
8182

8283
lock.writeLock().lock();
8384
try {

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import oracle.kubernetes.weblogic.domain.model.Domain;
3333

3434
public abstract class JobStepContext extends StepContextBase {
35-
static final long DEFAULT_ACTIVE_DEADLINE_SECONDS = 120L;
3635
static final long DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS = 60L;
3736
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
3837
private static final String WEBLOGIC_OPERATOR_SCRIPTS_INTROSPECT_DOMAIN_SH =
@@ -175,8 +174,8 @@ V1ObjectMeta createMetadata() {
175174
.putLabelsItem(LabelConstants.CREATEDBYOPERATOR_LABEL, "true");
176175
}
177176

178-
private long getActiveDeadlineSeconds() {
179-
return DEFAULT_ACTIVE_DEADLINE_SECONDS
177+
private long getActiveDeadlineSeconds(TuningParameters.PodTuning podTuning) {
178+
return podTuning.introspectorJobActiveDeadlineSeconds
180179
+ (DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS * info.getRetryCount());
181180
}
182181

@@ -185,11 +184,11 @@ V1JobSpec createJobSpec(TuningParameters tuningParameters) {
185184
"Creating job "
186185
+ getJobName()
187186
+ " with activeDeadlineSeconds = "
188-
+ getActiveDeadlineSeconds());
187+
+ getActiveDeadlineSeconds(tuningParameters.getPodTuning()));
189188

190189
return new V1JobSpec()
191190
.backoffLimit(0)
192-
.activeDeadlineSeconds(getActiveDeadlineSeconds())
191+
.activeDeadlineSeconds(getActiveDeadlineSeconds(tuningParameters.getPodTuning()))
193192
.template(createPodTemplateSpec(tuningParameters));
194193
}
195194

@@ -213,7 +212,7 @@ private V1ObjectMeta createPodTemplateMetadata() {
213212
private V1PodSpec createPodSpec(TuningParameters tuningParameters) {
214213
V1PodSpec podSpec =
215214
new V1PodSpec()
216-
.activeDeadlineSeconds(getActiveDeadlineSeconds())
215+
.activeDeadlineSeconds(getActiveDeadlineSeconds(tuningParameters.getPodTuning()))
217216
.restartPolicy("Never")
218217
.addContainersItem(createContainer(tuningParameters))
219218
.addVolumesItem(new V1Volume().name(SECRETS_VOLUME).secret(getSecretsVolume()))

operator/src/test/java/oracle/kubernetes/operator/helpers/DomainIntrospectorJobTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void setUp() throws Exception {
8787
TestUtils.silenceOperatorLogger()
8888
.collectLogMessages(logRecords, getMessageKeys())
8989
.withLogLevel(Level.INFO));
90+
mementos.add(TuningParametersStub.install());
9091
mementos.add(testSupport.install());
9192
testSupport.addDomainPresenceInfo(domainPresenceInfo);
9293
}

operator/src/test/java/oracle/kubernetes/operator/helpers/JobHelperTest.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
package oracle.kubernetes.operator.helpers;
66

7+
import com.meterware.simplestub.Memento;
78
import java.lang.reflect.InvocationTargetException;
89
import java.lang.reflect.Method;
10+
import java.util.ArrayList;
911
import java.util.Collection;
1012
import java.util.Collections;
1113
import java.util.List;
@@ -33,6 +35,8 @@
3335
import oracle.kubernetes.weblogic.domain.model.DomainSpec;
3436
import org.hamcrest.Matcher;
3537
import org.hamcrest.junit.MatcherAssert;
38+
import org.junit.After;
39+
import org.junit.Before;
3640
import org.junit.Test;
3741

3842
import static org.hamcrest.CoreMatchers.equalTo;
@@ -49,11 +53,22 @@ public class JobHelperTest {
4953
private static final String END_VALUE_1 = "find uid1 at /u01/oracle/user_projects/domains";
5054
private Method getDomainSpec;
5155
private final DomainPresenceInfo domainPresenceInfo = createDomainPresenceInfo();
56+
protected List<Memento> mementos = new ArrayList<>();
5257

5358
private static Matcher<Iterable<? super V1EnvVar>> hasEnvVar(String name, String value) {
5459
return hasItem(new V1EnvVar().name(name).value(value));
5560
}
5661

62+
@Before
63+
public void setup() throws Exception {
64+
mementos.add(TuningParametersStub.install());
65+
}
66+
67+
@After
68+
public void tearDown() throws Exception {
69+
for (Memento memento : mementos) memento.revert();
70+
}
71+
5772
@Test
5873
public void creatingServers_true_whenClusterReplicas_gt_0() {
5974
configureCluster(domainPresenceInfo, "cluster1").withReplicas(1);
@@ -256,9 +271,9 @@ public void verify_introspectorPodSpec_activeDeadlineSeconds_initial_values() {
256271

257272
MatcherAssert.assertThat(
258273
jobSpec.getTemplate().getSpec().getActiveDeadlineSeconds(),
259-
is(JobStepContext.DEFAULT_ACTIVE_DEADLINE_SECONDS));
274+
is(TuningParametersStub.INTROSPECTOR_JOB_ACTIVE_DEADLINE_SECONDS));
260275
MatcherAssert.assertThat(
261-
jobSpec.getActiveDeadlineSeconds(), is(JobStepContext.DEFAULT_ACTIVE_DEADLINE_SECONDS));
276+
jobSpec.getActiveDeadlineSeconds(), is(TuningParametersStub.INTROSPECTOR_JOB_ACTIVE_DEADLINE_SECONDS));
262277
}
263278

264279
@Test
@@ -268,7 +283,7 @@ public void verify_introspectorPodSpec_activeDeadlineSeconds_retry_values() {
268283
V1JobSpec jobSpec = createJobSpec();
269284

270285
long expectedActiveDeadlineSeconds =
271-
JobStepContext.DEFAULT_ACTIVE_DEADLINE_SECONDS
286+
TuningParametersStub.INTROSPECTOR_JOB_ACTIVE_DEADLINE_SECONDS
272287
+ (failureCount * JobStepContext.DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS);
273288
MatcherAssert.assertThat(
274289
jobSpec.getTemplate().getSpec().getActiveDeadlineSeconds(),

operator/src/test/java/oracle/kubernetes/operator/helpers/TuningParametersStub.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class TuningParametersStub implements TuningParameters {
2121
static final int LIVENESS_INITIAL_DELAY = 4;
2222
static final int LIVENESS_PERIOD = 6;
2323
static final int LIVENESS_TIMEOUT = 5;
24+
static final long INTROSPECTOR_JOB_ACTIVE_DEADLINE_SECONDS = 180L;
2425
static Map<String, String> namedParameters;
2526

2627
public static Memento install() throws NoSuchFieldException {
@@ -37,7 +38,8 @@ public PodTuning getPodTuning() {
3738
READINESS_PERIOD,
3839
LIVENESS_INITIAL_DELAY,
3940
LIVENESS_TIMEOUT,
40-
LIVENESS_PERIOD);
41+
LIVENESS_PERIOD,
42+
INTROSPECTOR_JOB_ACTIVE_DEADLINE_SECONDS);
4143
}
4244

4345
@Override

0 commit comments

Comments
 (0)