Skip to content

Commit 04ff5c0

Browse files
authored
Merge pull request #1204 from oracle/owls-74082
OWLS-74082 Configurable introspector job activeDeadlineSeconds using new tuning parameter
2 parents b51b3ec + f193867 commit 04ff5c0

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
@@ -31,7 +31,6 @@
3131
import oracle.kubernetes.weblogic.domain.model.Domain;
3232

3333
public abstract class JobStepContext extends StepContextBase {
34-
static final long DEFAULT_ACTIVE_DEADLINE_SECONDS = 120L;
3534
static final long DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS = 60L;
3635
private static final LoggingFacade LOGGER = LoggingFactory.getLogger("Operator", "Operator");
3736
private static final String WEBLOGIC_OPERATOR_SCRIPTS_INTROSPECT_DOMAIN_SH =
@@ -158,8 +157,8 @@ V1ObjectMeta createMetadata() {
158157
.putLabelsItem(LabelConstants.CREATEDBYOPERATOR_LABEL, "true");
159158
}
160159

161-
private long getActiveDeadlineSeconds() {
162-
return DEFAULT_ACTIVE_DEADLINE_SECONDS
160+
private long getActiveDeadlineSeconds(TuningParameters.PodTuning podTuning) {
161+
return podTuning.introspectorJobActiveDeadlineSeconds
163162
+ (DEFAULT_ACTIVE_DEADLINE_INCREMENT_SECONDS * info.getRetryCount());
164163
}
165164

@@ -168,11 +167,11 @@ V1JobSpec createJobSpec(TuningParameters tuningParameters) {
168167
"Creating job "
169168
+ getJobName()
170169
+ " with activeDeadlineSeconds = "
171-
+ getActiveDeadlineSeconds());
170+
+ getActiveDeadlineSeconds(tuningParameters.getPodTuning()));
172171

173172
return new V1JobSpec()
174173
.backoffLimit(0)
175-
.activeDeadlineSeconds(getActiveDeadlineSeconds())
174+
.activeDeadlineSeconds(getActiveDeadlineSeconds(tuningParameters.getPodTuning()))
176175
.template(createPodTemplateSpec(tuningParameters));
177176
}
178177

@@ -196,7 +195,7 @@ private V1ObjectMeta createPodTemplateMetadata() {
196195
private V1PodSpec createPodSpec(TuningParameters tuningParameters) {
197196
V1PodSpec podSpec =
198197
new V1PodSpec()
199-
.activeDeadlineSeconds(getActiveDeadlineSeconds())
198+
.activeDeadlineSeconds(getActiveDeadlineSeconds(tuningParameters.getPodTuning()))
200199
.restartPolicy("Never")
201200
.addContainersItem(createContainer(tuningParameters))
202201
.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)