From 549a704b15d96032f6839125e6a4f08264b25b7e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 27 Mar 2019 23:28:36 -0700 Subject: [PATCH] pkg/asset/machines/worker: Default to MachineSets only where we need them And not for additional zones. This will keep us from consuming more NAT gateways and associated EIPs than we need, once subsequent work ties those resources to Machine(Set) consumption. This means that pools where replicas is unset or zero will receive no MachineSets, but creating MachineSets later on is something we want to be easy anyway, so I don't see a need to require the installer to inject a template MachineSet into the cluster. --- pkg/asset/machines/worker.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/asset/machines/worker.go b/pkg/asset/machines/worker.go index 63b244ef27e..7cb7f0778d8 100644 --- a/pkg/asset/machines/worker.go +++ b/pkg/asset/machines/worker.go @@ -128,12 +128,15 @@ func (w *Worker) Generate(dependencies asset.Parents) error { mpool.InstanceType = awsDefaultWorkerMachineType(installconfig) mpool.Set(ic.Platform.AWS.DefaultMachinePlatform) mpool.Set(pool.Platform.AWS) - if len(mpool.Zones) == 0 { + if pool.Replicas != nil && *pool.Replicas > 0 && len(mpool.Zones) == 0 { azs, err := aws.AvailabilityZones(ic.Platform.AWS.Region) if err != nil { return errors.Wrap(err, "failed to fetch availability zones") } mpool.Zones = azs + if int(*pool.Replicas) < len(mpool.Zones) { + mpool.Zones = azs[:*pool.Replicas] + } } pool.Platform.AWS = &mpool sets, err := aws.MachineSets(clusterID.InfraID, ic, &pool, string(*rhcosImage), "worker", "worker-user-data")