Skip to content

Commit 2a7fe64

Browse files
authored
temporary fix for OPatch bug version and metadata change (#130)
* temporary fix for OPatch bug version and metadata change * changed IT test to use newer OPatch installer * fixed Update operation to use new/correct OPatch version * changed IT test to use newer OPatch installer * treat opatch patches as any other patch * use ENV for password resolution * delete OPatch patch from cache in IntegrationTest before adding
1 parent 1b286e3 commit 2a7fe64

File tree

8 files changed

+41
-32
lines changed

8 files changed

+41
-32
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/CachedPatchFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String resolve(CacheStore cacheStore) throws IOException {
4949
if (fileExists) {
5050
logger.info("IMG-0017", patchId, filePath);
5151
} else {
52-
logger.fine("Could not find patch in cache patchId={2} version={1} ", patchId, version);
52+
logger.fine("Could not find patch in cache patchId={0} version={1} ", patchId, version);
5353

5454
if (userId == null || password == null) {
5555
throw new FileNotFoundException(String.format(

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/cache/AddPatchEntry.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
import java.util.List;
1010

1111
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
12-
import com.oracle.weblogic.imagetool.cachestore.CacheStore;
1312
import com.oracle.weblogic.imagetool.installer.FmwInstallerType;
1413
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
1514
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
16-
import com.oracle.weblogic.imagetool.util.Constants;
1715
import com.oracle.weblogic.imagetool.util.Utils;
1816
import picocli.CommandLine.Command;
1917
import picocli.CommandLine.Option;
@@ -67,11 +65,11 @@ private CommandResponse addToCache(String patchNumber) {
6765
String key = patchNumber;
6866

6967
// Check if it is an Opatch patch
70-
String opatchNumber = Utils.getOpatchVersionFromZip(location.toAbsolutePath().toString());
71-
if (opatchNumber != null) {
72-
int lastSeparator = key.lastIndexOf(CacheStore.CACHE_KEY_SEPARATOR);
73-
key = key.substring(0, lastSeparator) + CacheStore.CACHE_KEY_SEPARATOR + Constants.OPATCH_PATCH_TYPE;
74-
}
68+
//String opatchNumber = Utils.getOpatchVersionFromZip(location.toAbsolutePath().toString());
69+
//if (opatchNumber != null) {
70+
// int lastSeparator = key.lastIndexOf(CacheStore.CACHE_KEY_SEPARATOR);
71+
// key = key.substring(0, lastSeparator) + CacheStore.CACHE_KEY_SEPARATOR + Constants.OPATCH_PATCH_TYPE;
72+
//}
7573
logger.info("adding key " + key);
7674
if (cacheStore.getValueFromCache(key) != null) {
7775
String error = String.format("Cache key %s already exists, remove it first", key);

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
@@ -403,7 +403,7 @@ String getPassword() {
403403
names = {"--opatchBugNumber"},
404404
description = "the patch number for OPatch (patching OPatch)"
405405
)
406-
String opatchBugNumber = "28186730";
406+
String opatchBugNumber = "28186730_13.9.4.2.2";
407407

408408
@Unmatched
409409
List<String> unmatchedOptions;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public CommandResponse call() throws Exception {
8383
String opatchBugNumberVersion;
8484

8585
if (userId == null && password == null) {
86-
String opatchFile = cacheStore.getValueFromCache(opatchBugNumber + "_opatch");
86+
String opatchFile = cacheStore.getValueFromCache(opatchBugNumber);
8787
if (opatchFile != null) {
8888
opatchBugNumberVersion = Utils.getOpatchVersionFromZip(opatchFile);
8989
logger.info("IMG-0008", opatchBugNumber, opatchFile, opatchBugNumberVersion);

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/ARUUtil.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,17 @@ private static void checkForMultiplePatches(String bugNumber, String userId, Str
319319
if (nodeList.getLength() > 1 && ind < 0) {
320320
// only base number is specified and there are multiple patches
321321
// ERROR
322-
logger.warning(Utils.getMessage("IMG-0034", baseBugNumber));
322+
List<String> patchVersions = new ArrayList<>();
323323
for (int i = 1; i <= nodeList.getLength(); i++) {
324324
String xpath = String.format("string(/results/patch[%d]/release/@name)", i);
325325
String releaseNumber = XPathUtil.applyXPathReturnString(allPatches, xpath);
326-
logger.warning(bugNumber + "_" + releaseNumber);
326+
patchVersions.add(bugNumber + "_" + releaseNumber);
327327
}
328-
throw new IOException(Utils.getMessage("IMG-0035"));
328+
329+
IOException ioe = new IOException(Utils.getMessage("IMG-0034", baseBugNumber,
330+
String.join(", ", patchVersions)));
331+
logger.throwing(ioe);
332+
throw ioe;
329333
}
330334

331335
} catch (XPathExpressionException xpe) {
@@ -354,15 +358,16 @@ private static String savePatch(Document allPatches, String userId, String passw
354358
if (nodeList.getLength() > 1 && ind < 0) {
355359
// only base number is specified and there are multiple patches
356360
// ERROR
357-
String message = String.format("There are multiple patches found with id %s, please specify "
358-
+ "the format as one of the following for the release you want", baseBugNumber);
359-
logger.warning(message);
361+
List<String> patchVersions = new ArrayList<>();
360362
for (int i = 1; i <= nodeList.getLength(); i++) {
361363
String xpath = String.format("string(/results/patch[%d]/release/@name)", i);
362364
String releaseNumber = XPathUtil.applyXPathReturnString(allPatches, xpath);
363-
logger.warning(bugNumber + "_" + releaseNumber);
365+
patchVersions.add(bugNumber + "_" + releaseNumber);
364366
}
365-
throw new IOException("Multiple patches with same patch number detected");
367+
IOException ioe = new IOException(Utils.getMessage("IMG-0034", baseBugNumber,
368+
String.join(", ", patchVersions)));
369+
logger.throwing(ioe);
370+
throw ioe;
366371
}
367372
if (optionalRelease != null) {
368373
// TODO: do we need this ?

imagetool/src/main/resources/ImageTool.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ IMG-0030=Additional build command file does not exist: {0}
3232
IMG-0031=No credentials provided. Cannot determine latestPSU
3333
IMG-0032=Failed to find latest PSU for {0}, version {1}
3434
IMG-0033=No credentials provided, skipping validation of patches
35-
IMG-0034=There are multiple patches found with id {0}, please specify the format as one of the following for the release you want
35+
IMG-0034=Patch ID {0} has multiple versions, please retry the command using one of the available patch versions: {1}
3636
IMG-0035=Multiple patches with the same patch number detected
3737
IMG-0036=Unable to find installer inventory file: {0}
3838
IMG-0037=Failed to find patch {0} for version {1}

imagetool/src/main/resources/docker-files/Update_Image.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ LABEL com.oracle.weblogic.imagetool.buildid="{{buildId}}"
9393
USER {{userid}}
9494

9595
{{#isOpatchPatchingEnabled}}
96-
COPY --chown=oracle:oracle p28186730_139400_Generic.zip {{{tempDir}}}/opatch/
96+
COPY --chown=oracle:oracle {{{opatchFileName}}} {{{tempDir}}}/opatch/
9797
RUN cd {{{tempDir}}}/opatch \
98-
&& $JAVA_HOME/bin/jar -xf {{{tempDir}}}/opatch/p28186730_139400_Generic.zip \
99-
&& $JAVA_HOME/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home=$ORACLE_HOME \
98+
&& {{{java_home}}}/bin/jar -xf {{{tempDir}}}/opatch/{{{opatchFileName}}} \
99+
&& {{{java_home}}}/bin/java -jar {{{tempDir}}}/opatch/6880880/opatch_generic.jar -silent -ignoreSysPrereqs -force -novalidation oracle_home={{{oracle_home}}} \
100100
&& rm -rf {{{tempDir}}}
101101
{{/isOpatchPatchingEnabled}}
102102

103103
{{#isPatchingEnabled}}
104104
COPY --chown={{userid}}:{{groupid}} patches/* {{{tempDir}}}/patches/
105105

106-
RUN $ORACLE_HOME/OPatch/opatch napply -silent -oh $ORACLE_HOME -phBaseDir {{{tempDir}}}/patches \
107-
&& $ORACLE_HOME/OPatch/opatch util cleanup -silent -oh $ORACLE_HOME \
106+
RUN {{{oracle_home}}}/OPatch/opatch napply -silent -oh {{{oracle_home}}} -phBaseDir {{{tempDir}}}/patches \
107+
&& {{{oracle_home}}}/OPatch/opatch util cleanup -silent -oh {{{oracle_home}}} \
108108
&& rm -rf {{{tempDir}}}
109109
{{/isPatchingEnabled}}
110110

imagetool/src/test/java/com/oracle/weblogic/imagetool/integration/ITImagetool.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ITImagetool extends BaseTest {
2323
private static final String JDK_INSTALLER_8u212 = "jdk-8u212-linux-x64.tar.gz";
2424
private static final String WLS_INSTALLER = "fmw_12.2.1.3.0_wls_Disk1_1of1.zip";
2525
private static final String P27342434_INSTALLER = "p27342434_122130_Generic.zip";
26-
private static final String P28186730_INSTALLER = "p28186730_139400_Generic.zip";
26+
private static final String P28186730_INSTALLER = "p28186730_139422_Generic.zip";
2727
private static final String P22987840_INSTALLER = "p22987840_122100_Generic.zip";
2828
private static final String WDT_INSTALLER = "weblogic-deploy.zip";
2929
private static final String FMW_INSTALLER = "fmw_12.2.1.3.0_infrastructure_Disk1_1of1.zip";
@@ -34,7 +34,7 @@ public class ITImagetool extends BaseTest {
3434
private static final String P22987840_ID = "22987840";
3535
private static final String WLS_VERSION = "12.2.1.3.0";
3636
private static final String WLS_VERSION_1221 = "12.2.1.0.0";
37-
private static final String OPATCH_VERSION = "13.9.4.0.0";
37+
private static final String OPATCH_VERSION = "13.9.4.2.2";
3838
private static final String JDK_VERSION = "8u202";
3939
private static final String JDK_VERSION_8u212 = "8u212";
4040
private static final String WDT_VERSION = "1.1.2";
@@ -43,7 +43,6 @@ public class ITImagetool extends BaseTest {
4343
private static final String WDT_MODEL = "simple-topology.yaml";
4444
private static final String WDT_MODEL2 = "simple-topology2.yaml";
4545
private static String oracleSupportUsername;
46-
private static String oracleSupportPassword;
4746

4847
@BeforeClass
4948
public static void staticPrepare() throws Exception {
@@ -65,7 +64,7 @@ public static void staticPrepare() throws Exception {
6564

6665
// get Oracle support credentials
6766
oracleSupportUsername = System.getenv("ORACLE_SUPPORT_USERNAME");
68-
oracleSupportPassword = System.getenv("ORACLE_SUPPORT_PASSWORD");
67+
String oracleSupportPassword = System.getenv("ORACLE_SUPPORT_PASSWORD");
6968
if (oracleSupportUsername == null || oracleSupportPassword == null) {
7069
throw new Exception("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD"
7170
+ " for Oracle Support credentials to download the patches.");
@@ -238,8 +237,11 @@ public void test8CreateWLSImgUseCache() throws Exception {
238237

239238
// need to add the required patches 28186730 for Opatch before create wls images
240239
String patchPath = getInstallerCacheDir() + FS + P28186730_INSTALLER;
241-
deleteEntryFromCache(P28186730_ID + "_opatch");
240+
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
242241
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
242+
ExecResult resultT = listItemsInCache();
243+
System.out.println(resultT.stdout());
244+
System.out.println(resultT.stderr());
243245

244246
String command = imagetool + " create --jdkVersion " + JDK_VERSION + " --fromImage "
245247
+ BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag " + build_tag + ":" + testMethodName
@@ -264,6 +266,10 @@ public void test9UpdateWLSImg() throws Exception {
264266
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
265267
logTestBegin(testMethodName);
266268

269+
ExecResult resultT = listItemsInCache();
270+
System.out.println(resultT.stdout());
271+
System.out.println(resultT.stderr());
272+
267273
String command = imagetool + " update --fromImage " + build_tag + ":test8CreateWLSImgUseCache --tag "
268274
+ build_tag + ":" + testMethodName + " --patches " + P27342434_ID;
269275
logger.info("Executing command: " + command);
@@ -307,7 +313,7 @@ public void testACreateWLSImgUsingWDT() throws Exception {
307313

308314
// need to add the required patches 28186730 for Opatch before create wls images
309315
// delete the cache entry first
310-
deleteEntryFromCache(P28186730_ID + "_opatch");
316+
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
311317
String patchPath = getInstallerCacheDir() + FS + P28186730_INSTALLER;
312318
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
313319

@@ -512,7 +518,7 @@ public void testECreateRestricedJRFDomainImgUsingWDT() throws Exception {
512518
String command = imagetool + " create --fromImage "
513519
+ BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " --tag " + build_tag + ":" + testMethodName
514520
+ " --version " + WLS_VERSION + " --latestPSU --user " + oracleSupportUsername
515-
+ " --password " + oracleSupportPassword + " --wdtVersion " + WDT_VERSION
521+
+ " --passwordEnv ORACLE_SUPPORT_PASSWORD" + " --wdtVersion " + WDT_VERSION
516522
+ " --wdtArchive " + wdtArchive + " --wdtDomainHome /u01/domains/simple_domain --wdtModel "
517523
+ wdtModel + " --wdtDomainType RestrictedJRF --type fmw --wdtVariables " + wdtVariables;
518524

@@ -556,7 +562,7 @@ public void testFCreateWLSImgUsingMultiModels() throws Exception {
556562

557563
// need to add the required patches 28186730 for Opatch before create wls images
558564
// delete the cache entry first
559-
deleteEntryFromCache(P28186730_ID + "_opatch");
565+
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
560566
String patchPath = getInstallerCacheDir() + FS + P28186730_INSTALLER;
561567
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
562568

0 commit comments

Comments
 (0)