Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 11 additions & 3 deletions integration-tests/backend/flowcollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
"golang.org/x/mod/semver"

"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
Expand Down Expand Up @@ -209,8 +210,15 @@ func (flow *Flowcollector) WaitForFlowcollectorReady(oc *exutil.CLI) {
default:
waitUntilDeploymentReady(oc, "flowlogs-pipeline", flow.Namespace)
}
// check informers deployment
waitUntilDeploymentReady(oc, "flowlogs-pipeline-informers", flow.Namespace)
// check informers deployment - only available in version >= 2.0
csvVersion, err := getCSVVersion(oc.AdminDynamicClient(), netobservNS)
if err != nil {
e2e.Logf("Could not get CSV version, skipping informers check: %v", err)
} else if semver.Compare(semver.Canonical("v"+csvVersion), "v2.0.0") >= 0 {
waitUntilDeploymentReady(oc, "flowlogs-pipeline-informers", flow.Namespace)
} else {
e2e.Logf("Skipping informers check, CSV version %s is below 2.0", csvVersion)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// check ebpf-agent status
waitUntilDaemonSetReady(oc, "netobserv-ebpf-agent", flow.Namespace+"-privileged")
Expand All @@ -222,7 +230,7 @@ func (flow *Flowcollector) WaitForFlowcollectorReady(oc *exutil.CLI) {

compat_otp.AssertAllPodsToBeReady(oc, flow.Namespace)
compat_otp.AssertAllPodsToBeReady(oc, flow.Namespace+"-privileged")
err := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, 600*time.Second, false, func(context.Context) (done bool, err error) {
err = wait.PollUntilContextTimeout(context.Background(), 10*time.Second, 600*time.Second, false, func(context.Context) (done bool, err error) {
condStatus, err := oc.AsAdmin().Run("get").Args("flowcollector", "cluster", "-o", `jsonpath='{.status.conditions[?(@.type=="Ready")].status}'`).Output()
if err != nil {
return false, nil
Expand Down
29 changes: 29 additions & 0 deletions integration-tests/backend/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/dynamic"
e2e "k8s.io/kubernetes/test/e2e/framework"
)

Expand Down Expand Up @@ -337,3 +340,29 @@ func getOperatorChannel(oc *exutil.CLI, catalog string, packageName string) (ope
channelArr := strings.Split(channels, " ")
return channelArr[len(channelArr)-1], err
}

// getCSVVersion returns the version of the installed NetObserv Operator CSV in the given namespace.
// It uses the dynamic client to list CSVs and finds the one whose name starts with the operator name prefix.
func getCSVVersion(dynamicClient dynamic.Interface, operatorNamespace string) (string, error) {
csvGVR := schema.GroupVersionResource{
Group: "operators.coreos.com",
Version: "v1alpha1",
Resource: "clusterserviceversions",
}

csvList, err := dynamicClient.Resource(csvGVR).Namespace(operatorNamespace).List(context.Background(), metav1.ListOptions{})
if err != nil {
return "", fmt.Errorf("failed to list CSVs in namespace %s: %v", operatorNamespace, err)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}

for _, csv := range csvList.Items {
if strings.HasPrefix(csv.GetName(), NOPackageName+".") {
version, found, err := unstructured.NestedString(csv.Object, "spec", "version")
if err != nil || !found {
return "", fmt.Errorf("version field not found in CSV %s", csv.GetName())
}
return version, nil
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
return "", fmt.Errorf("no CSV found for %s in namespace %s", NOPackageName, operatorNamespace)
}
Loading