Skip to content

Commit 2c1f20a

Browse files
committed
add failBootOnSituationalError to domain spec
1 parent 620933c commit 2c1f20a

File tree

10 files changed

+73
-2
lines changed

10 files changed

+73
-2
lines changed

docs/domains/Domain.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@
270270
"description": "The in-pod name of the directory in which to store the domain, node manager, server logs, and server *.out files",
271271
"type": "string"
272272
},
273+
"failBootOnSituationalError": {
274+
"description": "If true (the default), the WebLogic server boot would fail if any errors occur when applying situational configuration files during server startup. If false, WebLogic server would start if there are errors in the situational configuration files, and some configuration overrides may not be applied.",
275+
"type": "boolean"
276+
},
273277
"includeServerOutInPodLog": {
274278
"description": "If true (the default), the server .out file will be included in the pod\u0027s stdout.",
275279
"type": "boolean"

docs/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ DomainSpec is a description of a domain.
2323
| `domainHome` | string | The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true |
2424
| `domainHomeInImage` | Boolean | True if this domain's home is defined in the docker image for the domain. Defaults to true. |
2525
| `domainUID` | string | Domain unique identifier. Must be unique across the Kubernetes cluster. Not required. Defaults to the value of metadata.name |
26+
| `failBootOnSituationalError` | Boolean | If true (the default), the WebLogic server boot would fail if any errors occur when applying situational configuration files during server startup. If false, WebLogic server would start if there are errors in the situational configuration files, and some configuration overrides may not be applied. |
2627
| `image` | string | The WebLogic Docker image; required when domainHomeInImage is true; otherwise, defaults to container-registry.oracle.com/middleware/weblogic:12.2.1.3. |
2728
| `imagePullPolicy` | string | The image pull policy for the WebLogic Docker image. Legal values are Always, Never and IfNotPresent. Defaults to Always if image ends in :latest, IfNotPresent otherwise. |
2829
| `imagePullSecrets` | array of [Local Object Reference](k8s1.13.5.md#local-object-reference) | A list of image pull secrets for the WebLogic Docker image. |

docs/domains/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,10 @@
11901190
"description": "The in-pod name of the directory in which to store the domain, node manager, server logs, and server *.out files",
11911191
"type": "string"
11921192
},
1193+
"failBootOnSituationalError": {
1194+
"description": "If true (the default), the WebLogic server boot would fail if any errors occur when applying situational configuration files during server startup. If false, WebLogic server would start if there are errors in the situational configuration files, and some configuration overrides may not be applied.",
1195+
"type": "boolean"
1196+
},
11931197
"includeServerOutInPodLog": {
11941198
"description": "If true (the default), the server .out file will be included in the pod\u0027s stdout.",
11951199
"type": "boolean"

model/src/main/java/oracle/kubernetes/operator/KubernetesConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface KubernetesConstants {
2626
String[] DOMAIN_ALTERNATE_VERSIONS = {"v2", "v3"};
2727

2828
boolean DEFAULT_INCLUDE_SERVER_OUT_IN_POD_LOG = true;
29+
boolean DEFAULT_FAIL_BOOT_ON_SITUATIONAL_ERROR = true;
2930

3031
String CONTAINER_NAME = "weblogic-server";
3132

model/src/main/java/oracle/kubernetes/weblogic/domain/model/Domain.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ public boolean isIncludeServerOutInPodLog() {
345345
return spec.getIncludeServerOutInPodLog();
346346
}
347347

348+
public boolean isFailBootOnSituationalError() {
349+
return spec.getFailBootOnSituationalError();
350+
}
351+
348352
public boolean isDomainHomeInImage() {
349353
return spec.isDomainHomeInImage();
350354
}

model/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainSpec.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ public class DomainSpec extends BaseConfiguration {
9999
@Description("If true (the default), the server .out file will be included in the pod's stdout.")
100100
private Boolean includeServerOutInPodLog;
101101

102+
/**
103+
* Whether to fail to WebLogic server boot if any situational configuration error occurs during
104+
* server startup. Default is true.
105+
*
106+
* @since 2.3.0
107+
*/
108+
@Description(
109+
"If true (the default), the WebLogic server boot would fail if any errors occur "
110+
+ " when applying situational configuration files during server startup."
111+
+ " If false, WebLogic server would start if there are errors in the"
112+
+ " situational configuration files, and some configuration overrides may"
113+
+ " not be applied.")
114+
private Boolean failBootOnSituationalError;
115+
102116
/**
103117
* The WebLogic Docker image.
104118
*
@@ -412,6 +426,21 @@ public DomainSpec withIncludeServerOutInPodLog(boolean includeServerOutInPodLog)
412426
return this;
413427
}
414428

429+
/**
430+
* @return whether to fail WebLogic server boot if any error occurs when applying situational
431+
* configuration files during server startup.
432+
* @since 2.3.0
433+
*/
434+
boolean getFailBootOnSituationalError() {
435+
return Optional.ofNullable(failBootOnSituationalError)
436+
.orElse(KubernetesConstants.DEFAULT_FAIL_BOOT_ON_SITUATIONAL_ERROR);
437+
}
438+
439+
public DomainSpec withFailBootOnSituationalError(boolean failBootOnSituationalError) {
440+
this.failBootOnSituationalError = failBootOnSituationalError;
441+
return this;
442+
}
443+
415444
/**
416445
* Returns true if this domain's home is defined in the default docker image for the domain.
417446
*
@@ -519,6 +548,7 @@ public String toString() {
519548
.append("logHome", logHome)
520549
.append("logHomeEnabled", logHomeEnabled)
521550
.append("includeServerOutInPodLog", includeServerOutInPodLog)
551+
.append("failBootOnSituationalError", failBootOnSituationalError)
522552
.append("configOverrides", configOverrides)
523553
.append("configOverrideSecrets", configOverrideSecrets);
524554

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ private String getIncludeServerOutInPodLog() {
207207
return Boolean.toString(getDomain().isIncludeServerOutInPodLog());
208208
}
209209

210+
private boolean getFailBootOnSituationalError() {
211+
return getDomain().isFailBootOnSituationalError();
212+
}
213+
210214
private List<V1ContainerPort> getContainerPorts() {
211215
if (scan != null) {
212216
List<V1ContainerPort> ports = new ArrayList<>();
@@ -814,6 +818,9 @@ void overrideContainerWeblogicEnvVars(List<V1EnvVar> vars) {
814818
addEnvVar(
815819
vars, "SERVICE_NAME", LegalNames.toServerServiceName(getDomainUID(), getServerName()));
816820
addEnvVar(vars, "AS_SERVICE_NAME", LegalNames.toServerServiceName(getDomainUID(), getAsName()));
821+
if (!getFailBootOnSituationalError()) {
822+
addEnvVar(vars, "FAIL_BOOT_ON_SITUATIONAL_ERROR", "false");
823+
}
817824
if (mockWLS()) {
818825
addEnvVar(vars, "MOCK_WLS", "true");
819826
}

operator/src/main/resources/scripts/startNodeManager.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
# ${DOMAIN_UID}/${SERVER_NAME}_nodemanager.out
2727
# Default:
2828
# Use LOG_HOME. If LOG_HOME not set, use NODEMGR_HOME.
29-
# ADMIN_PORT_SECURE = "true" if the admin protocol is secure. Default is false
29+
# ADMIN_PORT_SECURE = "true" if the admin protocol is secure. Default is false# FAIL_BOOT_ON_SITUATIONAL_ERROR = "true" if WebLogic server should fail to
30+
# boot if situational configuration related errors are
31+
# found. Default to "true" if unspecified.
3032
#
3133
# If SERVER_NAME is set, then this NM is for a WL Server and these must also be set:
3234
#
@@ -113,12 +115,14 @@ export NODEMGR_HOME=${NODEMGR_HOME}/${DOMAIN_UID}/${SERVER_NAME}
113115
createFolder ${NODEMGR_HOME}
114116

115117
NODEMGR_LOG_HOME=${NODEMGR_LOG_HOME:-${LOG_HOME:-${NODEMGR_HOME}/${DOMAIN_UID}}}
118+
FAIL_BOOT_ON_SITUATIONAL_ERROR=${FAIL_BOOT_ON_SITUATIONAL_ERROR:-true}
116119

117120
trace "Info: NODEMGR_HOME='${NODEMGR_HOME}'"
118121
trace "Info: LOG_HOME='${LOG_HOME}'"
119122
trace "Info: SERVER_NAME='${SERVER_NAME}'"
120123
trace "Info: DOMAIN_UID='${DOMAIN_UID}'"
121124
trace "Info: NODEMGR_LOG_HOME='${NODEMGR_LOG_HOME}'"
125+
trace "Info: FAIL_BOOT_ON_SITUATIONAL_ERROR='${FAIL_BOOT_ON_SITUATIONAL_ERROR}'"
122126

123127
createFolder ${NODEMGR_LOG_HOME}
124128

@@ -239,7 +243,7 @@ RestartInterval=3600
239243
NumberOfFilesLimited=true
240244
FileTimeSpan=24
241245
NMHostName=${SERVICE_NAME}
242-
Arguments=${USER_MEM_ARGS} -XX\\:+UnlockExperimentalVMOptions -XX\\:+UseCGroupMemoryLimitForHeap -Dweblogic.SituationalConfig.failBootOnError=true ${serverOutOption} ${JAVA_OPTIONS}
246+
Arguments=${USER_MEM_ARGS} -XX\\:+UnlockExperimentalVMOptions -XX\\:+UseCGroupMemoryLimitForHeap -Dweblogic.SituationalConfig.failBootOnError=${FAIL_BOOT_ON_SITUATIONAL_ERROR} ${serverOutOption} ${JAVA_OPTIONS}
243247
244248
EOF
245249

operator/src/main/resources/scripts/startServer.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ function waitForShutdownMarker() {
110110
# Wait forever. Kubernetes will monitor this pod via liveness and readyness probes.
111111
#
112112
trace "Wait indefinitely so that the Kubernetes pod does not exit and try to restart"
113+
logged=false
113114
while true; do
115+
if [ "$logged" != 'true' ] && grep -q "BEA-141335" ${SERVER_OUT_FILE} ; then
116+
trace "WebLogic server failed to start due to missing or invalid situational configuration files. Please check ${SERVER_OUT_FILE} for details"
117+
logged=true
118+
fi
114119
if [ -e /weblogic-operator/doShutdown ] ; then
115120
exit 0
116121
fi
@@ -137,6 +142,9 @@ function copySitCfg() {
137142
if [ $? = 0 ]; then
138143
for local_fname in ${src_dir}/${fil_prefix}*.xml ; do
139144
copyIfChanged $local_fname $tgt_dir/`basename ${local_fname/${fil_prefix}//}`
145+
trace "Printing contents of situational configuration file $local_fname:"
146+
file_content=`cat $local_fname`
147+
echo "$file_content"
140148
done
141149
fi
142150

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ public void whenPodCreated_withoutLogHomeSpecified_hasDefaultLogHomeEnvVariable(
473473
getCreatedPodSpecContainer().getEnv(), allOf(hasEnvVar("LOG_HOME", LOG_HOME + "/" + UID)));
474474
}
475475

476+
@Test
477+
public void whenPodCreated_withFalseFailBootOnSituationalError_hasEnvVariable() {
478+
domainPresenceInfo.getDomain().getSpec().withFailBootOnSituationalError(false);
479+
assertThat(
480+
getCreatedPodSpecContainer().getEnv(),
481+
allOf(hasEnvVar("FAIL_BOOT_ON_SITUATIONAL_ERROR", "false")));
482+
}
483+
476484
static Matcher<Iterable<? super V1EnvVar>> hasEnvVar(String name, String value) {
477485
return hasItem(new V1EnvVar().name(name).value(value));
478486
}

0 commit comments

Comments
 (0)