Skip to content

Commit

Permalink
[PLAT-16481] Fix upgrade paths that don't use YBA latest stable YBC v…
Browse files Browse the repository at this point in the history
…ersion

Summary:
There were a few places that still used Universe details based YBC version during upgrade.
Fixed them to use latest stable YBC always.

Test Plan:
Manually checked a couple scenarios
More testing to be done by QA as part of feature validation

Reviewers: vpatibandla

Reviewed By: vpatibandla

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D41295
  • Loading branch information
kv83821-yb committed Jan 23, 2025
1 parent 949b4c7 commit 61c61ab
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ protected void createNonRestartGflagsUpgradeTask(Universe universe) {
UniverseDefinitionTaskParams universeDetails = universe.getUniverseDetails();
Cluster primaryCluster = universeDetails.getPrimaryCluster();
KubernetesGflagsUpgradeCommonParams upgradeParamsPrimary =
new KubernetesGflagsUpgradeCommonParams(universe, primaryCluster);
new KubernetesGflagsUpgradeCommonParams(universe, primaryCluster, confGetter);
createSingleKubernetesExecutorTask(
universe.getName(),
CommandType.POD_INFO,
Expand Down Expand Up @@ -625,7 +625,7 @@ protected void createNonRestartGflagsUpgradeTask(Universe universe) {
if (universeDetails.getReadOnlyClusters().size() != 0) {
Cluster readOnlyCluster = universeDetails.getReadOnlyClusters().get(0);
KubernetesGflagsUpgradeCommonParams upgradeParamsReadOnly =
new KubernetesGflagsUpgradeCommonParams(universe, readOnlyCluster);
new KubernetesGflagsUpgradeCommonParams(universe, readOnlyCluster, confGetter);
PlacementInfo readClusterPlacementInfo = readOnlyCluster.placementInfo;
createSingleKubernetesExecutorTask(
universe.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void maybeConfigureHistoryRetention(
List<Cluster> clusters = universe.getUniverseDetails().clusters;
for (Cluster cluster : clusters) {
KubernetesGflagsUpgradeCommonParams upgradeParams =
new KubernetesGflagsUpgradeCommonParams(universe, cluster);
new KubernetesGflagsUpgradeCommonParams(universe, cluster, confGetter);
createSingleKubernetesExecutorTask(
universe.getName(),
CommandType.POD_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.yugabyte.yw.commissioner.tasks.subtasks.KubernetesCommandExecutor;
import com.yugabyte.yw.common.KubernetesUtil;
import com.yugabyte.yw.common.PlacementInfoUtil;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdater;
import com.yugabyte.yw.common.operator.OperatorStatusUpdater.UniverseState;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
Expand Down Expand Up @@ -218,21 +219,22 @@ public void run() {
.setSubTaskGroupType(SubTaskGroupType.ConfigureUniverse);

// Install YBC on the pods
String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);
if (taskParams().isEnableYbc()) {
installYbcOnThePods(
tserversAdded,
false,
taskParams().getYbcSoftwareVersion(),
stableYbcVersion,
taskParams().getPrimaryCluster().userIntent.ybcFlags);
if (readClusters.size() == 1) {
installYbcOnThePods(
readOnlyTserversAdded,
true,
taskParams().getYbcSoftwareVersion(),
stableYbcVersion,
taskParams().getReadOnlyClusters().get(0).userIntent.ybcFlags);
}
createWaitForYbcServerTask(allTserversAdded);
createUpdateYbcTask(taskParams().getYbcSoftwareVersion())
createUpdateYbcTask(stableYbcVersion)
.setSubTaskGroupType(SubTaskGroupType.ConfigureUniverse);
}

Expand All @@ -241,7 +243,7 @@ public void run() {
if (KubernetesUtil.isNonRestartGflagsUpgradeSupported(
primaryCluster.userIntent.ybSoftwareVersion)) {
KubernetesGflagsUpgradeCommonParams gflagsParams =
new KubernetesGflagsUpgradeCommonParams(universe, primaryCluster);
new KubernetesGflagsUpgradeCommonParams(universe, primaryCluster, confGetter);
nonRestartMasterGflagUpgrade =
() ->
upgradePodsNonRestart(
Expand All @@ -259,7 +261,7 @@ public void run() {
// Use taskParams here since updated universe details are not available
// during subtasks creation.
taskParams().isEnableYbc(),
taskParams().getYbcSoftwareVersion());
stableYbcVersion);
}

createConfigureUniverseTasks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private boolean editCluster(
isReadOnlyCluster,
newNamingStyle,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion(),
ybcManager.getStableYbcVersion(),
tserverDiskSizeChanged,
masterDiskSizeChanged,
supportsNonRestartGflagsUpgrade /* usePreviousGflagsChecksum */);
Expand Down Expand Up @@ -563,7 +563,7 @@ private boolean editCluster(
isReadOnlyCluster,
KubernetesCommandExecutor.CommandType.HELM_UPGRADE,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion(),
ybcManager.getStableYbcVersion(),
PodUpgradeParams.DEFAULT);

upgradePodsTask(
Expand All @@ -581,7 +581,7 @@ private boolean editCluster(
isReadOnlyCluster,
KubernetesCommandExecutor.CommandType.HELM_UPGRADE,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion(),
ybcManager.getStableYbcVersion(),
PodUpgradeParams.DEFAULT);
} else if (instanceTypeChanged) {
upgradePodsTask(
Expand All @@ -599,7 +599,7 @@ private boolean editCluster(
isReadOnlyCluster,
KubernetesCommandExecutor.CommandType.HELM_UPGRADE,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion(),
ybcManager.getStableYbcVersion(),
PodUpgradeParams.DEFAULT);
} else if (masterAddressesChanged) {
// Update master_addresses flag on Master
Expand Down Expand Up @@ -760,7 +760,7 @@ public void createMasterAddressesUpdateTask(
taskParams().useNewHelmNamingStyle,
isReadOnlyCluster,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
ybcManager.getStableYbcVersion());

Set<NodeDetails> mastersToModify =
Stream.concat(
Expand Down Expand Up @@ -799,7 +799,7 @@ public void createMasterAddressesUpdateTask(
taskParams().useNewHelmNamingStyle,
isReadOnlyCluster,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
ybcManager.getStableYbcVersion());

// Set flag in memory for tserver
createSetFlagInMemoryTasks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.yugabyte.yw.common.KubernetesUtil;
import com.yugabyte.yw.common.PlacementInfoUtil;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.config.RuntimeConfGetter;
import com.yugabyte.yw.common.config.UniverseConfKeys;
import com.yugabyte.yw.common.helm.HelmUtils;
import com.yugabyte.yw.common.kms.util.EncryptionAtRestUtil;
Expand Down Expand Up @@ -126,7 +127,8 @@ public static class KubernetesGflagsUpgradeCommonParams {
private boolean enableYbc;
private String ybcSoftwareVersion;

public KubernetesGflagsUpgradeCommonParams(Universe universe, Cluster cluster) {
public KubernetesGflagsUpgradeCommonParams(
Universe universe, Cluster cluster, RuntimeConfGetter confGetter) {
UniverseDefinitionTaskParams universeParams = universe.getUniverseDetails();
Cluster primaryCluster = universeParams.getPrimaryCluster();
KubernetesPlacement primaryClusterPlacement =
Expand Down Expand Up @@ -157,7 +159,7 @@ public KubernetesGflagsUpgradeCommonParams(Universe universe, Cluster cluster) {
? new KubernetesPlacement(cluster.placementInfo, true /* isReadOnlyCluster */)
: primaryClusterPlacement;
this.enableYbc = universe.isYbcEnabled();
this.ybcSoftwareVersion = universe.getUniverseDetails().getYbcSoftwareVersion();
this.ybcSoftwareVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,6 @@ public SubTaskGroup createGFlagsOverrideTasks(
// The software package to install for this cluster.
params.ybSoftwareVersion = userIntent.ybSoftwareVersion;
params.setEnableYbc(taskParams().isEnableYbc());
params.setYbcSoftwareVersion(taskParams().getYbcSoftwareVersion());
params.ybcGflags = userIntent.ybcFlags;
// Set the InstanceType
params.instanceType = node.cloudInfo.instance_type;
Expand Down Expand Up @@ -1528,7 +1527,6 @@ public SubTaskGroup createConfigureServerTasks(
// The software package to install for this cluster.
params.ybSoftwareVersion = userIntent.ybSoftwareVersion;
params.setEnableYbc(taskParams().isEnableYbc());
params.setYbcSoftwareVersion(taskParams().getYbcSoftwareVersion());
params.setYbcInstalled(taskParams().isYbcInstalled());
params.ybcGflags = userIntent.ybcFlags;
// Set the InstanceType
Expand Down Expand Up @@ -2932,14 +2930,17 @@ public void createYbcSoftwareInstallTasks(
"AnsibleConfigureServers (%s) for: %s",
SubTaskGroupType.InstallingSoftware, taskParams().nodePrefix);
SubTaskGroup subTaskGroup = createSubTaskGroup(subGroupDescription);

// Use stable version for YBC
String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);
for (NodeDetails node : nodes) {
subTaskGroup.addSubTask(
getAnsibleConfigureServerTask(
node,
ServerType.CONTROLLER,
UpgradeTaskSubType.YbcInstall,
softwareVersion,
taskParams().getYbcSoftwareVersion()));
stableYbcVersion));
}
subTaskGroup.setSubTaskGroupType(subTaskGroupType);
getRunnableTask().addSubTaskGroup(subTaskGroup);
Expand Down Expand Up @@ -3097,7 +3098,11 @@ protected AnsibleConfigureServers getAnsibleConfigureServerTask(
UpgradeTaskSubType taskSubType,
String softwareVersion) {
return getAnsibleConfigureServerTask(
node, processType, taskSubType, softwareVersion, taskParams().getYbcSoftwareVersion());
node,
processType,
taskSubType,
softwareVersion,
confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion));
}

public AnsibleConfigureServers.Params getAnsibleConfigureServerParams(
Expand Down Expand Up @@ -3132,7 +3137,7 @@ public AnsibleConfigureServers.Params getAnsibleConfigureServerParams(
params.setUniverseUUID(taskParams().getUniverseUUID());

params.setEnableYbc(taskParams().isEnableYbc());
params.setYbcSoftwareVersion(taskParams().getYbcSoftwareVersion());
params.setYbcSoftwareVersion(confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion));
params.installYbc = taskParams().installYbc;
params.setYbcInstalled(taskParams().isYbcInstalled());
params.ybcGflags = userIntent.ybcFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.yugabyte.yw.common.KubernetesManagerFactory;
import com.yugabyte.yw.common.KubernetesUtil;
import com.yugabyte.yw.common.backuprestore.ybc.YbcManager;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
import com.yugabyte.yw.forms.ResizeNodeParams;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void run() {
isReadOnlyCluster,
taskParams().useNewHelmNamingStyle,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion(),
confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion),
tserverDiskSizeChanged,
masterDiskSizeChanged,
usePreviousGflagsChecksum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ public void run() {
Set<NodeDetails> nodeDetailSet =
new HashSet<>(universe.getRunningTserversInPrimaryCluster());

installYbcOnThePods(
nodeDetailSet, false, universeDetails.getYbcSoftwareVersion(), ybcGflagsMap);
installYbcOnThePods(nodeDetailSet, false, ybcManager.getStableYbcVersion(), ybcGflagsMap);
performYbcAction(nodeDetailSet, false, "stop");
createWaitForYbcServerTask(nodeDetailSet)
.setSubTaskGroupType(SubTaskGroupType.ConfigureUniverse);

List<Cluster> readOnlyClusters = universeDetails.getReadOnlyClusters();
if (!readOnlyClusters.isEmpty()) {
nodeDetailSet = universeDetails.getTserverNodesInCluster(readOnlyClusters.get(0).uuid);
installYbcOnThePods(
nodeDetailSet, true, universeDetails.getYbcSoftwareVersion(), ybcGflagsMap);
installYbcOnThePods(nodeDetailSet, true, ybcManager.getStableYbcVersion(), ybcGflagsMap);
performYbcAction(nodeDetailSet, true, "stop");
createWaitForYbcServerTask(nodeDetailSet)
.setSubTaskGroupType(SubTaskGroupType.ConfigureUniverse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.yugabyte.yw.commissioner.tasks.subtasks.UniverseSetTlsParams;
import com.yugabyte.yw.commissioner.tasks.subtasks.UniverseUpdateRootCert;
import com.yugabyte.yw.commissioner.tasks.subtasks.UniverseUpdateRootCert.UpdateRootCertAction;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
import com.yugabyte.yw.forms.CertsRotateParams;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams.Cluster;
Expand Down Expand Up @@ -60,13 +61,14 @@ public void run() {
// So, generated node certs will still be of old rootCA after this step
createUniverseUpdateRootCertTask(UpdateRootCertAction.MultiCert);
// Create kubernetes upgrade task to rotate certs
String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);
createUpgradeTask(
getUniverse(),
userIntent.ybSoftwareVersion,
true /* isMasterChanged */,
true /* isTserverChanged */,
getUniverse().isYbcEnabled(),
getUniverse().getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);

// Now we will change the order of certs: new cert first, followed by old root cert
// Also cert key will be pointing to new root cert key
Expand All @@ -80,7 +82,7 @@ public void run() {
true /* isMasterChanged */,
true /* isTserverChanged */,
getUniverse().isYbcEnabled(),
getUniverse().getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);

// Reset the temporary certs and update the universe to use new rootCA
createUniverseUpdateRootCertTask(UpdateRootCertAction.Reset);
Expand All @@ -92,7 +94,7 @@ public void run() {
true /* isMasterChanged */,
true /* isTserverChanged */,
getUniverse().isYbcEnabled(),
getUniverse().getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.yugabyte.yw.commissioner.ITask.Abortable;
import com.yugabyte.yw.commissioner.KubernetesUpgradeTaskBase;
import com.yugabyte.yw.commissioner.UserTaskDetails.SubTaskGroupType;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
import com.yugabyte.yw.forms.ConfigureDBApiParams;
import com.yugabyte.yw.forms.UniverseTaskParams;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void run() {
true /* isMasterChanged */,
true /* isTserverChanged */,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion));

// Now update Universe state in DB.
// Update custom communication ports in universe and node details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.yugabyte.yw.common.KubernetesManagerFactory;
import com.yugabyte.yw.common.KubernetesUtil;
import com.yugabyte.yw.common.XClusterUniverseService;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.gflags.GFlagsValidation;
import com.yugabyte.yw.common.gflags.SpecificGFlags;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
Expand Down Expand Up @@ -107,6 +108,7 @@ public void run() {
// Helm update will finish without any restarts if there are no updates
boolean updateMaster = true;
boolean updateTserver = true;
String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);

switch (taskParams().upgradeOption) {
case ROLLING_UPGRADE:
Expand All @@ -116,7 +118,7 @@ public void run() {
updateMaster,
updateTserver,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);
break;
case NON_ROLLING_UPGRADE:
createNonRollingGflagUpgradeTask(
Expand All @@ -125,7 +127,7 @@ public void run() {
updateMaster,
updateTserver,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);
break;
case NON_RESTART_UPGRADE:
createNonRestartGflagsUpgradeTask(getUniverse());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.yugabyte.yw.commissioner.TaskExecutor.SubTaskGroup;
import com.yugabyte.yw.commissioner.UserTaskDetails.SubTaskGroupType;
import com.yugabyte.yw.commissioner.tasks.subtasks.UpdateAndPersistKubernetesOverrides;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
import com.yugabyte.yw.forms.KubernetesOverridesUpgradeParams;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams.Cluster;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void run() {
// Set overrides to primary cluster so that they will be picked up in upgrade tasks.
cluster.userIntent.universeOverrides = taskParams().universeOverrides;
cluster.userIntent.azOverrides = taskParams().azOverrides;
String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);

// Create Kubernetes Upgrade Task.
createUpgradeTask(
Expand All @@ -60,7 +62,7 @@ public void run() {
/* isMasterChanged */ true,
/* isTServerChanged */ true,
universe.isYbcEnabled(),
universe.getUniverseDetails().getYbcSoftwareVersion());
stableYbcVersion);
// Remove extra Namespaced scope services.
addHandleKubernetesNamespacedServices(
false /* readReplicaDelete */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.yugabyte.yw.commissioner.KubernetesUpgradeTaskBase;
import com.yugabyte.yw.commissioner.UpgradeTaskBase.UpgradeContext;
import com.yugabyte.yw.commissioner.UserTaskDetails;
import com.yugabyte.yw.common.config.GlobalConfKeys;
import com.yugabyte.yw.common.operator.OperatorStatusUpdaterFactory;
import com.yugabyte.yw.forms.RollbackUpgradeParams;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams;
Expand Down Expand Up @@ -78,14 +79,16 @@ public void run() {
createRollbackAutoFlagTask(taskParams().getUniverseUUID(), autoFlagConfigVersion);
}

String stableYbcVersion = confGetter.getGlobalConf(GlobalConfKeys.ybcStableVersion);

// Create Kubernetes Upgrade Task
createUpgradeTask(
getUniverse(),
newVersion,
true,
true,
taskParams().isEnableYbc(),
taskParams().getYbcSoftwareVersion(),
stableYbcVersion,
getRollbackUpgradeContext(newVersion));

// Update Software version
Expand Down
Loading

0 comments on commit 61c61ab

Please sign in to comment.