Skip to content

Commit

Permalink
Merge pull request #3296 from michaelsaah/issue-3285-fix
Browse files Browse the repository at this point in the history
don't block TGB reconciliation loop on failed SG ingress reconciliation
  • Loading branch information
k8s-ci-robot authored Aug 30, 2023
2 parents 2be7cec + 4607bb4 commit 4e697f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/k8s/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
TargetGroupBindingEventReasonFailedRemoveFinalizer = "FailedRemoveFinalizer"
TargetGroupBindingEventReasonFailedUpdateStatus = "FailedUpdateStatus"
TargetGroupBindingEventReasonFailedCleanup = "FailedCleanup"
TargetGroupBindingEventReasonFailedNetworkReconcile = "FailedNetworkReconcile"
TargetGroupBindingEventReasonBackendNotFound = "BackendNotFound"
TargetGroupBindingEventReasonSuccessfullyReconciled = "SuccessfullyReconciled"
)
10 changes: 9 additions & 1 deletion pkg/targetgroupbinding/networking_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"strings"
"sync"
libErrors "errors"

awssdk "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down Expand Up @@ -199,11 +200,13 @@ func (m *defaultNetworkingManager) reconcileWithIngressPermissionsPerSG(ctx cont
aggregatedIngressPermissionsPerSG := m.computeAggregatedIngressPermissionsPerSG(ctx)

permissionSelector := labels.SelectorFromSet(labels.Set{tgbNetworkingIPPermissionLabelKey: tgbNetworkingIPPermissionLabelValue})
var sgReconciliationErrors []error
for sgID, permissions := range aggregatedIngressPermissionsPerSG {
if err := m.sgReconciler.ReconcileIngress(ctx, sgID, permissions,
networking.WithPermissionSelector(permissionSelector),
networking.WithAuthorizeOnly(!computedForAllTGBs)); err != nil {
return err
sgReconciliationErrors = append(sgReconciliationErrors, err)
continue
}
}

Expand All @@ -213,6 +216,11 @@ func (m *defaultNetworkingManager) reconcileWithIngressPermissionsPerSG(ctx cont
}
}

if len(sgReconciliationErrors) > 0 {
err := libErrors.Join(sgReconciliationErrors...)
return err
}

return nil
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/targetgroupbinding/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ func (m *defaultResourceManager) reconcileWithIPTargetType(ctx context.Context,
notDrainingTargets, drainingTargets := partitionTargetsByDrainingStatus(targets)
matchedEndpointAndTargets, unmatchedEndpoints, unmatchedTargets := matchPodEndpointWithTargets(endpoints, notDrainingTargets)

needNetworkingRequeue := false
if err := m.networkingManager.ReconcileForPodEndpoints(ctx, tgb, endpoints); err != nil {
return err
m.eventRecorder.Event(tgb, corev1.EventTypeWarning, k8s.TargetGroupBindingEventReasonFailedNetworkReconcile, err.Error())
needNetworkingRequeue = true
}
if len(unmatchedTargets) > 0 {
if err := m.deregisterTargets(ctx, tgARN, unmatchedTargets); err != nil {
Expand Down Expand Up @@ -167,6 +169,10 @@ func (m *defaultResourceManager) reconcileWithIPTargetType(ctx context.Context,
}

_ = drainingTargets

if needNetworkingRequeue {
return runtime.NewRequeueNeeded("networking reconciliation")
}
return nil
}

Expand Down

0 comments on commit 4e697f8

Please sign in to comment.