Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to detect field changes when mixedInstancePolicy is removed #11255

Merged
merged 2 commits into from
Apr 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
return req.MixedInstancesPolicy
}

if changes.LaunchTemplate != nil {
// We have to update LaunchTemplate to remove mixedInstancesPolicy when it is removed from spec.
if changes.LaunchTemplate != nil || a.UseMixedInstancesPolicy() && !e.UseMixedInstancesPolicy() {
spec := &autoscaling.LaunchTemplateSpecification{
LaunchTemplateId: e.LaunchTemplate.ID,
Version: aws.String("$Latest"),
Expand Down
8 changes: 5 additions & 3 deletions upup/pkg/fi/dryrun_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,16 @@ func buildChangeList(a, e, changes Task) ([]change, error) {
}

fieldValC := valC.Field(i)
fieldValE := valE.Field(i)
fieldValA := valA.Field(i)

changed := true
switch fieldValC.Kind() {
case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map:
changed = !fieldValC.IsNil()
if fieldValC.IsNil() && !fieldValA.IsNil() && fieldValE.IsNil() {
changed = true
}

case reflect.String:
changed = fieldValC.Interface().(string) != ""
Expand All @@ -320,12 +325,9 @@ func buildChangeList(a, e, changes Task) ([]change, error) {
continue
}

fieldValE := valE.Field(i)

description := ""
ignored := false
if fieldValE.CanInterface() {
fieldValA := valA.Field(i)

switch fieldValE.Interface().(type) {
//case SimpleUnit:
Expand Down