From 0cfa2bb6a7878825a8fa5559dae18eaff5d297b1 Mon Sep 17 00:00:00 2001 From: liranp Date: Thu, 6 Aug 2020 19:22:00 +0300 Subject: [PATCH] fix(spot/ocean): default instance group should be optional --- pkg/model/spotinstmodel/instance_group.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/model/spotinstmodel/instance_group.go b/pkg/model/spotinstmodel/instance_group.go index 75f9481bc9..6276b3a262 100644 --- a/pkg/model/spotinstmodel/instance_group.go +++ b/pkg/model/spotinstmodel/instance_group.go @@ -323,7 +323,7 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs .. { // Single instance group. if len(igs) == 1 { - ig = igs[0] + ig = igs[0].DeepCopy() } // Multiple instance groups. @@ -343,22 +343,25 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs .. InstanceGroupLabelOceanDefaultLaunchSpec) } - ig = g + ig = g.DeepCopy() break } } } } + + // No default instance group. Use the first one. if ig == nil { - return fmt.Errorf("unable to detect default launch spec: "+ - "please label the desired default instance group with `%s: \"true\"`", - InstanceGroupLabelOceanDefaultLaunchSpec) + ig = igs[0].DeepCopy() } } klog.V(4).Infof("Detected default launch spec: %q", b.AutoscalingGroupName(ig)) } + // Rename the instance group to avoid duplicate tasks with same name. + ig.Name = fi.StringValue(ocean.Name) + // Image. ocean.ImageID = fi.String(ig.Spec.Image)