Skip to content

Commit

Permalink
check invalid TG ARN when deleting TGB
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviassss committed Jan 11, 2022
1 parent e211bfc commit 6f665fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion apis/elbv2/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apis/elbv2/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/targetgroupbinding/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ func (m *defaultResourceManager) cleanupTargets(ctx context.Context, tgb *elbv2a
if err != nil {
if isELBV2TargetGroupNotFoundError(err) {
return nil
} else if isELBV2TargetGroupARNInvalidError(err) {
return nil
}
return err
}
if err := m.deregisterTargets(ctx, tgb.Spec.TargetGroupARN, targets); err != nil {
if isELBV2TargetGroupNotFoundError(err) {
return nil
} else if isELBV2TargetGroupARNInvalidError(err) {
return nil
}
return err
}
Expand Down Expand Up @@ -506,3 +510,11 @@ func isELBV2TargetGroupNotFoundError(err error) bool {
}
return false
}

func isELBV2TargetGroupARNInvalidError(err error) bool {
var awsErr awserr.Error
if errors.As(err, &awsErr) {
return awsErr.Code() == "ValidationError"
}
return false
}

0 comments on commit 6f665fd

Please sign in to comment.