Skip to content

Commit 76297df

Browse files
committed
Merge branch 'ohs-no-overlay' into 'main'
Changed code to handle OHS and some of its components no longer having overlay information See merge request weblogic-cloud/weblogic-image-tool!478
2 parents 9cf4df7 + 3f89a52 commit 76297df

File tree

3 files changed

+48
-56
lines changed

3 files changed

+48
-56
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/AruUtil.java

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,19 @@ List<AruPatch> getLatestPsu(AruProduct product, String version, String userId, S
137137
try {
138138
logger.info("IMG-0019", product.description());
139139
String releaseNumber = getReleaseNumber(product, version, userId, password);
140+
if (Utils.isEmptyString(releaseNumber)) {
141+
// ARU does not have a release number for the given product and version, return empty patch list
142+
logger.info(Utils.getMessage("IMG-0082", version, product.description()));
143+
return Collections.emptyList();
144+
}
140145
Document aruRecommendations = retry(
141146
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));
142147
logger.exiting();
143148
return AruPatch.getPatches(aruRecommendations)
144149
.filter(AruPatch::isPsu)
145150
.filter(not(AruPatch::isStackPatchBundle))
146151
.collect(Collectors.toList());
147-
} catch (NoPatchesFoundException | ReleaseNotFoundException ex) {
152+
} catch (NoPatchesFoundException ex) {
148153
logger.exiting();
149154
return Collections.emptyList();
150155
} catch (RetryFailedException | XPathExpressionException e) {
@@ -154,7 +159,7 @@ List<AruPatch> getLatestPsu(AruProduct product, String version, String userId, S
154159
}
155160

156161
/**
157-
* Get list of recommended patches available for a given product and version.
162+
* Get list of recommended patches available for all the products that are part of the FMW installer type.
158163
*
159164
* @param type FMW installer type
160165
* @param version version number like 12.2.1.3.0
@@ -203,44 +208,43 @@ public List<AruPatch> getRecommendedPatches(FmwInstallerType type, String versio
203208
List<AruPatch> getRecommendedPatches(AruProduct product, String version, String userId, String password)
204209
throws AruException {
205210
logger.entering(product, version);
211+
List<AruPatch> patches = Collections.emptyList();
206212
try {
207213
logger.info("IMG-0067", product.description());
208214
String releaseNumber = getReleaseNumber(product, version, userId, password);
209-
Document aruRecommendations = retry(
210-
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));
211-
// TODO: Need an option for the user to request the Coherence additional feature pack.
212-
List<AruPatch> patches = AruPatch.getPatches(aruRecommendations)
213-
.filter(not(AruPatch::isStackPatchBundle)) //remove Stack Patch Bundle
214-
.filter(not(AruPatch::isCoherenceFeaturePack)) //remove COH feature pack
215-
.collect(Collectors.toList());
216-
String psuVersion = getPsuVersion(product.description(), patches);
217-
if (psuVersion != null) {
218-
//repeat the same process to get recommended patches, but use the PSU release instead of the GA release
219-
// All the same patches are in the PSU release, but also the overlay patches (if any)
220-
patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}", p.patchId(), p.description()));
221-
logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}",
222-
psuVersion);
223-
// get release number for PSU
224-
String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password);
225-
// get recommended patches for PSU release (Overlay patches are only recommended on the PSU release)
226-
Document psuOverrides = retry(
227-
() -> getRecommendedPatchesMetadata(product, psuReleaseNumber, userId, password));
228-
229-
patches = AruPatch.getPatches(psuOverrides)
230-
.filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned
231-
.filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned
232-
.collect(Collectors.toList());
215+
if (Utils.isEmptyString(releaseNumber)) {
216+
// ARU does not have a release number for the given product and version, return an empty patch list
217+
logger.info(Utils.getMessage("IMG-0082", version, product.description()));
218+
} else {
219+
// Get a list of patches applicable to the given product and release number
220+
patches = getReleaseRecommendations(product, releaseNumber, userId, password);
221+
String psuVersion = getPsuVersion(product.description(), patches);
222+
if (psuVersion != null) {
223+
// Check to see if there is a release with the PSU version that contains overlay patches.
224+
logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}",
225+
psuVersion);
226+
// Get the release number for the PSU version number
227+
String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password);
228+
// If there is a release for the specific PSU, check it for overlay patches
229+
if (!Utils.isEmptyString(psuReleaseNumber)) {
230+
// Debug log - useful to know what was thrown away when "patches" is replaced by the new array
231+
patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}",
232+
p.patchId(), p.description()));
233+
// Get recommended patches for PSU release (includes PSU overlay patches)
234+
patches = getReleaseRecommendations(product, psuReleaseNumber, userId, password);
235+
} else {
236+
// ARU does not have a release number for the PSU version found (no overlays needed)
237+
logger.fine("PSU release was not found for {0} : {1}", product, psuVersion);
238+
}
239+
}
233240
}
234-
logger.exiting(patches);
235-
return patches;
236-
} catch (ReleaseNotFoundException nf) {
237-
return Collections.emptyList();
238241
} catch (NoPatchesFoundException npf) {
239242
logger.info("IMG-0069", product.description(), version);
240-
return Collections.emptyList();
241243
} catch (RetryFailedException | XPathExpressionException e) {
242244
throw new AruException(Utils.getMessage("IMG-0070", product.description(), version), e);
243245
}
246+
logger.exiting(patches);
247+
return patches;
244248
}
245249

246250
private String getPsuVersion(String productName, Collection<AruPatch> patches) {
@@ -256,6 +260,19 @@ private String getPsuVersion(String productName, Collection<AruPatch> patches) {
256260
return null;
257261
}
258262

263+
List<AruPatch> getReleaseRecommendations(AruProduct product, String releaseNumber, String userId, String password)
264+
throws AruException, XPathExpressionException, RetryFailedException {
265+
266+
Document patchesDocument = retry(
267+
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));
268+
269+
return AruPatch.getPatches(patchesDocument)
270+
.filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned
271+
// TODO: Need an option for the user to request the Coherence additional feature pack.
272+
.filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned
273+
.collect(Collectors.toList());
274+
}
275+
259276
static class PatchLists {
260277
List<InstalledPatch> installedPatches;
261278
List<AruPatch> candidatePatches;
@@ -358,7 +375,6 @@ Document getRecommendedPatchesMetadata(AruProduct product, String releaseNumber,
358375
* @param password OTN credential password
359376
* @return release number for the product and version provided
360377
* @throws AruException if the call to ARU fails, or the response from ARU had an error
361-
* @throws ReleaseNotFoundException if the specified version for the requested product was not found
362378
*/
363379
private String getReleaseNumber(AruProduct product, String version, String userId, String password)
364380
throws AruException {
@@ -375,11 +391,6 @@ private String getReleaseNumber(AruProduct product, String version, String userI
375391
} catch (XPathExpressionException xpe) {
376392
throw new AruException("Could not extract release number with XPath", xpe);
377393
}
378-
if (Utils.isEmptyString(result)) {
379-
String msg = Utils.getMessage("IMG-0082", version, product.description());
380-
logger.info(msg);
381-
throw new ReleaseNotFoundException(msg);
382-
}
383394
logger.exiting(result);
384395
return result;
385396
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/ReleaseNotFoundException.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ void createAuxImage(TestInfo testInfo) throws Exception {
783783
@Test
784784
@Order(20)
785785
@Tag("nightly")
786-
@Tag("failing")
787786
@DisplayName("Create FMW 12.2.1.3 image with latest PSU")
788787
void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
789788
// add jdk 8u212 installer to the cache
@@ -879,7 +878,6 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
879878
@Test
880879
@Order(23)
881880
@Tag("nightly")
882-
@Tag("failing")
883881
@DisplayName("Create FMW image with WDT domain and latestPSU with new base img")
884882
void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
885883
// test assumes that the FMW 12.2.1.3 installer is already in the cache
@@ -955,7 +953,6 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception {
955953
@Test
956954
@Order(25)
957955
@Tag("nightly")
958-
@Tag("failing")
959956
@DisplayName("Create image with additionalBuildCommands and recommendedPatches")
960957
void createWlsImgWithAdditionalBuildCommands(TestInfo testInfo) throws Exception {
961958
String tagName = build_tag + ":" + getMethodName(testInfo);

0 commit comments

Comments
 (0)