Skip to content

Commit

Permalink
[PLAT-12690] Remove runtime config for volume size validation
Browse files Browse the repository at this point in the history
Summary:
This unblocks full moves for volume size decreases without needing to set a runtime config.
A future preflight check will ensure that the target configuration disk size can accomodate the
current disk usage.

Test Plan: Unit tests

Reviewers: prarabdh.garg, yshchetinin

Reviewed By: prarabdh.garg

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D32802
  • Loading branch information
iSignal committed Mar 7, 2024
1 parent 1484e89 commit 1f42cab
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1410,20 +1410,6 @@ public void verifyParams(UniverseOpType opType) {
throw new IllegalArgumentException("'Name' tag value cannot be changed.");
}
}
if (cluster.userIntent.deviceInfo != null
&& cluster.userIntent.deviceInfo.volumeSize != null
&& cluster.userIntent.deviceInfo.numVolumes != null) {
int prevSize =
univCluster.userIntent.deviceInfo.volumeSize
* univCluster.userIntent.deviceInfo.numVolumes;
int curSize =
cluster.userIntent.deviceInfo.volumeSize * cluster.userIntent.deviceInfo.numVolumes;
if (curSize < prevSize
&& !confGetter.getConfForScope(universe, UniverseConfKeys.allowVolumeDecrease)) {
throw new IllegalArgumentException(
"Cannot decrease volume size from " + prevSize + " to " + curSize);
}
}
}
PlacementInfoUtil.verifyNumNodesAndRF(
cluster.clusterType, cluster.userIntent.numNodes, cluster.userIntent.replicationFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,6 @@ public class UniverseConfKeys extends RuntimeConfigKeysModule {
+ " used to appropriately send 'useTablespaces' parameter to backend in API.",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.INTERNAL));
public static final ConfKeyInfo<Boolean> allowVolumeDecrease =
new ConfKeyInfo<>(
"yb.edit.allow_volume_decrease",
ScopeType.UNIVERSE,
"Allow decrease volume size",
"Allow decrease volume size for universe during full move",
ConfDataType.BooleanType,
ImmutableList.of(ConfKeyTags.INTERNAL));
public static final ConfKeyInfo<Integer> nodeAgentReinstallParallelism =
new ConfKeyInfo<>(
"yb.node_agent.reinstall_parallelism",
Expand Down
1 change: 0 additions & 1 deletion managed/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ yb {
}
edit {
wait_for_leaders_on_preferred=true
allow_volume_decrease = false
}
releases {
path = "/opt/yugabyte/releases"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import static com.yugabyte.yw.common.ApiUtils.getTestUserIntent;
import static com.yugabyte.yw.common.AssertHelper.assertJsonEqual;
import static com.yugabyte.yw.common.ModelFactory.createUniverse;
import static com.yugabyte.yw.models.TaskInfo.State.Failure;
import static com.yugabyte.yw.models.TaskInfo.State.Success;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
Expand Down Expand Up @@ -605,23 +603,4 @@ public void testEditKubernetesUniverseRetry() {
TaskType.EditKubernetesUniverse,
taskParams);
}

@Test
public void testVolumeDecreaseIsForbidden() {
setupUniverseSingleAZ(/* Create Masters */ true);
UniverseDefinitionTaskParams taskParams = new UniverseDefinitionTaskParams();
taskParams.setUniverseUUID(defaultUniverse.getUniverseUUID());
taskParams.expectedUniverseVersion = 3;
taskParams.nodeDetailsSet = defaultUniverse.getUniverseDetails().nodeDetailsSet;
UniverseDefinitionTaskParams.UserIntent newUserIntent =
defaultUniverse.getUniverseDetails().getPrimaryCluster().userIntent.clone();
newUserIntent.instanceType = "c5.xlarge";
newUserIntent.deviceInfo.volumeSize--;
RuntimeConfigEntry.upsertGlobal("yb.edit.allow_volume_decrease", "true");
PlacementInfo pi = defaultUniverse.getUniverseDetails().getPrimaryCluster().placementInfo;
TaskInfo taskInfo = submitTask(taskParams, newUserIntent, pi);
assertEquals(Failure, taskInfo.getTaskState());
assertTrue(
taskInfo.getErrorMessage().contains("Cannot decrease disk size in a Kubernetes cluster"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static com.yugabyte.yw.models.TaskInfo.State.Success;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
Expand All @@ -26,7 +25,6 @@
import com.yugabyte.yw.commissioner.Common;
import com.yugabyte.yw.common.ApiUtils;
import com.yugabyte.yw.common.PlacementInfoUtil;
import com.yugabyte.yw.common.PlatformServiceException;
import com.yugabyte.yw.common.ShellResponse;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams;
import com.yugabyte.yw.forms.UniverseDefinitionTaskParams.Cluster;
Expand Down Expand Up @@ -398,20 +396,6 @@ public void testEditUniverseRetries() {
taskParams);
}

@Test
public void testVolumeSizeValidation() {
Universe universe = defaultUniverse;
UniverseDefinitionTaskParams taskParams = performFullMove(universe);
setDumpEntitiesMock(defaultUniverse, "", false);
taskParams.getPrimaryCluster().userIntent.deviceInfo.volumeSize--;
PlatformServiceException exception =
assertThrows(PlatformServiceException.class, () -> submitTask(taskParams));
assertTrue(exception.getMessage().contains("Cannot decrease volume size from 100 to 99"));
RuntimeConfigEntry.upsertGlobal("yb.edit.allow_volume_decrease", "true");
TaskInfo taskInfo = submitTask(taskParams);
assertEquals(Success, taskInfo.getTaskState());
}

@Test
public void testVolumeSizeValidationIncNum() {
Universe universe = defaultUniverse;
Expand Down

0 comments on commit 1f42cab

Please sign in to comment.