Skip to content

Commit

Permalink
[PLAT-13406] Copy releases from yb.docker.release directory on startup
Browse files Browse the repository at this point in the history
Summary:
The new implementation of releases was not copying release tgz on startup. We now
call the code that does the copy in both "legacyImportLocalRelease" and the new workflow

Test Plan:
add new releases to the path at yb.docker.release, start yba.
Validate they are added to the release database

Reviewers: muthu, anijhawan

Reviewed By: muthu

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D33962
  • Loading branch information
shubin-yb committed Apr 10, 2024
1 parent 755a341 commit ecdc1aa
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions managed/src/main/java/com/yugabyte/yw/common/ReleaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,17 @@ public synchronized void importLocalReleases() {
String ybReleasesPath = appConfig.getString(YB_RELEASES_PATH);
if (ybReleasesPath != null && !ybReleasesPath.isEmpty()) {
if (confGetter.getGlobalConf(GlobalConfKeys.enableReleasesRedesign)) {
String releasePath = appConfig.getString(YB_RELEASES_PATH);
Set<String> currentVersions =
Release.getAll().stream().map(r -> r.getVersion()).collect(Collectors.toSet());
copyReleasesFromDockerRelease(ybReleasesPath, currentVersions);
List<ReleaseLocalFile> currentLocalFiles = ReleaseLocalFile.getLocalFiles();
Set<String> currentFilePaths =
Sets.newHashSet(
currentLocalFiles.stream()
.map(rlf -> rlf.getLocalFilePath())
.collect(Collectors.toList()));
try {
Files.walk(Paths.get(releasePath))
Files.walk(Paths.get(ybReleasesPath))
.filter(
getPackageFilter(
"glob:**yugabyte*{centos,alma,linux,el}*{x86_64,aarch64}.tar.gz"))
Expand Down Expand Up @@ -721,14 +723,7 @@ private void importLocalLegacyReleases(

// Local copy pattern to account for the presence of characters prior to the file name itself.
// (ensures that all local releases get imported prior to version checking).
Pattern ybPackagePatternCopy =
Pattern.compile(confGetter.getGlobalConf(GlobalConfKeys.ybdbReleasePathRegex));

Pattern ybHelmChartPatternCopy =
Pattern.compile(confGetter.getGlobalConf(GlobalConfKeys.ybdbHelmReleasePathRegex));

copyFiles(ybReleasePath, ybReleasesPath, ybPackagePatternCopy, currentReleases.keySet());
copyFiles(ybHelmChartPath, ybReleasesPath, ybHelmChartPatternCopy, currentReleases.keySet());
copyReleasesFromDockerRelease(ybReleasesPath, currentReleases.keySet());
Map<String, ReleaseMetadata> localReleases = getLocalReleases(ybReleasesPath);
localReleases.keySet().removeAll(currentReleases.keySet());
log.debug("Current releases: [ {} ]", currentReleases.keySet().toString());
Expand Down Expand Up @@ -1087,6 +1082,17 @@ public synchronized void updateReleaseMetadata(String version, ReleaseMetadata n
configHelper.loadConfigToDB(ConfigHelper.ConfigType.SoftwareReleases, currentReleases);
}

private void copyReleasesFromDockerRelease(String destinationDir, Set<String> skipVersions) {
String ybReleasePath = appConfig.getString("yb.docker.release");
String ybHelmChartPath = appConfig.getString("yb.helm.packagePath");
Pattern ybPackagePatternCopy =
Pattern.compile(confGetter.getGlobalConf(GlobalConfKeys.ybdbReleasePathRegex));
Pattern ybHelmChartPatternCopy =
Pattern.compile(confGetter.getGlobalConf(GlobalConfKeys.ybdbHelmReleasePathRegex));
copyFiles(ybReleasePath, destinationDir, ybPackagePatternCopy, skipVersions);
copyFiles(ybHelmChartPath, destinationDir, ybHelmChartPatternCopy, skipVersions);
}

/**
* This method copies release files that match a specific regex to a destination directory.
*
Expand Down

0 comments on commit ecdc1aa

Please sign in to comment.