Skip to content

Commit 4a396b9

Browse files
authored
improve error message when WDT Operation UPDATE is used on image without a domain (#171)
1 parent 2cd6c01 commit 4a396b9

File tree

6 files changed

+36
-26
lines changed

6 files changed

+36
-26
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ boolean applyingPatches() {
185185
*/
186186
boolean shouldUpdateOpatch() {
187187
if (skipOpatchUpdate) {
188-
logger.fine("OPatch update was skipped at user's request");
188+
logger.fine("IMG-0065");
189189
}
190190
return !skipOpatchUpdate;
191191
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/UpdateImage.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
1717
import com.oracle.weblogic.imagetool.cachestore.OPatchFile;
18-
import com.oracle.weblogic.imagetool.installer.FmwInstallerType;
1918
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
2019
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
2120
import com.oracle.weblogic.imagetool.util.Constants;
@@ -68,11 +67,17 @@ public CommandResponse call() throws Exception {
6867

6968
String oracleHome = baseImageProperties.getProperty("ORACLE_HOME", null);
7069
if (oracleHome == null) {
71-
return new CommandResponse(-1, "ORACLE_HOME env variable undefined in base image: " + fromImage);
70+
return new CommandResponse(-1, "IMG-0072", fromImage);
7271
}
7372
dockerfileOptions.setOracleHome(oracleHome);
74-
installerType = FmwInstallerType.valueOf(baseImageProperties.getProperty("WLS_TYPE",
75-
FmwInstallerType.WLS.toString()).toUpperCase());
73+
74+
if (wdtOptions.isUsingWdt()) {
75+
String domainHome = baseImageProperties.getProperty("DOMAIN_HOME", null);
76+
if (domainHome == null && wdtOperation == WdtOperation.UPDATE) {
77+
return new CommandResponse(-1, "IMG-0071", fromImage);
78+
}
79+
}
80+
7681
installerVersion = baseImageProperties.getProperty("WLS_VERSION", Constants.DEFAULT_WLS_VERSION);
7782

7883
String opatchVersion = baseImageProperties.getProperty("OPATCH_VERSION");
@@ -174,8 +179,6 @@ String getInstallerVersion() {
174179

175180
private String installerVersion;
176181

177-
private FmwInstallerType installerType;
178-
179182
@Option(
180183
names = {"--fromImage"},
181184
description = "Docker image to use as base image.",

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/WdtOptions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ public class WdtOptions {
2626

2727
private static final LoggingFacade logger = LoggingFactory.getLogger(WdtOptions.class);
2828

29+
/**
30+
* Return true if the user specified a WDT model or WDT archive on the command line.
31+
* @return true if WDT was selected by the user
32+
*/
33+
boolean isUsingWdt() {
34+
return wdtModelPath != null || wdtArchivePath != null;
35+
}
36+
2937
/**
3038
* Checks whether the user requested a domain to be created with WDT.
3139
* If so, creates required file links to pass the model, archive, variables file to build process.

imagetool/src/main/resources/ImageTool.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,5 @@ IMG-0067=Finding patch number for latest PSU along with all its recommended patc
6969
IMG-0068=Adding patch number {0} to the recommended patches list
7070
IMG-0069=No recommended patches for {0}, version {1}
7171
IMG-0070=Failed to find latest patches for {0}, version {1}
72+
IMG-0071=WDT Operation is set to UPDATE, but the DOMAIN_HOME environment variable was not defined in the base image, {0}. Did you mean to use "--wdtOperation CREATE" to create a new domain?
73+
IMG-0072=ORACLE_HOME environment variable is not defined in the base image: {0}

imagetool/src/main/resources/probe-env/test-create-env.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ if [[ -f /etc/os-release ]]; then
1010
cat /etc/os-release | grep -oE '^VERSION_ID=[\"]?[[:digit:]\.]+[\"]?'
1111
fi
1212

13-
if [[ ! -z "$JAVA_HOME" ]]; then
13+
if [[ -n "$JAVA_HOME" ]]; then
1414
echo JAVA_HOME="$JAVA_HOME"
1515
fi
1616

17-
if [[ ! -z "$ORACLE_HOME" ]]; then
17+
if [[ -n "$ORACLE_HOME" ]]; then
1818
echo ORACLE_HOME="$ORACLE_HOME"
19-
WLS_TYPE=$(cat $ORACLE_HOME/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
20-
if [[ ! -z "$WLS_TYPE" ]]; then
19+
WLS_TYPE=$(cat "$ORACLE_HOME"/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
20+
if [[ -n "$WLS_TYPE" ]]; then
2121
echo WLS_TYPE="$WLS_TYPE"
2222
fi
23-
if [[ ! -z "$JAVA_HOME" ]]; then
24-
echo WLS_VERSION=$($JAVA_HOME/bin/java -cp $ORACLE_HOME/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)
23+
if [[ -n "$JAVA_HOME" ]]; then
24+
echo WLS_VERSION="$("$JAVA_HOME"/bin/java -cp "$ORACLE_HOME"/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)"
2525
fi
2626
fi

imagetool/src/main/resources/probe-env/test-update-env.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,30 @@ if [[ -f /etc/os-release ]]; then
1010
cat /etc/os-release | grep -oE '^VERSION_ID=[\"]?[[:digit:]\.]+[\"]?'
1111
fi
1212

13-
if [[ ! -z "$JAVA_HOME" ]]; then
13+
if [[ -n "$JAVA_HOME" ]]; then
1414
echo JAVA_HOME="$JAVA_HOME"
1515
echo JAVA_PATH="$(readlink -f $JAVA_HOME)"
1616
echo ADMIN_PORT="${ADMIN_PORT}"
1717
echo MANAGED_SERVER_PORT="${MANAGED_SERVER_PORT}"
1818
fi
1919

20-
if [[ ! -z "$ORACLE_HOME" ]]; then
20+
if [[ -n "$ORACLE_HOME" ]]; then
2121
echo ORACLE_HOME="$ORACLE_HOME"
22-
WLS_TYPE=$(cat $ORACLE_HOME/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
23-
if [[ ! -z "$WLS_TYPE" ]]; then
22+
WLS_TYPE=$(cat "$ORACLE_HOME"/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
23+
if [[ -n "$WLS_TYPE" ]]; then
2424
echo WLS_TYPE="$WLS_TYPE"
2525
fi
26-
if [[ ! -z "$JAVA_HOME" ]]; then
27-
echo WLS_VERSION=$($JAVA_HOME/bin/java -cp $ORACLE_HOME/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)
26+
if [[ -n "$JAVA_HOME" ]]; then
27+
echo WLS_VERSION="$("$JAVA_HOME"/bin/java -cp $ORACLE_HOME/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)"
2828
fi
29-
echo OPATCH_VERSION=$($ORACLE_HOME/OPatch/opatch version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)')
30-
#LSINV_TEXT=$($ORACLE_HOME/OPatch/opatch lsinventory 2> /dev/null)
31-
$ORACLE_HOME/OPatch/opatch lsinventory > /tmp/lsout 2> /dev/null
29+
echo OPATCH_VERSION="$("$ORACLE_HOME"/OPatch/opatch version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)')"
30+
"$ORACLE_HOME"/OPatch/opatch lsinventory > /tmp/lsout 2> /dev/null
3231

3332
if [[ -f "/tmp/lsout" ]]; then
34-
#1echo "$LSINV_TEXT" > /tmp_scripts/opatch-lsinventory.txt 2> /dev/null
35-
#echo $LSINV_TEXT | base64 > /tmp/b64
36-
echo LSINV_TEXT=$(base64 /tmp/lsout)
33+
echo LSINV_TEXT="$(base64 /tmp/lsout)"
3734
fi
3835
fi
3936

40-
if [[ ! -z "$DOMAIN_HOME" ]]; then
37+
if [[ -n "$DOMAIN_HOME" ]]; then
4138
echo DOMAIN_HOME="$DOMAIN_HOME"
4239
fi

0 commit comments

Comments
 (0)