Skip to content

Fixing a bug where we deregister pod targets on updates #461

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

Merged
merged 1 commit into from
Jul 16, 2018
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
5 changes: 1 addition & 4 deletions pkg/alb/tg/targetgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func (t *TargetGroup) create(rOpts *ReconcileOptions) error {
rOpts.Eventf(api.EventTypeWarning, "ERROR", "Error registering targets to target group %s: %s", t.ID, err.Error())
return fmt.Errorf("Failed TargetGroup creation. Unable to register targets: %s.", err.Error())
}
t.targets.current = t.targets.desired

if len(t.attributes.desired) > 0 {
// Add TargetGroup attributes
Expand Down Expand Up @@ -432,8 +433,6 @@ func (t *TargetGroup) registerTargets(additions albelbv2.TargetDescriptions, rOp
return err
}

t.targets.current = t.targets.desired

// when managing security groups, ensure sg is associated with instance
if rOpts.ManagedSGInstance != nil {
err := albec2.EC2svc.AssociateSGToInstanceIfNeeded(additions, rOpts.ManagedSGInstance)
Expand All @@ -456,8 +455,6 @@ func (t *TargetGroup) deregisterTargets(removals albelbv2.TargetDescriptions, rO
return err
}

t.targets.current = t.targets.desired

// when managing security groups, ensure sg is disassociated with instance
if rOpts.ManagedSGInstance != nil {
err := albec2.EC2svc.DisassociateSGFromInstanceIfNeeded(removals, rOpts.ManagedSGInstance)
Expand Down
2 changes: 1 addition & 1 deletion pkg/alb/tg/targetgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func NewDesiredTargetGroups(o *NewDesiredTargetGroupsOptions) (TargetGroups, err
output[i].copyDesiredState(targetGroup)

// If there is a current TG ARN we can use it to purge the desired targets of unready instances
if output[i].CurrentARN() != nil {
if output[i].CurrentARN() != nil && *tgAnnotations.TargetType == "instance" {
desired, err := albelbv2.ELBV2svc.DescribeTargetGroupTargetsForArn(output[i].CurrentARN(), output[i].targets.desired)
if err != nil {
return nil, err
Expand Down