Skip to content

Commit

Permalink
Merge branch 'ohs-no-overlay' into 'main'
Browse files Browse the repository at this point in the history
Changed code to handle OHS and some of its components no longer having overlay information

See merge request weblogic-cloud/weblogic-image-tool!478
  • Loading branch information
ddsharpe committed Jul 23, 2024
2 parents 9cf4df7 + 3f89a52 commit 76297df
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ List<AruPatch> getLatestPsu(AruProduct product, String version, String userId, S
try {
logger.info("IMG-0019", product.description());
String releaseNumber = getReleaseNumber(product, version, userId, password);
if (Utils.isEmptyString(releaseNumber)) {
// ARU does not have a release number for the given product and version, return empty patch list
logger.info(Utils.getMessage("IMG-0082", version, product.description()));
return Collections.emptyList();
}
Document aruRecommendations = retry(
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));
logger.exiting();
return AruPatch.getPatches(aruRecommendations)
.filter(AruPatch::isPsu)
.filter(not(AruPatch::isStackPatchBundle))
.collect(Collectors.toList());
} catch (NoPatchesFoundException | ReleaseNotFoundException ex) {
} catch (NoPatchesFoundException ex) {
logger.exiting();
return Collections.emptyList();
} catch (RetryFailedException | XPathExpressionException e) {
Expand All @@ -154,7 +159,7 @@ List<AruPatch> getLatestPsu(AruProduct product, String version, String userId, S
}

/**
* Get list of recommended patches available for a given product and version.
* Get list of recommended patches available for all the products that are part of the FMW installer type.
*
* @param type FMW installer type
* @param version version number like 12.2.1.3.0
Expand Down Expand Up @@ -203,44 +208,43 @@ public List<AruPatch> getRecommendedPatches(FmwInstallerType type, String versio
List<AruPatch> getRecommendedPatches(AruProduct product, String version, String userId, String password)
throws AruException {
logger.entering(product, version);
List<AruPatch> patches = Collections.emptyList();
try {
logger.info("IMG-0067", product.description());
String releaseNumber = getReleaseNumber(product, version, userId, password);
Document aruRecommendations = retry(
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));
// TODO: Need an option for the user to request the Coherence additional feature pack.
List<AruPatch> patches = AruPatch.getPatches(aruRecommendations)
.filter(not(AruPatch::isStackPatchBundle)) //remove Stack Patch Bundle
.filter(not(AruPatch::isCoherenceFeaturePack)) //remove COH feature pack
.collect(Collectors.toList());
String psuVersion = getPsuVersion(product.description(), patches);
if (psuVersion != null) {
//repeat the same process to get recommended patches, but use the PSU release instead of the GA release
// All the same patches are in the PSU release, but also the overlay patches (if any)
patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}", p.patchId(), p.description()));
logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}",
psuVersion);
// get release number for PSU
String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password);
// get recommended patches for PSU release (Overlay patches are only recommended on the PSU release)
Document psuOverrides = retry(
() -> getRecommendedPatchesMetadata(product, psuReleaseNumber, userId, password));

patches = AruPatch.getPatches(psuOverrides)
.filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned
.filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned
.collect(Collectors.toList());
if (Utils.isEmptyString(releaseNumber)) {
// ARU does not have a release number for the given product and version, return an empty patch list
logger.info(Utils.getMessage("IMG-0082", version, product.description()));
} else {
// Get a list of patches applicable to the given product and release number
patches = getReleaseRecommendations(product, releaseNumber, userId, password);
String psuVersion = getPsuVersion(product.description(), patches);
if (psuVersion != null) {
// Check to see if there is a release with the PSU version that contains overlay patches.
logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}",
psuVersion);
// Get the release number for the PSU version number
String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password);
// If there is a release for the specific PSU, check it for overlay patches
if (!Utils.isEmptyString(psuReleaseNumber)) {
// Debug log - useful to know what was thrown away when "patches" is replaced by the new array
patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}",
p.patchId(), p.description()));
// Get recommended patches for PSU release (includes PSU overlay patches)
patches = getReleaseRecommendations(product, psuReleaseNumber, userId, password);
} else {
// ARU does not have a release number for the PSU version found (no overlays needed)
logger.fine("PSU release was not found for {0} : {1}", product, psuVersion);
}
}
}
logger.exiting(patches);
return patches;
} catch (ReleaseNotFoundException nf) {
return Collections.emptyList();
} catch (NoPatchesFoundException npf) {
logger.info("IMG-0069", product.description(), version);
return Collections.emptyList();
} catch (RetryFailedException | XPathExpressionException e) {
throw new AruException(Utils.getMessage("IMG-0070", product.description(), version), e);
}
logger.exiting(patches);
return patches;
}

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

List<AruPatch> getReleaseRecommendations(AruProduct product, String releaseNumber, String userId, String password)
throws AruException, XPathExpressionException, RetryFailedException {

Document patchesDocument = retry(
() -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password));

return AruPatch.getPatches(patchesDocument)
.filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned
// TODO: Need an option for the user to request the Coherence additional feature pack.
.filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned
.collect(Collectors.toList());
}

static class PatchLists {
List<InstalledPatch> installedPatches;
List<AruPatch> candidatePatches;
Expand Down Expand Up @@ -358,7 +375,6 @@ Document getRecommendedPatchesMetadata(AruProduct product, String releaseNumber,
* @param password OTN credential password
* @return release number for the product and version provided
* @throws AruException if the call to ARU fails, or the response from ARU had an error
* @throws ReleaseNotFoundException if the specified version for the requested product was not found
*/
private String getReleaseNumber(AruProduct product, String version, String userId, String password)
throws AruException {
Expand All @@ -375,11 +391,6 @@ private String getReleaseNumber(AruProduct product, String version, String userI
} catch (XPathExpressionException xpe) {
throw new AruException("Could not extract release number with XPath", xpe);
}
if (Utils.isEmptyString(result)) {
String msg = Utils.getMessage("IMG-0082", version, product.description());
logger.info(msg);
throw new ReleaseNotFoundException(msg);
}
logger.exiting(result);
return result;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,6 @@ void createAuxImage(TestInfo testInfo) throws Exception {
@Test
@Order(20)
@Tag("nightly")
@Tag("failing")
@DisplayName("Create FMW 12.2.1.3 image with latest PSU")
void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
// add jdk 8u212 installer to the cache
Expand Down Expand Up @@ -879,7 +878,6 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
@Test
@Order(23)
@Tag("nightly")
@Tag("failing")
@DisplayName("Create FMW image with WDT domain and latestPSU with new base img")
void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
// test assumes that the FMW 12.2.1.3 installer is already in the cache
Expand Down Expand Up @@ -955,7 +953,6 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception {
@Test
@Order(25)
@Tag("nightly")
@Tag("failing")
@DisplayName("Create image with additionalBuildCommands and recommendedPatches")
void createWlsImgWithAdditionalBuildCommands(TestInfo testInfo) throws Exception {
String tagName = build_tag + ":" + getMethodName(testInfo);
Expand Down

0 comments on commit 76297df

Please sign in to comment.