Skip to content

Commit

Permalink
fixed cluster templates getting deleted when failing to create a clus…
Browse files Browse the repository at this point in the history
…ter (#11601)
  • Loading branch information
lsviben committed Dec 28, 2022
1 parent 24390da commit 33f6e58
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ func (r *reconciler) createClusters(ctx context.Context, instance *kubermaticv1.

for i := 0; i < int(instance.Spec.Replicas); i++ {
if err := r.createCluster(ctx, log, template, instance); err != nil {
created := int64(i + 1)
created := int64(i)
totalReplicas := instance.Spec.Replicas

if err := r.patchInstance(ctx, instance, func(i *kubermaticv1.ClusterTemplateInstance) {
if patchErr := r.patchInstance(ctx, instance, func(i *kubermaticv1.ClusterTemplateInstance) {
i.Spec.Replicas = totalReplicas - created
}); err != nil {
return err
}); patchErr != nil {
return fmt.Errorf("error patching cluster template instance (%v), after cluster creation fail: %w", patchErr, err)
}

return fmt.Errorf("failed to create desired number of clusters. Created %d of %d", created, totalReplicas)
return fmt.Errorf("failed to create desired number of clusters. Created %d of %d: %w", created, totalReplicas, err)
}
}
}
Expand Down

0 comments on commit 33f6e58

Please sign in to comment.