Skip to content

Commit d802540

Browse files
committed
fix(azure): default dual-pool autoscaling
Explicitly enable autoscaling for Azure Batch Forge head and worker pools when their disable flags are omitted. Closes #658
1 parent 06b7576 commit d802540

2 files changed

Lines changed: 59 additions & 5 deletions

File tree

src/main/java/io/seqera/tower/cli/commands/computeenvs/platforms/AzBatchForgePlatform.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,27 @@ public AzBatchConfig computeConfig(Long workspaceId, CredentialsApi credentialsA
128128
}
129129

130130
if (dualPool) {
131-
AzBatchPoolConfig headPool = new AzBatchPoolConfig();
131+
AzBatchPoolConfig headPool = new AzBatchPoolConfig()
132+
.autoScale(true);
132133
if (headPoolOpts != null) {
133134
headPool.vmType(headPoolOpts.headVmType);
134135
headPool.vmCount(headPoolOpts.headVmCount);
135-
headPool.autoScale(headPoolOpts.headNoAutoScale != null ? !headPoolOpts.headNoAutoScale : null);
136+
if (headPoolOpts.headNoAutoScale != null) {
137+
headPool.autoScale(!headPoolOpts.headNoAutoScale);
138+
}
136139
if (headPoolOpts.headBootDiskSizeGb != null) {
137140
headPool.bootDiskSizeGB(headPoolOpts.headBootDiskSizeGb);
138141
}
139142
}
140143

141-
AzBatchPoolConfig workerPool = new AzBatchPoolConfig();
144+
AzBatchPoolConfig workerPool = new AzBatchPoolConfig()
145+
.autoScale(true);
142146
if (workerPoolOpts != null) {
143147
workerPool.vmType(workerPoolOpts.workerVmType);
144148
workerPool.vmCount(workerPoolOpts.workerVmCount);
145-
workerPool.autoScale(workerPoolOpts.workerNoAutoScale != null ? !workerPoolOpts.workerNoAutoScale : null);
149+
if (workerPoolOpts.workerNoAutoScale != null) {
150+
workerPool.autoScale(!workerPoolOpts.workerNoAutoScale);
151+
}
146152
if (workerPoolOpts.workerBootDiskSizeGb != null) {
147153
workerPool.bootDiskSizeGB(workerPoolOpts.workerBootDiskSizeGb);
148154
}

src/test/java/io/seqera/tower/cli/computeenvs/platforms/AzBatchForgePlatformTest.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void testAddDualPoolWithBootDiskSize(MockServerClient mock) {
117117
);
118118

119119
mock.when(
120-
request().withMethod("POST").withPath("/compute-envs").withBody(JsonBody.json("{\"computeEnv\":{\"name\":\"azure\",\"platform\":\"azure-batch\",\"config\":{\"workDir\":\"az://nextflow-ci/jordeu\",\"region\":\"europe\",\"forge\":{\"disposeOnDeletion\":true,\"bootDiskSizeGB\":100,\"headPool\":{\"bootDiskSizeGB\":50},\"workerPool\":{\"bootDiskSizeGB\":200}}},\"credentialsId\":\"57Ic6reczFn78H1DTaaXkp\"}}")), exactly(1)
120+
request().withMethod("POST").withPath("/compute-envs").withBody(JsonBody.json("{\"computeEnv\":{\"name\":\"azure\",\"platform\":\"azure-batch\",\"config\":{\"workDir\":\"az://nextflow-ci/jordeu\",\"region\":\"europe\",\"forge\":{\"disposeOnDeletion\":true,\"bootDiskSizeGB\":100,\"headPool\":{\"autoScale\":true,\"bootDiskSizeGB\":50},\"workerPool\":{\"autoScale\":true,\"bootDiskSizeGB\":200}}},\"credentialsId\":\"57Ic6reczFn78H1DTaaXkp\"}}")), exactly(1)
121121
).respond(
122122
response().withStatusCode(200).withBody("{\"computeEnvId\":\"isnEDBLvHDAIteOEF44ow\"}").withContentType(MediaType.APPLICATION_JSON)
123123
);
@@ -129,4 +129,52 @@ void testAddDualPoolWithBootDiskSize(MockServerClient mock) {
129129
assertEquals(0, out.exitCode);
130130
}
131131

132+
@Test
133+
void testAddDualPoolEnablesAutoscalingByDefault(MockServerClient mock) {
134+
135+
mock.reset();
136+
137+
mock.when(
138+
request().withMethod("GET").withPath("/credentials").withQueryStringParameter("platformId", "azure-batch"), exactly(1)
139+
).respond(
140+
response().withStatusCode(200).withBody("{\"credentials\":[{\"id\":\"57Ic6reczFn78H1DTaaXkp\",\"name\":\"azure\",\"description\":null,\"discriminator\":\"azure\",\"baseUrl\":null,\"category\":null,\"deleted\":null,\"lastUsed\":null,\"dateCreated\":\"2021-09-07T13:50:21Z\",\"lastUpdated\":\"2021-09-07T13:50:21Z\"}]}").withContentType(MediaType.APPLICATION_JSON)
141+
);
142+
143+
mock.when(
144+
request().withMethod("POST").withPath("/compute-envs").withBody(JsonBody.json("{\"computeEnv\":{\"name\":\"azure\",\"platform\":\"azure-batch\",\"config\":{\"workDir\":\"az://nextflow-ci/jordeu\",\"region\":\"europe\",\"forge\":{\"disposeOnDeletion\":true,\"headPool\":{\"vmCount\":8,\"autoScale\":true},\"workerPool\":{\"vmCount\":32,\"autoScale\":true}}},\"credentialsId\":\"57Ic6reczFn78H1DTaaXkp\"}}")), exactly(1)
145+
).respond(
146+
response().withStatusCode(200).withBody("{\"computeEnvId\":\"isnEDBLvHDAIteOEF44ow\"}").withContentType(MediaType.APPLICATION_JSON)
147+
);
148+
149+
ExecOut out = exec(mock, "compute-envs", "add", "azure-batch", "forge", "-n", "azure", "-l", "europe", "--work-dir", "az://nextflow-ci/jordeu", "--dual-pool", "--head-vm-count", "8", "--worker-vm-count", "32");
150+
151+
assertEquals("", out.stdErr);
152+
assertEquals(new ComputeEnvAdded("azure-batch", "isnEDBLvHDAIteOEF44ow", "azure", null, USER_WORKSPACE_NAME).toString(), out.stdOut);
153+
assertEquals(0, out.exitCode);
154+
}
155+
156+
@Test
157+
void testAddDualPoolDisablesAutoscalingExplicitly(MockServerClient mock) {
158+
159+
mock.reset();
160+
161+
mock.when(
162+
request().withMethod("GET").withPath("/credentials").withQueryStringParameter("platformId", "azure-batch"), exactly(1)
163+
).respond(
164+
response().withStatusCode(200).withBody("{\"credentials\":[{\"id\":\"57Ic6reczFn78H1DTaaXkp\",\"name\":\"azure\",\"description\":null,\"discriminator\":\"azure\",\"baseUrl\":null,\"category\":null,\"deleted\":null,\"lastUsed\":null,\"dateCreated\":\"2021-09-07T13:50:21Z\",\"lastUpdated\":\"2021-09-07T13:50:21Z\"}]}").withContentType(MediaType.APPLICATION_JSON)
165+
);
166+
167+
mock.when(
168+
request().withMethod("POST").withPath("/compute-envs").withBody(JsonBody.json("{\"computeEnv\":{\"name\":\"azure\",\"platform\":\"azure-batch\",\"config\":{\"workDir\":\"az://nextflow-ci/jordeu\",\"region\":\"europe\",\"forge\":{\"disposeOnDeletion\":true,\"headPool\":{\"autoScale\":false},\"workerPool\":{\"autoScale\":false}}},\"credentialsId\":\"57Ic6reczFn78H1DTaaXkp\"}}")), exactly(1)
169+
).respond(
170+
response().withStatusCode(200).withBody("{\"computeEnvId\":\"isnEDBLvHDAIteOEF44ow\"}").withContentType(MediaType.APPLICATION_JSON)
171+
);
172+
173+
ExecOut out = exec(mock, "compute-envs", "add", "azure-batch", "forge", "-n", "azure", "-l", "europe", "--work-dir", "az://nextflow-ci/jordeu", "--dual-pool", "--head-no-auto-scale", "--worker-no-auto-scale");
174+
175+
assertEquals("", out.stdErr);
176+
assertEquals(new ComputeEnvAdded("azure-batch", "isnEDBLvHDAIteOEF44ow", "azure", null, USER_WORKSPACE_NAME).toString(), out.stdOut);
177+
assertEquals(0, out.exitCode);
178+
}
179+
132180
}

0 commit comments

Comments
 (0)