Skip to content

Commit

Permalink
bug fix for edge cases not covered by pod readness gate PR kubernetes…
Browse files Browse the repository at this point in the history
  • Loading branch information
M00nF1sh committed Mar 22, 2020
1 parent 61acd6a commit 0dbd870
Show file tree
Hide file tree
Showing 5 changed files with 780 additions and 3 deletions.
23 changes: 23 additions & 0 deletions internal/alb/tg/targetgroup_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,29 @@ func TestDefaultGroupController_GC(t *testing.T) {
},
},
},
{
Name: "GC succeeds without deleting externalTargetArn even it's created by controller",
TGGroup: TargetGroupGroup{
TGByBackend: map[extensions.IngressBackend]TargetGroup{
{
ServiceName: "service1",
ServicePort: intstr.FromInt(80),
}: {Arn: "arn1"},
},
externalTGARNs: []string{"arn3"},
selector: map[string]string{"key1": "value1", "key2": "value2"},
},
GetResourcesByFiltersCall: &GetResourcesByFiltersCall{
TagFilters: map[string][]string{"key1": {"value1"}, "key2": {"value2"}},
ResourceType: aws.ResourceTypeEnumELBTargetGroup,
Arns: []string{"arn1", "arn2", "arn3"},
},
DeleteTargetGroupByArnCalls: []DeleteTargetGroupByArnCall{
{
Arn: "arn2",
},
},
},
{
Name: "GC failed when fetch current targetGroups",
TGGroup: TargetGroupGroup{
Expand Down
5 changes: 4 additions & 1 deletion internal/alb/tg/targethealth.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (c *targetHealthController) reconcilePodConditionsLoop(ctx context.Context,

// For each given pod, checks for the health status of the corresponding target in the target group and adds/updates a pod condition that can be used for pod readiness gates.
func (c *targetHealthController) reconcilePodConditions(ctx context.Context, tgArn string, conditionType api.PodConditionType, ingress *extensions.Ingress, backend *extensions.IngressBackend, targetsToReconcile []*elbv2.TargetDescription) ([]*elbv2.TargetDescription, error) {
notReadyTargets := []*elbv2.TargetDescription{}
var notReadyTargets []*elbv2.TargetDescription

in := &elbv2.DescribeTargetHealthInput{
TargetGroupArn: aws.String(tgArn),
Expand All @@ -202,6 +202,9 @@ func (c *targetHealthController) reconcilePodConditions(ctx context.Context, tgA

for i, target := range targetsToReconcile {
pod := pods[i]
if pod == nil {
continue
}
targetHealth, ok := targetsHealth[pod.Status.PodIP]
if ok && podHasReadinessGate(pod, conditionType) {
if aws.StringValue(targetHealth.State) != elbv2.TargetHealthStateEnumHealthy {
Expand Down
Loading

0 comments on commit 0dbd870

Please sign in to comment.