Skip to content

Commit

Permalink
[PLAT-12935] Kubernetes only releases are disabled
Browse files Browse the repository at this point in the history
Summary:
Kubernetes (helm chart) only releases are disabled,
as we need a valid db build when performing an
upgrade.

This is done by adding helm charts in an "Incomplete" state, and automatically moving them to "active" when a db.tgz is added also

Test Plan:
unit tests
added k8s release - disabled
uploaded db.tgz - active

Reviewers: muthu, anijhawan

Reviewed By: muthu

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D33297
  • Loading branch information
shubin-yb committed Mar 20, 2024
1 parent 8e8f8b0 commit 5578e6e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,12 @@ private void setArtifactMatchingPackage(String ybPackage) {
}
throw new RuntimeException("Unable to find matching artifact for package " + ybPackage);
}

public boolean isActive() {
if (isLegacy()) {
return this.metadata.state == ReleaseManager.ReleaseState.ACTIVE;
} else {
return this.release.getState() == Release.ReleaseState.ACTIVE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class ReleasesUtils {

public final String YB_PACKAGE_REGEX =
"yugabyte-(?:ee-)?(.*)-(alma|centos|linux|el8|darwin)(.*).tar.gz";
public final String YB_HELM_PACKAGE_REGEX = "(.*)yugabyte-(?:ee-)?(.*)-(helm)(.*).tar.gz";
// We can see helm packages as either yugabyte-<version>.tgz or yugabyte-version-helm.tgz
public final String YB_HELM_PACKAGE_REGEX = "yugabyte-(?:ee-)?(.*?)(?:-helm)?.tar.gz";
// Match release form 2.16.1.2 and return 2.16 or 2024.1.0.0 and return 2024
public final String YB_VERSION_TYPE_REGEX = "(2\\.\\d+|\\d\\d\\d\\d)";

Expand Down Expand Up @@ -254,7 +255,7 @@ public ExtractedMetadata metadataFromName(String fileName) {
}
} else if (helmPackage.find()) {
em.platform = ReleaseArtifact.Platform.KUBERNETES;
em.version = helmPackage.group(2);
em.version = helmPackage.group(1);
em.architecture = null;
} else {
throw new RuntimeException("failed to parse package " + fileName);
Expand Down
13 changes: 11 additions & 2 deletions managed/src/main/java/com/yugabyte/yw/models/Release.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public enum YbType {
public enum ReleaseState {
ACTIVE,
DISABLED,
INCOMPLETE,
DELETED
}

Expand All @@ -75,7 +76,7 @@ public static Release create(UUID releaseUUID, String version, String releaseTyp
release.version = version;
release.releaseType = releaseType;
release.yb_type = YbType.YBDB;
release.state = ReleaseState.ACTIVE;
release.state = ReleaseState.INCOMPLETE;
release.save();
return release;
}
Expand Down Expand Up @@ -105,7 +106,7 @@ public static Release createFromRequest(CreateRelease reqRelease) {
}
}
release.releaseNotes = reqRelease.release_notes;
release.state = ReleaseState.ACTIVE;
release.state = ReleaseState.INCOMPLETE;

release.save();
return release;
Expand Down Expand Up @@ -153,6 +154,14 @@ public void addArtifact(ReleaseArtifact artifact) {
artifact.getPlatform(), artifact.getArchitecture()));
}
artifact.setReleaseUUID(releaseUUID);

// Move the state from incomplete to active when adding a Linux type. Kubernetes artifacts
// are not sufficient to make a release move into the "active" state.
if (artifact.getPlatform() == ReleaseArtifact.Platform.LINUX
&& this.state == ReleaseState.INCOMPLETE) {
state = ReleaseState.ACTIVE;
save();
}
}

public List<ReleaseArtifact> getArtifacts() {
Expand Down
22 changes: 20 additions & 2 deletions managed/src/test/java/com/yugabyte/yw/models/ReleasesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;

import com.yugabyte.yw.cloud.PublicCloudConstants;
import com.yugabyte.yw.cloud.PublicCloudConstants.Architecture;
import com.yugabyte.yw.common.FakeDBApplication;
import com.yugabyte.yw.common.PlatformServiceException;
import java.util.List;
Expand Down Expand Up @@ -31,7 +32,8 @@ public void testBadRequest() {
public void testAddArtifact() {
Release release = Release.create(UUID.randomUUID(), "1.2.3", "LTS");
ReleaseArtifact artifact =
ReleaseArtifact.create("sha256", ReleaseArtifact.Platform.KUBERNETES, null, "file_url");
ReleaseArtifact.create(
"sha256", ReleaseArtifact.Platform.LINUX, Architecture.x86_64, "file_url");
release.addArtifact(artifact);
assertEquals(artifact.getReleaseUUID(), release.getReleaseUUID());
ReleaseArtifact newArtifact = ReleaseArtifact.get(artifact.getArtifactUUID());
Expand All @@ -42,7 +44,8 @@ public void testAddArtifact() {
public void testGetArtifacts() {
Release release = Release.create(UUID.randomUUID(), "1.2.3", "LTS");
ReleaseArtifact art1 =
ReleaseArtifact.create("sha256", ReleaseArtifact.Platform.KUBERNETES, null, "file_url");
ReleaseArtifact.create(
"sha256", ReleaseArtifact.Platform.LINUX, Architecture.aarch64, "file_url");
ReleaseArtifact art2 =
ReleaseArtifact.create(
"sha257",
Expand Down Expand Up @@ -79,4 +82,19 @@ public void testGetForArtifactType() {
assertEquals(1, result2.size());
assertEquals(release2.getReleaseUUID(), result2.get(0).getReleaseUUID());
}

@Test
public void testAddingK8S() {
Release release = Release.create(UUID.randomUUID(), "1.2.3", "LTS");
ReleaseArtifact artifact =
ReleaseArtifact.create("sha256", ReleaseArtifact.Platform.KUBERNETES, null, "file_url");

release.addArtifact(artifact);
assertEquals(Release.ReleaseState.INCOMPLETE, release.getState());
ReleaseArtifact art1 =
ReleaseArtifact.create(
"sha256", ReleaseArtifact.Platform.LINUX, Architecture.aarch64, "file_url");
release.addArtifact(art1);
assertEquals(Release.ReleaseState.ACTIVE, release.getState());
}
}

0 comments on commit 5578e6e

Please sign in to comment.