Skip to content

Commit 27b795a

Browse files
authored
Merge pull request #10388 from sbueringer/pr-worker-count-nil
🌱 Allow setting worker machine count to nil in ApplyClusterTemplateAndWait & ConfigCluster
2 parents 1721d42 + ec6150c commit 27b795a

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

test/e2e/autoscaler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func AutoscalerSpec(ctx context.Context, inputGetter func() AutoscalerSpecInput)
127127
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
128128
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
129129
ControlPlaneMachineCount: ptr.To[int64](1),
130-
WorkerMachineCount: ptr.To[int64](0),
130+
WorkerMachineCount: nil,
131131
},
132132
ControlPlaneWaiters: input.ControlPlaneWaiters,
133133
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),

test/framework/clusterctl/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,16 @@ type ConfigClusterInput struct {
318318

319319
// ConfigCluster gets a workload cluster based on a template.
320320
func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte {
321-
log.Logf("clusterctl config cluster %s --infrastructure %s --kubernetes-version %s --control-plane-machine-count %d --worker-machine-count %d --flavor %s",
321+
var workerMachineCountArg string
322+
if input.WorkerMachineCount != nil {
323+
workerMachineCountArg = fmt.Sprintf("--worker-machine-count %d ", *input.WorkerMachineCount)
324+
}
325+
log.Logf("clusterctl config cluster %s --infrastructure %s --kubernetes-version %s --control-plane-machine-count %d %s--flavor %s",
322326
input.ClusterName,
323327
valueOrDefault(input.InfrastructureProvider),
324328
input.KubernetesVersion,
325329
*input.ControlPlaneMachineCount,
326-
*input.WorkerMachineCount,
330+
workerMachineCountArg,
327331
valueOrDefault(input.Flavor),
328332
)
329333

test/framework/clusterctl/clusterctl_helpers.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package clusterctl
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"os"
2223
"path/filepath"
2324
"time"
@@ -286,10 +287,15 @@ func ApplyClusterTemplateAndWait(ctx context.Context, input ApplyClusterTemplate
286287
Expect(input.ClusterProxy).ToNot(BeNil(), "Invalid argument. input.ClusterProxy can't be nil when calling ApplyClusterTemplateAndWait")
287288
Expect(result).ToNot(BeNil(), "Invalid argument. result can't be nil when calling ApplyClusterTemplateAndWait")
288289
Expect(input.ConfigCluster.ControlPlaneMachineCount).ToNot(BeNil())
289-
Expect(input.ConfigCluster.WorkerMachineCount).ToNot(BeNil())
290290

291-
log.Logf("Creating the workload cluster with name %q using the %q template (Kubernetes %s, %d control-plane machines, %d worker machines)",
292-
input.ConfigCluster.ClusterName, valueOrDefault(input.ConfigCluster.Flavor), input.ConfigCluster.KubernetesVersion, *input.ConfigCluster.ControlPlaneMachineCount, *input.ConfigCluster.WorkerMachineCount)
291+
var workerMachinesCount string
292+
if input.ConfigCluster.WorkerMachineCount != nil {
293+
workerMachinesCount = fmt.Sprintf("%d", *input.ConfigCluster.WorkerMachineCount)
294+
} else {
295+
workerMachinesCount = "(unset)"
296+
}
297+
log.Logf("Creating the workload cluster with name %q using the %q template (Kubernetes %s, %d control-plane machines, %s worker machines)",
298+
input.ConfigCluster.ClusterName, valueOrDefault(input.ConfigCluster.Flavor), input.ConfigCluster.KubernetesVersion, *input.ConfigCluster.ControlPlaneMachineCount, workerMachinesCount)
293299

294300
// Ensure we have a Cluster for dump and cleanup steps in AfterEach even if ApplyClusterTemplateAndWait fails.
295301
result.Cluster = &clusterv1.Cluster{

0 commit comments

Comments
 (0)