@@ -21,7 +21,6 @@ import (
2121 bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
2222 "github.com/bpfman/bpfman-operator/internal"
2323 bpfmanHelpers "github.com/bpfman/bpfman-operator/pkg/helpers"
24- "github.com/bpfman/bpfman-operator/test/testutil"
2524 osv1 "github.com/openshift/api/security/v1"
2625 "k8s.io/apimachinery/pkg/runtime"
2726 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -60,7 +59,6 @@ millisec_delay = 10000
6059allow_unsigned = true
6160verify_enabled = true` ,
6261 Agent : v1alpha1.AgentSpec {
63- HealthProbePort : 8175 ,
6462 Image : "quay.io/bpfman/bpfman-agent:latest" ,
6563 LogLevel : "debug" , // Changed from info to debug
6664 },
@@ -131,8 +129,8 @@ func TestLifecycle(t *testing.T) {
131129 if err := waitForResourceCreation (ctx ); err != nil {
132130 t .Fatalf ("Failed to ensure resources: %q" , err )
133131 }
134- if err := waitForAvailable (ctx , isOpenShift ); err != nil {
135- t .Fatalf ("Config never reported status available : %q" , err )
132+ if err := checkResourcesInDesiredState (ctx ); err != nil {
133+ t .Fatalf ("Failed to ensure resources : %q" , err )
136134 }
137135
138136 // Test deleting resources.
@@ -787,37 +785,36 @@ func podHasContainerArg(ds *appsv1.DaemonSet, arg string) bool {
787785 return false
788786}
789787
790- // waitForAvailable waits until the bpfman Config shows "Available" status conditions,
791- // indicating that all components are ready and reconciliation is complete.
792- func waitForAvailable (ctx context.Context , isOpenShift bool ) error {
793- return waitUntilCondition (ctx , func () (bool , error ) {
794- bpfmanConfig := & v1alpha1.Config {}
795- if err := runtimeClient .Get (ctx , types.NamespacedName {Name : internal .BpfmanConfigName }, bpfmanConfig ); err != nil {
796- if errors .IsNotFound (err ) {
797- return false , nil
798- }
799- return false , err
800- }
801- progressingCondition := metav1.Condition {
802- Type : internal .ConfigConditionProgressing ,
803- Status : metav1 .ConditionFalse ,
804- Reason : internal .ConfigReasonAvailable ,
805- Message : internal .ConfigMessageAvailable ,
806- }
807- availableCondition := metav1.Condition {
808- Type : internal .ConfigConditionAvailable ,
809- Status : metav1 .ConditionTrue ,
810- Reason : internal .ConfigReasonAvailable ,
811- Message : internal .ConfigMessageAvailable ,
812- }
813- if ! testutil .ContainsCondition (bpfmanConfig .Status .Conditions , progressingCondition ) {
814- return false , nil
815- }
816- if ! testutil .ContainsCondition (bpfmanConfig .Status .Conditions , availableCondition ) {
817- return false , nil
818- }
819- componentsReady := bpfmanConfig .Status .Components != nil &&
820- internal .CCSAllComponentsReady (bpfmanConfig .Status .Components , isOpenShift )
821- return componentsReady , nil
822- })
788+ // checkResourcesInDesiredState makes sure that all resources are in the desired state.
789+ // Right now, the only implemented validation in this function is a check for the health probe port.
790+ // Returns error if timeout is reached or if context is cancelled.
791+ func checkResourcesInDesiredState (ctx context.Context ) error {
792+ // Check DaemonSet is in desired state.
793+ ds := & appsv1.DaemonSet {}
794+ dsKey := types.NamespacedName {Name : internal .BpfmanDsName , Namespace : internal .BpfmanNamespace }
795+ if err := runtimeClient .Get (ctx , dsKey , ds ); err != nil && errors .IsNotFound (err ) || ds .Status .NumberAvailable == 0 {
796+ return nil
797+ } else if err != nil {
798+ return err
799+ }
800+
801+ arg := "--health-probe-bind-address=:8175"
802+ // Check that the bpfman DaemonSet has the health probe bind address argument.
803+ if ! podHasContainerArg (ds , arg ) {
804+ return fmt .Errorf ("bpfman DaemonSet missing argument %q" , arg )
805+ }
806+ // Check Metrics Proxy DaemonSet is in desired state.
807+ mds := & appsv1.DaemonSet {}
808+ mdsKey := types.NamespacedName {Name : internal .BpfmanMetricsProxyDsName , Namespace : internal .BpfmanNamespace }
809+ if err := runtimeClient .Get (ctx , mdsKey , mds ); err != nil && errors .IsNotFound (err ) || mds .Status .NumberAvailable == 0 {
810+ return nil
811+ } else if err != nil {
812+ return err
813+ }
814+ // Check that the metrics proxy DaemonSet has the health probe bind address argument.
815+ if ! podHasContainerArg (mds , arg ) {
816+ return fmt .Errorf ("metrics proxy DaemonSet missing argement %q" , arg )
817+ }
818+
819+ return nil
823820}
0 commit comments