Skip to content
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 intermittent error when deleting programs #354

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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
23 changes: 16 additions & 7 deletions controllers/bpfman-agent/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,21 +653,30 @@
return internal.Requeue, fmt.Errorf("failed to delete program from bpfman: %v", err)
}

if r.removeFinalizer(ctx, bpfProgram.GetClientObject(), rec.getFinalizer()) {
return internal.Updated, nil
}

if isBeingDeleted {
// We're deleting these programs because the *Program is being
// deleted, so update the status and the program will be deleted
// when the owner is deleted.
// deleted.

// So update the status.

Check warning on line 660 in controllers/bpfman-agent/common.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/common.go#L658-L660

Added lines #L658 - L660 were not covered by tests
if r.updateStatus(ctx, rec, &bpfProgram, cond) {
return internal.Updated, nil
}

// Then remove the finalizer, and the program will be deleted when
// the owner is deleted.
if r.removeFinalizer(ctx, bpfProgram.GetClientObject(), rec.getFinalizer()) {
return internal.Updated, nil
}

Check warning on line 669 in controllers/bpfman-agent/common.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/common.go#L667-L669

Added lines #L667 - L669 were not covered by tests
} else {
// We're deleting these programs because they were not expected due
// to changes that caused the containers to not be selected anymore.
// So, explicitly delete them.

// So, remove the finalizer.
if r.removeFinalizer(ctx, bpfProgram.GetClientObject(), rec.getFinalizer()) {
return internal.Updated, nil
}

Check warning on line 677 in controllers/bpfman-agent/common.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/common.go#L673-L677

Added lines #L673 - L677 were not covered by tests

// Then explicitly delete them.
opts := client.DeleteOptions{}
r.Logger.Info("Calling KubeAPI to delete BpfProgram", "Name", bpfProgram.GetName(), "Owner", bpfProgram.GetName())
if err := r.Delete(ctx, bpfProgram.GetClientObject(), &opts); err != nil {
Expand Down
Loading