Skip to content

Commit

Permalink
Rebase on pr #38
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Fredette <afredette@redhat.com>
  • Loading branch information
anfredette committed Jul 8, 2024
1 parent 3c4c683 commit 76440da
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions controllers/bpfman-agent/application-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
fentryObjects := []client.Object{&fentryProgram}
appProgramMap[fentryProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile FentryProgram.
complete, res, err = r.reconcileCommon(ctx, rec, fentryObjects)

Expand All @@ -117,7 +117,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
fexitObjects := []client.Object{&fexitProgram}
appProgramMap[fexitProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile FexitProgram.
complete, res, err = r.reconcileCommon(ctx, rec, fexitObjects)

Expand All @@ -140,7 +140,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
kprobeObjects := []client.Object{&kprobeProgram}
appProgramMap[kprobeProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile KprobeProgram or KpretprobeProgram.
complete, res, err = r.reconcileCommon(ctx, rec, kprobeObjects)

Expand All @@ -163,7 +163,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
uprobeObjects := []client.Object{&uprobeProgram}
appProgramMap[uprobeProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile UprobeProgram or UpretprobeProgram.
complete, res, err = r.reconcileCommon(ctx, rec, uprobeObjects)

Expand All @@ -185,7 +185,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
tracepointObjects := []client.Object{&tracepointProgram}
appProgramMap[tracepointProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile TracepointProgram.
complete, res, err = r.reconcileCommon(ctx, rec, tracepointObjects)

Expand Down Expand Up @@ -214,7 +214,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
tcObjects := []client.Object{&tcProgram}
appProgramMap[tcProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile TcProgram.
complete, res, err = r.reconcileCommon(ctx, rec, tcObjects)

Expand Down Expand Up @@ -242,7 +242,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
rec.appOwner = &a
xdpObjects := []client.Object{&xdpProgram}
appProgramMap[xdpProgram.Name] = true
appProgramMap[appProgramId] = true
// Reconcile XdpProgram.
complete, res, err = r.reconcileCommon(ctx, rec, xdpObjects)

Expand All @@ -267,15 +267,15 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
bpfPrograms := &bpfmaniov1alpha1.BpfProgramList{}
bpfDeletedPrograms := &bpfmaniov1alpha1.BpfProgramList{}
// find programs that need to be deleted and delete them
opts := []client.ListOption{client.MatchingLabels{internal.BpfProgramOwnerLabel: a.Name}}
opts := []client.ListOption{client.MatchingLabels{internal.BpfProgramOwner: a.Name}}
if err := r.List(ctx, bpfPrograms, opts...); err != nil {
ctxLogger.Error(err, "failed to get freshPrograms for full reconcile")
return ctrl.Result{}, err
}
for _, bpfProgram := range bpfPrograms.Items {
progName := bpfProgram.Labels[internal.BpfParentProgram]
if _, ok := appProgramMap[progName]; !ok {
ctxLogger.Info("Deleting BpfProgram", "BpfProgram", progName)
id := bpfProgram.Labels[internal.AppProgramId]
if _, ok := appProgramMap[id]; !ok {
ctxLogger.Info("Deleting BpfProgram", "AppProgramId", id, "BpfProgram", bpfProgram.Name)
bpfDeletedPrograms.Items = append(bpfDeletedPrograms.Items, bpfProgram)
}
}
Expand Down

0 comments on commit 76440da

Please sign in to comment.