Skip to content

Commit

Permalink
[PLAT-16427][PLAT-16371] Add master resize in operator, fix dedicated…
Browse files Browse the repository at this point in the history
…To in universe node details

Summary:
Diff adds support for master resize in Operator universes. Also fixes the dedicatedTo field
in node details to point to the correct server type.

Test Plan:
Manually tested operator universe master resize and creating universe with custom master
volume.

Reviewers: anijhawan, dshubin, vbansal, anabaria

Reviewed By: dshubin

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D41147
  • Loading branch information
kv83821-yb committed Jan 21, 2025
1 parent b8a6342 commit 6eb1d81
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ private void processNodeInfo() {
if (nodeName.contains("master")) {
nodeDetail.isTserver = false;
nodeDetail.isMaster = true;
nodeDetail.dedicatedTo = ServerType.MASTER;
nodeDetail.cloudInfo.private_ip =
KubernetesUtil.formatPodAddress(
podAddressTemplate,
Expand All @@ -672,6 +673,7 @@ private void processNodeInfo() {
} else {
nodeDetail.isMaster = false;
nodeDetail.isTserver = true;
nodeDetail.dedicatedTo = ServerType.TSERVER;
nodeDetail.cloudInfo.private_ip =
KubernetesUtil.formatPodAddress(
podAddressTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ protected void editUniverse(
UserIntent currentUserIntent = universeDetails.getPrimaryCluster().userIntent;
UserIntent incomingIntent = createUserIntent(ybUniverse, cust.getUuid(), false);

// Handle previously unset masterDeviceInfo
if (currentUserIntent.masterDeviceInfo == null) {
currentUserIntent.masterDeviceInfo = operatorUtils.defaultMasterDeviceInfo();
}

// Fix non-changeable values to current.
incomingIntent.accessKeyCode = currentUserIntent.accessKeyCode;
incomingIntent.enableExposingService = currentUserIntent.enableExposingService;
Expand All @@ -721,6 +726,8 @@ protected void editUniverse(
universe, k8ResourceDetails, TaskType.EditKubernetesUniverse.name());
currentUserIntent.numNodes = incomingIntent.numNodes;
currentUserIntent.deviceInfo.volumeSize = incomingIntent.deviceInfo.volumeSize;
currentUserIntent.masterDeviceInfo.volumeSize =
incomingIntent.masterDeviceInfo.volumeSize;
taskUUID = updateYBUniverse(universeDetails, cust, ybUniverse);
break;
case KubernetesOverridesUpgrade:
Expand Down Expand Up @@ -792,10 +799,15 @@ protected void editUniverse(
upgradeYBUniverse(
universeDetails, cust, ybUniverse, incomingIntent.ybSoftwareVersion);
} else if (operatorUtils.shouldUpdateYbUniverse(
currentUserIntent, incomingIntent.numNodes, incomingIntent.deviceInfo)) {
currentUserIntent,
incomingIntent.numNodes,
incomingIntent.deviceInfo,
incomingIntent.masterDeviceInfo)) {
log.info("Calling Edit Universe");
currentUserIntent.numNodes = incomingIntent.numNodes;
currentUserIntent.deviceInfo.volumeSize = incomingIntent.deviceInfo.volumeSize;
currentUserIntent.masterDeviceInfo.volumeSize =
incomingIntent.masterDeviceInfo.volumeSize;
kubernetesStatusUpdater.createYBUniverseEventStatus(
universe, k8ResourceDetails, TaskType.EditKubernetesUniverse.name());
if (checkAndHandleUniverseLock(
Expand Down Expand Up @@ -988,8 +1000,8 @@ private UserIntent createUserIntent(YBUniverse ybUniverse, UUID customerUUID, bo
userIntent.accessKeyCode = "";

userIntent.deviceInfo = operatorUtils.mapDeviceInfo(ybUniverse.getSpec().getDeviceInfo());
log.debug("ui.deviceInfo : {}", userIntent.deviceInfo);
log.debug("given deviceInfo: {} ", ybUniverse.getSpec().getDeviceInfo());
userIntent.masterDeviceInfo =
operatorUtils.mapMasterDeviceInfo(ybUniverse.getSpec().getMasterDeviceInfo());

userIntent.enableYSQL = ybUniverse.getSpec().getEnableYSQL();
userIntent.enableYCQL = ybUniverse.getSpec().getEnableYCQL();
Expand Down Expand Up @@ -1081,7 +1093,9 @@ private Provider createAutoProvider(
.map(
z -> {
HashMap<String, String> tempMap = new HashMap<>(z.config);
tempMap.put("STORAGE_CLASS", storageClass);
if (StringUtils.isNotBlank(storageClass)) {
tempMap.put("STORAGE_CLASS", storageClass);
}
tempMap.put("KUBENAMESPACE", kubeNamespace);
z.config = tempMap;
return z;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ spec:
rule: self == oldSelf
deviceInfo:
description: >
Device information for the universe to
Device information for the tservers in universe to
refer to storage information for volume,
storage classes etc.
properties:
Expand All @@ -198,6 +198,27 @@ spec:
- message: StorageClass cannot be changed once set.
rule: self == oldSelf
type: object
masterDeviceInfo:
description: >
Device information for the masters in universe to
refer to storage information for volume,
storage classes etc.
properties:
volumeSize:
type: integer
default: 50
numVolumes:
type: integer
default: 1
x-kubernetes-validations:
- message: numVolumes cannot be changed once set.
rule: self == oldSelf
storageClass:
type: string
x-kubernetes-validations:
- message: StorageClass cannot be changed once set.
rule: self == oldSelf
type: object
kubernetesOverrides:
description: >
Kubernetes overrides for the universe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ public static String getYbaUniverseName(YBUniverse ybUniverse) {
/*--- YBUniverse related help methods ---*/

public boolean shouldUpdateYbUniverse(
UserIntent currentUserIntent, int newNumNodes, DeviceInfo newDeviceInfo) {
UserIntent currentUserIntent,
int newNumNodes,
DeviceInfo newDeviceInfo,
DeviceInfo newMasterDeviceInfo) {
return !(currentUserIntent.numNodes == newNumNodes)
|| !currentUserIntent.deviceInfo.volumeSize.equals(newDeviceInfo.volumeSize);
|| !currentUserIntent.deviceInfo.volumeSize.equals(newDeviceInfo.volumeSize)
|| !currentUserIntent.masterDeviceInfo.volumeSize.equals(newMasterDeviceInfo.volumeSize);
}

public String getKubernetesOverridesString(
Expand Down Expand Up @@ -229,6 +233,36 @@ public DeviceInfo mapDeviceInfo(io.yugabyte.operator.v1alpha1.ybuniversespec.Dev
return di;
}

public DeviceInfo mapMasterDeviceInfo(
io.yugabyte.operator.v1alpha1.ybuniversespec.MasterDeviceInfo spec) {
DeviceInfo di = new DeviceInfo();

if (spec == null) {
return defaultMasterDeviceInfo();
}

Long numVols = spec.getNumVolumes();
if (numVols != null) {
di.numVolumes = numVols.intValue();
}

Long volSize = spec.getVolumeSize();
if (volSize != null) {
di.volumeSize = volSize.intValue();
}

di.storageClass = spec.getStorageClass();

return di;
}

public DeviceInfo defaultMasterDeviceInfo() {
DeviceInfo masterDeviceInfo = new DeviceInfo();
masterDeviceInfo.volumeSize = 50;
masterDeviceInfo.numVolumes = 1;
return masterDeviceInfo;
}

public boolean universeAndSpecMismatch(Customer cust, Universe u, YBUniverse ybUniverse) {
return universeAndSpecMismatch(cust, u, ybUniverse, null);
}
Expand All @@ -243,6 +277,11 @@ public boolean universeAndSpecMismatch(

UserIntent currentUserIntent = universeDetails.getPrimaryCluster().userIntent;

// Handle previously unset masterDeviceInfo
if (currentUserIntent.masterDeviceInfo == null) {
currentUserIntent.masterDeviceInfo = defaultMasterDeviceInfo();
}

Provider provider =
Provider.getOrBadRequest(cust.getUuid(), UUID.fromString(currentUserIntent.provider));
// Get all required params
Expand All @@ -251,6 +290,8 @@ public boolean universeAndSpecMismatch(
getKubernetesOverridesString(ybUniverse.getSpec().getKubernetesOverrides());
String incomingYbSoftwareVersion = ybUniverse.getSpec().getYbSoftwareVersion();
DeviceInfo incomingDeviceInfo = mapDeviceInfo(ybUniverse.getSpec().getDeviceInfo());
DeviceInfo incomingMasterDeviceInfo =
mapMasterDeviceInfo(ybUniverse.getSpec().getMasterDeviceInfo());
int incomingNumNodes = (int) ybUniverse.getSpec().getNumNodes().longValue();

if (prevTaskToRerun != null) {
Expand All @@ -260,7 +301,10 @@ public boolean universeAndSpecMismatch(
UniverseDefinitionTaskParams prevTaskParams =
Json.fromJson(prevTaskToRerun.getTaskParams(), UniverseDefinitionTaskParams.class);
return shouldUpdateYbUniverse(
prevTaskParams.getPrimaryCluster().userIntent, incomingNumNodes, incomingDeviceInfo);
prevTaskParams.getPrimaryCluster().userIntent,
incomingNumNodes,
incomingDeviceInfo,
incomingMasterDeviceInfo);
case KubernetesOverridesUpgrade:
KubernetesOverridesUpgradeParams overridesUpgradeTaskParams =
Json.fromJson(
Expand All @@ -286,7 +330,8 @@ public boolean universeAndSpecMismatch(
.userIntent
.specificGFlags /*Current gflags */,
specGFlags)
|| shouldUpdateYbUniverse(currentUserIntent, incomingNumNodes, incomingDeviceInfo)
|| shouldUpdateYbUniverse(
currentUserIntent, incomingNumNodes, incomingDeviceInfo, incomingMasterDeviceInfo)
|| !StringUtils.equals(currentUserIntent.ybSoftwareVersion, incomingYbSoftwareVersion);
}

Expand Down

0 comments on commit 6eb1d81

Please sign in to comment.