mirror of https://github.com/kubernetes/kops.git
fix(spot/ocean): avoid unnecessary duplication of tasks
This commit is contained in:
parent
43d294f4bd
commit
5f30cdedf9
|
@ -376,9 +376,6 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs ..
|
||||||
klog.V(4).Infof("Detected default launch spec: %q", b.AutoscalingGroupName(ig))
|
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.
|
// Image.
|
||||||
ocean.ImageID = fi.String(ig.Spec.Image)
|
ocean.ImageID = fi.String(ig.Spec.Image)
|
||||||
|
|
||||||
|
@ -493,8 +490,8 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs ..
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a Launch Spec for each instance group.
|
// Create a Launch Spec for each instance group.
|
||||||
for _, ig := range igs {
|
for _, g := range igs {
|
||||||
if err := b.buildLaunchSpec(c, ig, ocean); err != nil {
|
if err := b.buildLaunchSpec(c, g, ig, ocean); err != nil {
|
||||||
return fmt.Errorf("error building launch spec: %v", err)
|
return fmt.Errorf("error building launch spec: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,7 +503,7 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs ..
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *InstanceGroupModelBuilder) buildLaunchSpec(c *fi.ModelBuilderContext,
|
func (b *InstanceGroupModelBuilder) buildLaunchSpec(c *fi.ModelBuilderContext,
|
||||||
ig *kops.InstanceGroup, ocean *spotinsttasks.Ocean) (err error) {
|
ig, igOcean *kops.InstanceGroup, ocean *spotinsttasks.Ocean) (err error) {
|
||||||
|
|
||||||
klog.V(4).Infof("Building instance group as LaunchSpec: %q", b.AutoscalingGroupName(ig))
|
klog.V(4).Infof("Building instance group as LaunchSpec: %q", b.AutoscalingGroupName(ig))
|
||||||
launchSpec := &spotinsttasks.LaunchSpec{
|
launchSpec := &spotinsttasks.LaunchSpec{
|
||||||
|
@ -544,10 +541,14 @@ func (b *InstanceGroupModelBuilder) buildLaunchSpec(c *fi.ModelBuilderContext,
|
||||||
ocean.MaxSize = fi.Int64(fi.Int64Value(ocean.MaxSize) + fi.Int64Value(maxSize))
|
ocean.MaxSize = fi.Int64(fi.Int64Value(ocean.MaxSize) + fi.Int64Value(maxSize))
|
||||||
|
|
||||||
// User data.
|
// User data.
|
||||||
|
if ig.Name == igOcean.Name {
|
||||||
|
launchSpec.UserData = ocean.UserData
|
||||||
|
} else {
|
||||||
launchSpec.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)
|
launchSpec.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error building user data: %v", err)
|
return fmt.Errorf("error building user data: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Instance profile.
|
// Instance profile.
|
||||||
launchSpec.IAMInstanceProfile, err = b.LinkToIAMInstanceProfile(ig)
|
launchSpec.IAMInstanceProfile, err = b.LinkToIAMInstanceProfile(ig)
|
||||||
|
|
Loading…
Reference in New Issue