Skip to content

Commit

Permalink
[PLAT-15397]Add a check for software version when configuring Namespa…
Browse files Browse the repository at this point in the history
…ced services

Summary:
We were blindly trying to make override changes even for charts that do not support
Namespaced services. Added a software version check.

Test Plan:
Manually tested a flow where software version does not support Namespaced services. In
this case, the AZ services are brought up like the old flow.

Reviewers: anijhawan

Reviewed By: anijhawan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D38255
  • Loading branch information
kv83821-yb committed Sep 24, 2024
1 parent 395a4ba commit 6897046
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
17 changes: 15 additions & 2 deletions managed/src/main/java/com/yugabyte/yw/common/KubernetesUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
public class KubernetesUtil {

public static String MIN_VERSION_NON_RESTART_GFLAGS_UPGRADE_SUPPORT_PREVIEW = "2.23.0.0-b539";
public static String MIN_VERSION_NON_RESTART_GFLAGS_UPGRADE_SUPPORT_STABLE = "2024.2.0.0-b999";
public static String MIN_VERSION_NON_RESTART_GFLAGS_UPGRADE_SUPPORT_STABLE = "2024.2.0.0-b1";
public static String MIN_VERSION_NAMESPACED_SERVICE_SUPPORT_PREVIEW = "2.23.1.0-b168";
public static String MIN_VERSION_NAMESPACED_SERVICE_SUPPORT_STABLE = "2024.2.0.0-b1";
// Kubelet secret sync time + k8s_parent template sync time.
public static final int WAIT_FOR_GFLAG_SYNC_SECS = 90;

Expand All @@ -74,6 +76,15 @@ public static boolean isNonRestartGflagsUpgradeSupported(String universeSoftware
> 0;
}

public static boolean isNamespacedServiceSupported(String universeSoftwareVersion) {
return Util.compareYBVersions(
universeSoftwareVersion,
MIN_VERSION_NAMESPACED_SERVICE_SUPPORT_STABLE,
MIN_VERSION_NAMESPACED_SERVICE_SUPPORT_PREVIEW,
true)
> 0;
}

// ToDo: Old k8s provider needs to be fixed, so that we can get
// rid of the old merging logic, & start treating them same as the
// new providers.
Expand Down Expand Up @@ -784,7 +795,9 @@ public static NodeDetails getKubernetesNodeName(
public static boolean shouldConfigureNamespacedService(
UniverseDefinitionTaskParams universeDetails, Map<String, String> universeConfig) {
if (!universeDetails.useNewHelmNamingStyle
|| universeConfig.getOrDefault(Universe.LABEL_K8S_RESOURCES, "false").equals("false")) {
|| universeConfig.getOrDefault(Universe.LABEL_K8S_RESOURCES, "false").equals("false")
|| !isNamespacedServiceSupported(
universeDetails.getPrimaryCluster().userIntent.ybSoftwareVersion)) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private Map<String, String> universeConfig() {
@Test
public void testExtraNSScopedServiceToRemoveRRDeleteDifferentNS() throws IOException {
Pair<UniverseDefinitionTaskParams, List<AvailabilityZone>> pair =
addClusterAndNodeDetailsK8s("2024.2.0.0", true /* createRR */);
addClusterAndNodeDetailsK8s("2024.2.0.0-b2", true /* createRR */);
Map<String, String> universeConfig = universeConfig();
String serviceEndpoint = TestUtils.readResource("kubernetes/service_endpoint_overrides.yaml");
Map<String, String> azConfig = new HashMap<>();
Expand Down Expand Up @@ -101,7 +101,7 @@ public void testExtraNSScopedServiceToRemoveRRDeleteDifferentNS() throws IOExcep
@Test
public void testExtraNSScopedServiceToRemoveRRDeleteSameNS() throws IOException {
Pair<UniverseDefinitionTaskParams, List<AvailabilityZone>> pair =
addClusterAndNodeDetailsK8s("2024.2.0.0", true /* createRR */);
addClusterAndNodeDetailsK8s("2024.2.0.0-b2", true /* createRR */);
Map<String, String> universeConfig = universeConfig();
String serviceEndpoint = TestUtils.readResource("kubernetes/service_endpoint_overrides.yaml");
Map<String, String> azConfig = new HashMap<>();
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testExtraNSScopedServiceToRemoveRRDeleteSameNS() throws IOException
@Test
public void testExtraNSScopedServiceToRemoveOverridesChange() throws IOException {
Pair<UniverseDefinitionTaskParams, List<AvailabilityZone>> pair =
addClusterAndNodeDetailsK8s("2024.2.0.0", false /* createRR */);
addClusterAndNodeDetailsK8s("2024.2.0.0-b2", false /* createRR */);
Map<String, String> universeConfig = universeConfig();
String serviceEndpoint = TestUtils.readResource("kubernetes/service_endpoint_overrides.yaml");
String serviceEndpointsOverriden =
Expand Down Expand Up @@ -162,7 +162,7 @@ public void testExtraNSScopedServiceToRemoveOverridesChange() throws IOException
@Test
public void testExtraNSScopedServiceToRemoveDeleteAZMultiNS() throws IOException {
Pair<UniverseDefinitionTaskParams, List<AvailabilityZone>> pair =
addClusterAndNodeDetailsK8s("2024.2.0.0", false /* createRR */);
addClusterAndNodeDetailsK8s("2024.2.0.0-b2", false /* createRR */);
Map<String, String> universeConfig = universeConfig();
String serviceEndpoint = TestUtils.readResource("kubernetes/service_endpoint_overrides.yaml");
Map<String, String> azConfig = new HashMap<>();
Expand Down Expand Up @@ -232,7 +232,7 @@ public void testExtraNSScopedServiceToRemoveDeleteAZMultiNS() throws IOException
@Test
public void testExtraNSScopedServiceToRemoveDeleteAZSingleNS() throws IOException {
Pair<UniverseDefinitionTaskParams, List<AvailabilityZone>> pair =
addClusterAndNodeDetailsK8s("2024.2.0.0", false /* createRR */);
addClusterAndNodeDetailsK8s("2024.2.0.0-b2", false /* createRR */);
Map<String, String> universeConfig = universeConfig();
String serviceEndpoint = TestUtils.readResource("kubernetes/service_endpoint_overrides.yaml");
Map<String, String> azConfig = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ protected Result createUniverseWithoutYsqlPasswordAndYsqlEnabled() {
// SEO: ServiceEndpointOverrides
@Test
public void testCreateK8sUniverseMatchingSEOSingleNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1645,7 +1645,7 @@ public void testCreateK8sUniverseMatchingSEOSingleNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseEmptyArraySEOSingleNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1683,7 +1683,7 @@ public void testCreateK8sUniverseEmptyArraySEOSingleNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseNoSEOSingleNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1712,7 +1712,7 @@ public void testCreateK8sUniverseNoSEOSingleNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseMatchingSEOMultiNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1758,7 +1758,7 @@ public void testCreateK8sUniverseMatchingSEOMultiNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseWithRRMatchingSEOSameNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1796,7 +1796,7 @@ public void testCreateK8sUniverseWithRRMatchingSEOSameNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseWithRRMatchingSEOMultiNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1845,7 +1845,7 @@ public void testCreateK8sUniverseWithRRMatchingSEOMultiNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseMCSMatchingSEOSameNSMultiAZSuccess() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1900,7 +1900,7 @@ public void testCreateK8sUniverseMCSMatchingSEOSameNSMultiAZSuccess() {

@Test
public void testCreateK8sUniverseMismatchSEOMultiNSMultiAZFail() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -1948,7 +1948,7 @@ public void testCreateK8sUniverseMismatchSEOMultiNSMultiAZFail() {

@Test
public void testCreateK8sUniverseMCSMismatchSEOSingleNSMultiAZFail() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -2010,7 +2010,7 @@ public void testCreateK8sUniverseMCSMismatchSEOSingleNSMultiAZFail() {

@Test
public void testCreateK8sUniverseWithRRMismatchSEOSingleNSMultiAZFail() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -2060,7 +2060,7 @@ public void testCreateK8sUniverseWithRRMismatchSEOSingleNSMultiAZFail() {

@Test
public void testCreateK8sUniverseMismatchSEOSingleNSMultiAZFail() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down Expand Up @@ -2114,7 +2114,7 @@ public void testCreateK8sUniverseMismatchSEOSingleNSMultiAZFail() {

@Test
public void testCreateK8sUniverseConflictingSameNameSEOFail() {
String ybVersion = "2024.2.0.0-b1";
String ybVersion = "2024.2.0.0-b2";
when(mockRuntimeConfig.getBoolean("yb.use_new_helm_naming")).thenReturn(true);
when(mockRuntimeConfig.getString("yb.universe.default_service_scope_for_k8s"))
.thenReturn("Namespaced");
Expand Down

0 comments on commit 6897046

Please sign in to comment.