Skip to content

don't block TGB reconciliation loop on failed SG ingress reconciliation #3296

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 4 commits into from
Aug 30, 2023
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
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