-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix race condition in strict mode #306
Fix race condition in strict mode #306
Conversation
Generic Q: How is the BPF prog delete going through when the said prog is still (loaded &) attached to another active pod interface on the same node? |
@@ -197,6 +197,33 @@ func (r *PolicyEndpointsReconciler) cleanUpPolicyEndpoint(ctx context.Context, r | |||
return nil | |||
} | |||
|
|||
func (r *PolicyEndpointsReconciler) isProgFdShared(ctx context.Context, targetPodName string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can optimize this as a pod will always have both ingress and egress probes attached (i.e.,) there will never be a scenario where only one of the probes is attached for any particular pod. Probably can collapse the maps in to one unless there are plans to use them for something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achevuru Yeah using one just one map to store reverse mapping from progFds to Pods list makes sense. I will just add the ingress one and we can remove the new egress map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will update this optimization in a separate PR as this is change is blocking cx
We are assuming it is not being shared by any other active pod by verifying policy endpoint list. But when a new pod is created and not yet reconciled in strict mode, we are attaching the probes and updating the maps but pod is not yet present in policy endpoint list https://github.com/aws/aws-network-policy-agent/blob/main/pkg/rpc/rpc_handler.go#L74
|
Nice to hear from you @achevuru :) To summarize with Strict mode when we get |
@@ -211,11 +238,10 @@ func (r *PolicyEndpointsReconciler) updatePolicyEnforcementStatusForPods(ctx con | |||
deletePinPath := true | |||
podIdentifier := utils.GetPodIdentifier(targetPod.Name, targetPod.Namespace, r.log) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need podIdentifier? Seems like only used in the below log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can remove that one. I will add optimization and clean up of this line in next PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do the cleanup post merge. We should also have a way to dump all these internal structures maybe via cli to debug any issues..
Agree. Logging these structs will help us in debugging. I will add a task and follow up on this |
Issue #, if available:
Fixing a race condition where shared ebpf maps are being deleted in strict mode
Description of changes:
Added new map to store progFD to pods mapping which will help us check if progFD's are being shared between pods
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.