Skip to content

Commit

Permalink
Additional changes for BpfApplication object
Browse files Browse the repository at this point in the history
- Handle setting owner and object type
- If reconcile is complete with one program/object, continue with the
  next one

These changes have not been tested.  Still need to write a unit test

Signed-off-by: Andre Fredette <afredette@redhat.com>
  • Loading branch information
anfredette authored and msherif1234 committed Jun 7, 2024
1 parent 293a84f commit 051a49f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions controllers/bpfman-agent/application-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
var complete bool

for _, a := range appPrograms.Items {

Check failure on line 82 in controllers/bpfman-agent/application-program.go

View workflow job for this annotation

GitHub Actions / Build, lint, test (1.22)

expected declaration, found 'for'

Check failure on line 82 in controllers/bpfman-agent/application-program.go

View workflow job for this annotation

GitHub Actions / Build, lint, test (1.22)

expected declaration, found 'for'
complete = false
for _, p := range a.Spec.Programs {
complete = false
switch p.Type {
case bpfmaniov1alpha1.ProgTypeFentry:
fentryProgram := bpfmaniov1alpha1.FentryProgram{
Expand Down Expand Up @@ -226,8 +228,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, xdpObjects)

default:
r.Logger.Error(fmt.Errorf("Unsupported Bpf program type"), "Unsupported Bpf program type", "ProgType", p.Type)
// Skip this program and continue to the next one
r.Logger.Info("Unsupported Bpf program type", "ProgType", p.Type)
continue
}

Expand Down
6 changes: 3 additions & 3 deletions controllers/bpfman-agent/application-program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestBpfApplicationControllerCreate(t *testing.T) {
Type: bpfmaniov1alpha1.ProgTypeFentry,
Fentry: &bpfmaniov1alpha1.FentryProgramInfo{
BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{
BpfFunctionName: fentryBpfFunctionName,
BpfFunctionName: bpfFentryFunctionName,
},
FunctionName: fentryFunctionName,
},
Expand All @@ -75,7 +75,7 @@ func TestBpfApplicationControllerCreate(t *testing.T) {
Type: bpfmaniov1alpha1.ProgTypeKprobe,
Kprobe: &bpfmaniov1alpha1.KprobeProgramInfo{
BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{
BpfFunctionName: kprobeBpfFunctionName,
BpfFunctionName: bpfKprobeFunctionName,
},
FunctionName: kprobeFunctionName,
Offset: uint64(kprobeOffset),
Expand All @@ -86,7 +86,7 @@ func TestBpfApplicationControllerCreate(t *testing.T) {
Type: bpfmaniov1alpha1.ProgTypeTracepoint,
Tracepoint: &bpfmaniov1alpha1.TracepointProgramInfo{
BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{
BpfFunctionName: tracepointBpfFunctionName,
BpfFunctionName: bpfTracepointFunctionName,
},
Names: []string{tracepointName},
},
Expand Down

0 comments on commit 051a49f

Please sign in to comment.