-
Notifications
You must be signed in to change notification settings - Fork 19
handle update app object by removing an existing program #38
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
- Coverage 27.08% 26.92% -0.17%
==========================================
Files 81 81
Lines 6844 6897 +53
==========================================
+ Hits 1854 1857 +3
- Misses 4806 4856 +50
Partials 184 184
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thanks for doing this! It looks pretty good, but I have a few comments.
@@ -74,6 +74,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque | |||
} | |||
|
|||
for i, a := range appPrograms.Items { | |||
var appProgramMap = make(map[string][]client.Object) |
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.
Since we just need to know whether the app program exists, and don't actually need the object, you can make this map[string]bool
and just set the entry to true
.
@@ -633,6 +633,31 @@ func (r *ReconcilerCommon) handleProgDelete( | |||
return internal.Unchanged, nil | |||
} | |||
|
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.
// unloadAndDeletePrograms unloads and deletes BbpPrograms when the owning
// *Program or BpfApplication is not being deleted itself, but something
// has change such that the BpfPrograms are no longer needed.
controllers/bpfman-agent/common.go
Outdated
@@ -633,6 +633,31 @@ func (r *ReconcilerCommon) handleProgDelete( | |||
return internal.Unchanged, nil | |||
} | |||
|
|||
func (r *ReconcilerCommon) unloadAndDeleteApplicationProgramsList(ctx context.Context, bpfDeletedPrograms *bpfmaniov1alpha1.BpfProgramList) error { |
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.
func (r *ReconcilerCommon) unloadAndDeleteApplicationProgramsList(ctx context.Context, bpfDeletedPrograms *bpfmaniov1alpha1.BpfProgramList) error { | |
func (r *ReconcilerCommon) unloadAndDeleteBpfPrograms(ctx context.Context, bpfProgramList *bpfmaniov1alpha1.BpfProgramList) error { |
This can also be used by handleProgCreateOrUpdate() to delete the extra BpfPrograms
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.
"bpfDeletedPrograms" doesn't seem right because they aren't deleted yet.
controllers/bpfman-agent/common.go
Outdated
return err | ||
} | ||
|
||
r.removeFinalizer(ctx, &bpfProgram, internal.BpfApplicationControllerFinalizer) |
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 know it's inefficient, but the way the current controller is implemented, every time we make a change to a BpfProgram object, we exit. For example, from handleProgDelete:
if r.removeFinalizer(ctx, &bpfProgram, rec.getFinalizer()) {
return internal.Updated, nil
}
r.Logger.Info("Deleting bpfProgram", "Name", bpfProgram.Name, "Owner", bpfProgram.GetName()) | ||
if err := r.Delete(ctx, &bpfProgram, &opts); err != nil { | ||
return fmt.Errorf("failed to delete bpfProgram object: %v", err) | ||
} |
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 would return here too on success.
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 have some ideas about changing that behavior, but I think we should keep it as is. The reason is that as soon as you make a change, the manager calls Reconcile() again, and if we don't stop, we end up with a Reconcile storm. That's the theory anyway.
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.
so u wanted to delete one program at a time that is why the return ?
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.
That's what ends up happening, but I'd like to look at changing that behavior.
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 this behavior isn't great I watched app sample configs with 6 hooks takes ~30s to complete
febdea7
to
379b9d0
Compare
38e21e8
to
2b538e2
Compare
Signed-off-by: Mohamed Mahmoud <[email protected]>
2b538e2
to
b3c925c
Compare
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.
LGTM
Signed-off-by: Andre Fredette <[email protected]>
Signed-off-by: Andre Fredette <[email protected]>
…84197785d29f23b4 [Snyk] Security upgrade golang from 1.6 to 1.23.1
fix #29
1- deploy app example
oc create -f config/samples/bpfman.io_v1alpha1_bpfapplication.yaml
2- edit app object and remove
kprobe
oc edit bpfapplication bpfapplication-sample
3- add back kprobe