@@ -24,6 +24,7 @@ import (
24
24
bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
25
25
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
26
26
"github.com/bpfman/bpfman-operator/internal"
27
+ "github.com/bpfman/bpfman-operator/pkg/helpers"
27
28
gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
28
29
29
30
v1 "k8s.io/api/core/v1"
@@ -109,7 +110,7 @@ func (r *ClBpfApplicationReconciler) SetupWithManager(mgr ctrl.Manager) error {
109
110
builder .WithPredicates (predicate .And (predicate.LabelChangedPredicate {}, nodePredicate (r .NodeName ))),
110
111
).
111
112
// Watch for changes in Pod resources in case we are using a container
112
- // or network namepsce selector.
113
+ // or network namespace selector.
113
114
Watches (
114
115
& v1.Pod {},
115
116
& handler.EnqueueRequestForObject {},
@@ -241,12 +242,13 @@ func (r *ClBpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Req
241
242
r .Logger .Info ("Successfully reconciled program" , "Name" , rec .getProgName ())
242
243
}
243
244
}
245
+ }
244
246
245
- // If the bpfApplicationStatus didn't get changed to an error already,
246
- // check the status of the programs.
247
- if bpfApplicationStatus == bpfmaniov1alpha1 .BpfAppStateCondSuccess {
248
- bpfApplicationStatus = r .checkProgramStatus ()
249
- }
247
+ // If the bpfApplicationStatus didn't get changed to an error already,
248
+ // check the status of the programs.
249
+ if bpfApplicationStatus == bpfmaniov1alpha1 .BpfAppStateCondSuccess {
250
+ bpfApplicationStatus = r .checkProgramStatus ()
251
+ r . Logger . Info ( "Checking program status" , "Name" , r . currentAppState . Name , "Status" , bpfApplicationStatus )
250
252
}
251
253
252
254
r .updateBpfAppStateCondition (r , bpfApplicationStatus )
@@ -262,7 +264,7 @@ func (r *ClBpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Req
262
264
return ctrl.Result {}, nil
263
265
}
264
266
265
- if r .isBeingDeleted () {
267
+ if r .isBeingDeleted () && ! helpers . IsBpfAppStateConditionFailure ( r . currentAppState . Status . Conditions ) {
266
268
r .Logger .Info ("BpfApplication is being deleted" , "Name" , r .currentApp .Name )
267
269
if r .removeFinalizer (ctx , r .currentAppState , r .finalizer ) {
268
270
return ctrl.Result {}, nil
@@ -289,7 +291,7 @@ func (r *ClBpfApplicationReconciler) createBpfAppState(ctx context.Context) (ctr
289
291
r .Logger .Error (err , "failed to create BpfApplicationState object" )
290
292
return ctrl.Result {Requeue : true , RequeueAfter : retryDurationAgent }, nil
291
293
}
292
- if err := r .initBpfAppStateStatus (ctx ); err != nil {
294
+ if err := r .initBpfAppStateStatus (); err != nil {
293
295
r .Logger .Error (err , "failed to initialize BpfApplicationState status" )
294
296
return ctrl.Result {Requeue : true , RequeueAfter : retryDurationAgent }, nil
295
297
}
@@ -397,6 +399,12 @@ func (r *ClBpfApplicationReconciler) getProgramReconciler(prog *bpfmaniov1alpha1
397
399
}
398
400
399
401
func (r * ClBpfApplicationReconciler ) checkProgramStatus () bpfmaniov1alpha1.BpfApplicationStateConditionType {
402
+ if r .currentAppState .Status .AppLoadStatus == bpfmaniov1alpha1 .AppLoadError {
403
+ return bpfmaniov1alpha1 .BpfAppStateCondUnloadError
404
+ }
405
+ if r .currentAppState .Status .AppLoadStatus == bpfmaniov1alpha1 .AppUnLoadSuccess {
406
+ return bpfmaniov1alpha1 .BpfAppStateCondUnloaded
407
+ }
400
408
for _ , program := range r .currentAppState .Status .Programs {
401
409
if program .ProgramLinkStatus != bpfmaniov1alpha1 .ProgAttachSuccess {
402
410
return bpfmaniov1alpha1 .BpfAppStateCondError
@@ -573,7 +581,7 @@ func (r *ClBpfApplicationReconciler) initBpfAppState() error {
573
581
return nil
574
582
}
575
583
576
- func (r * ClBpfApplicationReconciler ) initBpfAppStateStatus (ctx context. Context ) error {
584
+ func (r * ClBpfApplicationReconciler ) initBpfAppStateStatus () error {
577
585
r .currentAppState .Status = bpfmaniov1alpha1.ClBpfApplicationStateStatus {
578
586
Node : r .NodeName ,
579
587
AppLoadStatus : bpfmaniov1alpha1 .AppLoadNotLoaded ,
0 commit comments