cleanup code

This commit is contained in:
Rodrigo Menezes 2020-10-28 11:11:58 -07:00
parent 9bd0a7aedb
commit 41adf07e15
2 changed files with 12 additions and 27 deletions

View File

@ -74,7 +74,7 @@ has been updated by a newer version of kops unless it is given the `--allow-kops
* See note about [Openstack Cinder plugin](#openstack-cinder-plugin) above.
* Terraform users, in order to prevent downtime you will have to remove the state of the existing ELB attatchments from your terraform state file. This is due to us migrating to setting the loadbalancer attatchment when defining the ASG resource. The migration was required due to a bug described in #9913.
* Terraform users, in order to prevent downtime you will have to remove the state of any existing ELB or TargetGroup attatchments from your Terraform state file. This is due to migrating the attachments to the in-line `aws_autoscaling_group` fields. See the [terraform documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group) for more information about the difference. This migration is required due to a bug described in [#9913](https://github.com/kubernetes/kops/issues/9913).
To prevent downtime, follow these steps with the new version of Kops:
```

View File

@ -91,10 +91,6 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
}
c.AddTask(tsk)
// @step: add any external load balancer attachments
if err := b.buildExternalLoadBalancerTasks(c, ig); err != nil {
return err
}
}
return nil
@ -369,10 +365,21 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.ModelBuil
for _, extLB := range ig.Spec.ExternalLoadBalancers {
if extLB.LoadBalancerName != nil {
t.LoadBalancers = append(t.LoadBalancers, &awstasks.LoadBalancer{Name: extLB.LoadBalancerName})
c.AddTask(&awstasks.LoadBalancer{
Name: extLB.LoadBalancerName,
Shared: fi.Bool(true),
})
}
if extLB.TargetGroupARN != nil {
t.TargetGroups = append(t.TargetGroups, &awstasks.TargetGroup{Name: extLB.TargetGroupARN, ARN: extLB.TargetGroupARN})
c.AddTask(&awstasks.TargetGroup{
Name: extLB.TargetGroupARN,
ARN: extLB.TargetGroupARN,
Shared: fi.Bool(true),
})
}
}
@ -391,25 +398,3 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.ModelBuil
return t, nil
}
// buildExternlLoadBalancerTasks is responsible for adding any ELB attachment tasks to the model
func (b *AutoscalingGroupModelBuilder) buildExternalLoadBalancerTasks(c *fi.ModelBuilderContext, ig *kops.InstanceGroup) error {
for _, x := range ig.Spec.ExternalLoadBalancers {
if x.LoadBalancerName != nil {
c.AddTask(&awstasks.LoadBalancer{
Name: x.LoadBalancerName,
Shared: fi.Bool(true),
})
}
if x.TargetGroupARN != nil {
c.AddTask(&awstasks.TargetGroup{
Name: x.TargetGroupARN,
ARN: x.TargetGroupARN,
Shared: fi.Bool(true),
})
}
}
return nil
}