Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/domains/Cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"type": "string"
},
"introspectVersion": {
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. The introspectVersion value must be a valid label value in Kubernetes. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"type": "string"
},
"dataHome": {
Expand Down
2 changes: 1 addition & 1 deletion documentation/domains/Domain.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"type": "string"
},
"introspectVersion": {
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. The introspectVersion value must be a valid label value in Kubernetes. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"type": "string"
},
"dataHome": {
Expand Down
2 changes: 1 addition & 1 deletion documentation/domains/Domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The specification of the operation of the WebLogic domain. Required.
| `imagePullPolicy` | string | The image pull policy for the WebLogic Server image. Legal values are Always, Never, and IfNotPresent. Defaults to Always if image ends in :latest; IfNotPresent, otherwise. |
| `imagePullSecrets` | Array of [Local Object Reference](k8s1.13.5.md#local-object-reference) | A list of image pull Secrets for the WebLogic Server image. |
| `includeServerOutInPodLog` | Boolean | Specifies whether the server .out file will be included in the Pod's log. Defaults to true. |
| `introspectVersion` | string | Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. See also `domains.spec.configuration.overrideDistributionStrategy`. |
| `introspectVersion` | string | Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. The introspectVersion value must be a valid label value in Kubernetes. See also `domains.spec.configuration.overrideDistributionStrategy`. |
| `livenessProbeCustomScript` | string | Full path of an optional liveness probe custom script for WebLogic Server instance pods. The existing liveness probe script `livenessProbe.sh` will invoke this custom script after the existing script performs its own checks. This element is optional and is for advanced usage only. Its value is not set by default. If the custom script fails with non-zero exit status, then pod will fail the liveness probe and Kubernetes will restart the container. If the script specified by this element value is not found, then it is ignored. |
| `logHome` | string | The directory in a server's container in which to store the domain, Node Manager, server logs, server *.out, introspector .out, and optionally HTTP access log files if `httpAccessLogInLogHome` is true. Default is `/shared/logs/DOMAIN-UID`. Ignored if `logHomeEnabled` is false.See also `domains.spec.logHomeLayout`. |
| `logHomeEnabled` | Boolean | Specifies whether the log home folder is enabled. Defaults to true if `domainHomeSourceType` is PersistentVolume; false, otherwise. |
Expand Down
2 changes: 1 addition & 1 deletion documentation/domains/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@
"type": "string"
},
"introspectVersion": {
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"description": "Changes to this field cause the operator to repeat its introspection of the WebLogic domain configuration. Repeating introspection is required for the operator to recognize changes to the domain configuration, such as adding a new WebLogic cluster or Managed Server instance, to regenerate configuration overrides, or to regenerate the WebLogic domain home when the `domainHomeSourceType` is FromModel. Introspection occurs automatically, without requiring change to this field, when servers are first started or restarted after a full domain shut down. For the FromModel `domainHomeSourceType`, introspection also occurs when a running server must be restarted because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. The introspectVersion value must be a valid label value in Kubernetes. See also `domains.spec.configuration.overrideDistributionStrategy`.",
"type": "string"
},
"dataHome": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ void testDedicatedModeSameNamespaceScale() {
* Update the introspectVersion of the domain resource using lifecycle script.
* Refer to kubernetes/samples/scripts/domain-lifecycle/introspectDomain.sh
* The usecase update the introspectVersion by passing differnt value to -i
* option (non-numeic, non-numeric with space, no value) and make sure that
* option (non-numeic, non-numeric with underscore and dash, no value) and make sure that
* the introspectVersion is updated accrodingly in both domain sepc level
* and server pod level.
* It also verifies the intospector job is started/stoped and none of the
Expand Down Expand Up @@ -914,8 +914,8 @@ void testIntrospectDomainScript() {
verifyIntrospectVersionLabelInPod();

// use introspectDomain.sh to initiate introspection
logger.info("Initiate introspection with non numeric string with space");
introspectVersion = "My Version";
logger.info("Initiate introspection with non numeric string with underscore and dash");
introspectVersion = "My_Version-1";
String extraParam2 = " -i " + "\"" + introspectVersion + "\"";
assertDoesNotThrow(() -> executeLifecycleScript(INTROSPECT_DOMAIN_SCRIPT, extraParam2),
String.format("Failed to run %s", INTROSPECT_DOMAIN_SCRIPT));
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/crd/domain-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
weblogic.sha256: eb697282e8cf67ddf56fa6cc35cf7deb6c572ab1df40e4a4598eaedc1b57c7c3
weblogic.sha256: 9d0b4712b81ed3816329476fb3b035019bed06d60d095b82f2f92de1e417f083
name: domains.weblogic.oracle
spec:
group: weblogic.oracle
Expand Down Expand Up @@ -6688,6 +6688,7 @@ spec:
full domain shut down. For the FromModel `domainHomeSourceType`,
introspection also occurs when a running server must be restarted
because of changes to any of the fields listed here: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted.
The introspectVersion value must be a valid label value in Kubernetes.
See also `domains.spec.configuration.overrideDistributionStrategy`.'
type: string
dataHome:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ private String jobDescription(@Nonnull V1Job job) {
}

private boolean isInProgressJobOutdated(V1Job job) {
return hasNotCompleted(job) && hasAnyImageChanged(job);
return Optional.ofNullable(job)
.map(j -> hasNotCompleted(j) && (hasAnyImageChanged(j) || hasIntrospectVersionChanged(j)))
.orElse(false);
}

private boolean hasNotCompleted(V1Job job) {
Expand All @@ -265,6 +267,11 @@ private boolean hasAuxiliaryImageChanged(@Nonnull V1Job job) {
return ! getSortedJobModelPodSpecAuxiliaryImages().equals(getSortedAuxiliaryImagesFromJob(job));
}

private boolean hasIntrospectVersionChanged(@Nonnull V1Job job) {
return !Objects.equals(getIntrospectVersionLabelFromJob(job),
getIntrospectVersionLabelFromJob(getJobModel()));
}

String getImageFromJob(V1Job job) {
return getPodSpecFromJob(job).map(this::getImageFromPodSpec).orElse(null);
}
Expand Down Expand Up @@ -311,6 +318,15 @@ Stream<String> getJobModelPodSpecAuxiliaryImages() {
.orElse(Stream.empty());
}

@Nullable
String getIntrospectVersionLabelFromJob(V1Job job) {
return Optional.ofNullable(job)
.map(V1Job::getMetadata)
.map(V1ObjectMeta::getLabels)
.map(m -> m.get(INTROSPECTION_STATE_LABEL))
.orElse(null);
}

private boolean isKnownFailedJob(V1Job job) {
return getUid(job).equals(getLastFailedUid());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ private V1ObjectMeta createMetadata() {
new V1ObjectMeta()
.name(getJobName())
.namespace(getNamespace())
.putLabelsItem(LabelConstants.INTROSPECTION_STATE_LABEL, getIntrospectVersionLabel())
.putLabelsItem(LabelConstants.DOMAINUID_LABEL, getDomainUid())
.putLabelsItem(LabelConstants.CREATEDBYOPERATOR_LABEL, "true"));
}
Expand Down Expand Up @@ -664,6 +665,10 @@ private String getAsServiceName() {
return LegalNames.toServerServiceName(getDomainUid(), getAsName());
}

private String getIntrospectVersionLabel() {
return Optional.ofNullable(getDomain().getIntrospectVersion()).orElse(null);
}

@Override
List<V1EnvVar> getConfiguredEnvVars() {
// Pod for introspector job would use same environment variables as for admin server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ public class DomainSpec extends BaseConfiguration {
+ "server must be restarted because of changes to any of the fields listed here: "
+ "https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/"
+ "domain-lifecycle/startup/#properties-that-cause-servers-to-be-restarted. "
+ "The introspectVersion value must be a valid label value in Kubernetes. "
+ "See also `domains.spec.configuration.overrideDistributionStrategy`.")
private String introspectVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ private void definePreviousFailedIntrospectionWithoutPodLog() {
getDomain().getOrCreateStatus().setFailedIntrospectionUid(JOB_UID);
}

private void defineIntrospectionWithIntrospectVersionLabel(String introspectVersion) {
testSupport.defineResources(createIntrospectorJobWithIntrospectVersionLabel(introspectVersion));
}

@Test
void whenPreviousFailedJobExists_deleteIt() {
ignoreJobCreatedAndDeletedLogs();
Expand Down Expand Up @@ -989,6 +993,69 @@ void whenJobInProgressWithNonAuxImageInitContainer_doNotCreateNewJob() {
assertThat(affectedJob, nullValue());
}

@Test
void whenJobInProgressAndIntrospectVersionAdded_createNewJob() {
ignoreIntrospectorFailureLogs();
ignoreJobCreatedAndDeletedLogs();

getConfigurator().withIntrospectVersion("v2");

testSupport.addToPacket(DOMAIN_TOPOLOGY, createDomainConfig("cluster-1"));
defineIntrospection();
testSupport.doOnCreate(JOB, this::recordJob);

testSupport.runSteps(JobHelper.createIntrospectionStartStep(null));

assertThat(affectedJob, notNullValue());
}

@Test
void whenJobInProgressAndIntrospectVersionChanged_createNewJob() {
ignoreIntrospectorFailureLogs();
ignoreJobCreatedAndDeletedLogs();

getConfigurator().withIntrospectVersion("v2");

testSupport.addToPacket(DOMAIN_TOPOLOGY, createDomainConfig("cluster-1"));
defineIntrospectionWithIntrospectVersionLabel("v1");
testSupport.doOnCreate(JOB, this::recordJob);

testSupport.runSteps(JobHelper.createIntrospectionStartStep(null));

assertThat(affectedJob, notNullValue());
}

@Test
void whenJobInProgressAndIntrospectVersionUnchanged_doNotCreateNewJob() {
ignoreIntrospectorFailureLogs();
ignoreJobCreatedAndDeletedLogs();

getConfigurator().withIntrospectVersion("v2");

testSupport.addToPacket(DOMAIN_TOPOLOGY, createDomainConfig("cluster-1"));
defineIntrospectionWithIntrospectVersionLabel("v2");
testSupport.doOnCreate(JOB, this::recordJob);

testSupport.runSteps(JobHelper.createIntrospectionStartStep(null));

assertThat(affectedJob, nullValue());
}

@Test
void whenJobInProgressAndNullIntrospectVersionUnchanged_doNotCreateNewJob() {
ignoreIntrospectorFailureLogs();
ignoreJobCreatedAndDeletedLogs();

getConfigurator().withIntrospectVersion(null);

testSupport.addToPacket(DOMAIN_TOPOLOGY, createDomainConfig("cluster-1"));
defineIntrospectionWithIntrospectVersionLabel(null);
testSupport.doOnCreate(JOB, this::recordJob);

testSupport.runSteps(JobHelper.createIntrospectionStartStep(null));

assertThat(affectedJob, nullValue());
}

private void replaceFailedJobPodWithSuccess() {
testSupport.deleteResources(createIntrospectorJobPod());
Expand Down Expand Up @@ -1186,6 +1253,12 @@ private V1JobSpec createJobSpecWithImage(String image) {
return new V1JobSpec().template(podTemplateSpec);
}

private V1Job createIntrospectorJobWithIntrospectVersionLabel(String introspectVersion) {
V1Job job = createIntrospectorJob(UID);
job.getMetadata().putLabelsItem(LabelConstants.INTROSPECTION_STATE_LABEL, introspectVersion);
return job;
}

private V1ObjectMeta createJobMetadata(String uid) {
return new V1ObjectMeta().name(getJobName()).namespace(NS).creationTimestamp(SystemClock.now()).uid(uid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ private V1JobSpec createJobSpec() {
return JobHelper.createJobSpec(new Packet().with(domainPresenceInfo));
}

private V1Job createJob() {
return new JobStepContext(new Packet().with(domainPresenceInfo)).getJobModel();
}

@Test
void introspectorPodStartsWithDefaultUser_Mem_Args_environmentVariable() {
V1JobSpec jobSpec = createJobSpec();
Expand Down Expand Up @@ -1407,6 +1411,24 @@ void whenDomainIsIstioEnabled_istioLocalhostBindingsDisabledEnv_hasIstioUseLocal
);
}

@Test
void whenDomainHasIntrospectVersion_jobMetatadataCreatedWithLabel() {
final String INTROSPECT_VERSION = "v123";
configureDomain().withIntrospectVersion(INTROSPECT_VERSION);

V1Job job = createJob();
assertThat(job.getMetadata().getLabels().get(LabelConstants.INTROSPECTION_STATE_LABEL),
is(INTROSPECT_VERSION));
}

@Test
void whenDomainHasNoIntrospectVersion_jobMetatadataCreatedWithoutNoLabel() {
configureDomain().withIntrospectVersion(null);

V1Job job = createJob();
assertThat(job.getMetadata().getLabels().get(LabelConstants.INTROSPECTION_STATE_LABEL), is(nullValue()));
}

private V1Job job;

private void recordJob(V1Job job) {
Expand Down