Skip to content

Commit 94eeb5d

Browse files
committed
Improve error handling around compact-cluster installs
Worker machinesets generated, during create manifests can be deleted before creating the cluster. Detect this case and take action based on whether masters are marked as schedulable. This fixes compact cluster installs on GCP, AWS and Azure.
1 parent 54d9c8e commit 94eeb5d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pkg/asset/cluster/tfvars/tfvars.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
272272
if err != nil {
273273
return err
274274
}
275+
// Based on the number of workers, we could have the following outcomes:
276+
// 1. workers > 0, masters not schedulable, valid cluster
277+
// 2. workers = 0, masters schedulable, valid compact cluster but currently unsupported
278+
// 3. workers = 0, masters not schedulable, invalid cluster
279+
if len(workers) == 0 {
280+
return errors.Errorf("compact clusters with 0 workers are not supported at this time")
281+
}
275282
workerConfigs := make([]*machinev1beta1.AWSMachineProviderConfig, len(workers))
276283
for i, m := range workers {
277284
workerConfigs[i] = m.Spec.Template.Spec.ProviderSpec.Value.Object.(*machinev1beta1.AWSMachineProviderConfig) //nolint:errcheck // legacy, pre-linter
@@ -370,6 +377,13 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
370377
if err != nil {
371378
return err
372379
}
380+
// Based on the number of workers, we could have the following outcomes:
381+
// 1. workers > 0, masters not schedulable, valid cluster
382+
// 2. workers = 0, masters schedulable, valid compact cluster but currently unsupported
383+
// 3. workers = 0, masters not schedulable, invalid cluster
384+
if len(workers) == 0 {
385+
return errors.Errorf("compact clusters with 0 workers are not supported at this time")
386+
}
373387
workerConfigs := make([]*machinev1beta1.AzureMachineProviderSpec, len(workers))
374388
for i, w := range workers {
375389
workerConfigs[i] = w.Spec.Template.Spec.ProviderSpec.Value.Object.(*machinev1beta1.AzureMachineProviderSpec) //nolint:errcheck // legacy, pre-linter
@@ -485,6 +499,13 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
485499
if err != nil {
486500
return err
487501
}
502+
// Based on the number of workers, we could have the following outcomes:
503+
// 1. workers > 0, masters not schedulable, valid cluster
504+
// 2. workers = 0, masters schedulable, valid compact cluster but currently unsupported
505+
// 3. workers = 0, masters not schedulable, invalid cluster
506+
if len(workers) == 0 {
507+
return errors.Errorf("compact clusters with 0 workers are not supported at this time")
508+
}
488509
workerConfigs := make([]*machinev1beta1.GCPMachineProviderSpec, len(workers))
489510
for i, w := range workers {
490511
workerConfigs[i] = w.Spec.Template.Spec.ProviderSpec.Value.Object.(*machinev1beta1.GCPMachineProviderSpec) //nolint:errcheck // legacy, pre-linter

0 commit comments

Comments
 (0)