Skip to content

Commit 6d61154

Browse files
authored
Merge pull request #461 from kubernetes-sigs/podbugfix
Fixing a bug where we deregister pod targets on updates
2 parents cb67384 + 8abda38 commit 6d61154

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

pkg/alb/tg/targetgroup.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (t *TargetGroup) create(rOpts *ReconcileOptions) error {
242242
rOpts.Eventf(api.EventTypeWarning, "ERROR", "Error registering targets to target group %s: %s", t.ID, err.Error())
243243
return fmt.Errorf("Failed TargetGroup creation. Unable to register targets: %s.", err.Error())
244244
}
245+
t.targets.current = t.targets.desired
245246

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

435-
t.targets.current = t.targets.desired
436-
437436
// when managing security groups, ensure sg is associated with instance
438437
if rOpts.ManagedSGInstance != nil {
439438
err := albec2.EC2svc.AssociateSGToInstanceIfNeeded(additions, rOpts.ManagedSGInstance)
@@ -456,8 +455,6 @@ func (t *TargetGroup) deregisterTargets(removals albelbv2.TargetDescriptions, rO
456455
return err
457456
}
458457

459-
t.targets.current = t.targets.desired
460-
461458
// when managing security groups, ensure sg is disassociated with instance
462459
if rOpts.ManagedSGInstance != nil {
463460
err := albec2.EC2svc.DisassociateSGFromInstanceIfNeeded(removals, rOpts.ManagedSGInstance)

pkg/alb/tg/targetgroups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func NewDesiredTargetGroups(o *NewDesiredTargetGroupsOptions) (TargetGroups, err
177177
output[i].copyDesiredState(targetGroup)
178178

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

0 commit comments

Comments
 (0)