Skip to content

Commit d183446

Browse files
author
Tom Barnes
committed
Issue 721: DOMAIN_HOME handling when domain resource 'domainHome' not set and 'domainHomeInImage' is 'true'.
1 parent 558f25e commit d183446

File tree

13 files changed

+103
-30
lines changed

13 files changed

+103
-30
lines changed

docs/domains/Domain.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
"type": "string"
225225
},
226226
"domainHome": {
227-
"description": "The folder for the Weblogic Domain. (Not required)Defaults to /shared/domains/domains/domainUID if domainHomeInImage is falseDefaults to /shared/domains/domain if domainHomeInImage is true",
227+
"description": "The folder for the Weblogic Domain. (Not required)Defaults to /shared/domains/domains/domainUID if domainHomeInImage is falseDefaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
228228
"type": "string"
229229
},
230230
"logHomeEnabled": {

docs/domains/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@
11441144
"type": "string"
11451145
},
11461146
"domainHome": {
1147-
"description": "The folder for the Weblogic Domain. (Not required)Defaults to /shared/domains/domains/domainUID if domainHomeInImage is falseDefaults to /shared/domains/domain if domainHomeInImage is true",
1147+
"description": "The folder for the Weblogic Domain. (Not required)Defaults to /shared/domains/domains/domainUID if domainHomeInImage is falseDefaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
11481148
"type": "string"
11491149
},
11501150
"logHomeEnabled": {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

@@ -321,13 +321,13 @@ public boolean isDomainHomeInImage() {
321321
/**
322322
* Returns the domain home
323323
*
324-
* <p>Defaults to either /shared/domain/ or /shared/domains/domainUID
324+
* <p>Defaults to either /u01/oracle/user_projects/domains or /shared/domains/domainUID
325325
*
326326
* @return domain home
327327
*/
328328
public String getDomainHome() {
329329
if (spec.getDomainHome() != null) return spec.getDomainHome();
330-
if (spec.isDomainHomeInImage()) return "/shared/domain";
330+
if (spec.isDomainHomeInImage()) return "/u01/oracle/user_projects/domains";
331331
return "/shared/domains/" + getDomainUID();
332332
}
333333

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

@@ -41,7 +41,7 @@ public class DomainSpec extends BaseConfiguration {
4141
@Description(
4242
"The folder for the Weblogic Domain. (Not required)"
4343
+ "Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false"
44-
+ "Defaults to /shared/domains/domain if domainHomeInImage is true")
44+
+ "Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true")
4545
private String domainHome;
4646

4747
/**

model/src/test/java/oracle/kubernetes/weblogic/domain/v2/DomainV2Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

@@ -1207,7 +1207,7 @@ public void domainHomeTest_standardHome2() {
12071207
public void domainHomeTest_standardHome3() {
12081208
configureDomain(domain).withDomainHomeInImage(true);
12091209

1210-
assertThat(domain.getDomainHome(), equalTo("/shared/domain"));
1210+
assertThat(domain.getDomainHome(), equalTo("/u01/oracle/user_projects/domains"));
12111211
}
12121212

12131213
@Test

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
33
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
44

55
#
@@ -74,6 +74,10 @@ for dir_var in DOMAIN_HOME JAVA_HOME WL_HOME MW_HOME; do
7474
[ ! -d "${!dir_var}" ] && trace "Error: missing ${dir_var} directory '${!dir_var}'." && exit 1
7575
done
7676

77+
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed
78+
79+
exportEffectiveDomainHome || exit 1
80+
7781
# start node manager
7882

7983
trace "Starting node manager"
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
#!/bin/bash
22

3-
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at
55
# http://oss.oracle.com/licenses/upl.
66

77
# Kubernetes periodically calls this liveness probe script to determine whether
88
# the pod should be restarted. The script checks a WebLogic Server state file which
99
# is updated by the node manager.
1010

11+
# if the livenessProbeSuccessOverride file is available, treat failures as success:
12+
RETVAL=$(test -f /weblogic-operator/debug/livenessProbeSuccessOverride ; echo $?)
13+
14+
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
15+
source ${SCRIPTPATH}/traceUtils.sh
16+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit $RETVAL
17+
18+
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
19+
exportEffectiveDomainHome || exit $RETVAL
20+
1121
DN=${DOMAIN_NAME?}
1222
SN=${SERVER_NAME?}
1323
DH=${DOMAIN_HOME?}
1424

1525
STATEFILE=${DH}/servers/${SN}/data/nodemanager/${SN}.state
1626

17-
# if the livenessProbeSuccessOverride file is available, treat failures as success
18-
#
19-
RETVAL=$(test -f /weblogic-operator/debug/livenessProbeSuccessOverride ; echo $?)
20-
2127
if [ "${MOCK_WLS}" != 'true' ]; then
2228
if [ `jps -l | grep -c " weblogic.NodeManager"` -eq 0 ]; then
23-
echo "Error: WebLogic NodeManager process not found."
29+
trace "Error: WebLogic NodeManager process not found."
2430
exit $RETVAL
2531
fi
2632
fi
2733
if [ -f ${STATEFILE} ] && [ `grep -c "FAILED_NOT_RESTARTABLE" ${STATEFILE}` -eq 1 ]; then
28-
echo "Error: WebLogic Server state is FAILED_NOT_RESTARTABLE."
34+
trace "Error: WebLogic Server state is FAILED_NOT_RESTARTABLE."
2935
exit $RETVAL
3036
fi
3137
exit 0

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
#!/bin/bash
22

3-
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at
55
# http://oss.oracle.com/licenses/upl.
66

77
# Reads the current state of a server. The script checks a WebLogic Server state
88
# file which is updated by the node manager.
99

10+
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
11+
source ${SCRIPTPATH}/traceUtils.sh
12+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
13+
14+
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
15+
exportEffectiveDomainHome || exit 1
16+
1017
DN=${DOMAIN_NAME?}
1118
SN=${SERVER_NAME?}
1219
DH=${DOMAIN_HOME?}
1320

1421
STATEFILE=/${DH}/servers/${SN}/data/nodemanager/${SN}.state
1522

1623
if [ `jps -l | grep -c " weblogic.NodeManager"` -eq 0 ]; then
17-
echo "Error: WebLogic NodeManager process not found."
24+
trace "Error: WebLogic NodeManager process not found."
1825
exit 1
1926
fi
2027

2128
if [ ! -f ${STATEFILE} ]; then
22-
echo "Error: WebLogic Server state file not found."
29+
trace "Error: WebLogic Server state file not found."
2330
exit 2
2431
fi
2532

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
44
# Licensed under the Universal Permissive License v 1.0 as shown at
55
# http://oss.oracle.com/licenses/upl.
66

@@ -174,6 +174,11 @@ trace "SERVER_OUT_IN_POD_LOG=${SERVER_OUT_IN_POD_LOG}"
174174
trace "USER_MEM_ARGS=${USER_MEM_ARGS}"
175175
trace "JAVA_OPTIONS=${JAVA_OPTIONS}"
176176

177+
#
178+
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
179+
#
180+
exportEffectiveDomainHome || exitOrLoop
181+
177182
#
178183
# Check if introspector actually ran. This should never fail since
179184
# the operator shouldn't try run a wl pod if the introspector failed.

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
# Copyright 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
#
@@ -103,3 +103,54 @@ function checkEnv() {
103103
fi
104104
return 0
105105
}
106+
107+
108+
#
109+
# exportEffectiveDomainHome
110+
# 1) Look for a config.xml in DOMAIN_HOME/config and DOMAIN_HOME/*/config
111+
# 2) Export DOMAIN_HOME to reflect the actual location
112+
# 3) Trace an Error and return non-zero if not found or more than 1 found
113+
#
114+
function exportEffectiveDomainHome() {
115+
local count=0
116+
local cur_domain_home=""
117+
local eff_domain_home=""
118+
local found_configs=""
119+
120+
for cur_domain_home in "${DOMAIN_HOME?}" "${DOMAIN_HOME}"/*; do
121+
122+
config_path="${cur_domain_home}/config/config.xml"
123+
124+
if [ ! -f "${config_path}" ]; then
125+
continue
126+
fi
127+
128+
count=$((count + 1))
129+
130+
if [ $count -gt 1 ]; then
131+
found_configs="${found_configs}, '${config_path}'"
132+
continue
133+
fi
134+
135+
eff_domain_home="${cur_domain_home}"
136+
found_configs="'${config_path}'"
137+
if [ "${cur_domain_home}" = "${DOMAIN_HOME}" ]; then
138+
# when a config.xml is found right away at ${DOMAIN_HOME}/config
139+
# then don't bother looking a level deeper in "${DOMAIN_HOME}"/*/config
140+
break
141+
fi
142+
done
143+
144+
if [ $count -eq 1 ]; then
145+
export DOMAIN_HOME="${eff_domain_home}"
146+
return 0
147+
fi
148+
149+
if [ $count -eq 0 ]; then
150+
trace "Error: No config.xml found at DOMAIN_HOME/config/config.xml or DOMAIN_HOME/*/config/config.xml, DOMAIN_HOME='$DOMAIN_HOME'. Check your 'domainHome' setting in your WebLogic Operator Domain resource, and your pv/pvc mount location (if any)."
151+
return 1
152+
fi
153+
154+
trace "Error: More than one config.xml found at DOMAIN_HOME/config/config.xml and DOMAIN_HOME/*/config/config.xml, DOMAIN_HOME='$DOMAIN_HOME': ${found_configs}. Configure your 'domainHome' setting in your WebLogic Operator Domain resource to reference a single WebLogic domain."
155+
return 1
156+
}

0 commit comments

Comments
 (0)