Skip to content

Commit

Permalink
Merge branch 'main' into cm_langdetection_reconcile_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RonFed committed Nov 10, 2024
2 parents 6465bc3 + b1cceb7 commit d9dd276
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions instrumentor/controllers/instrumentationdevice/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (
"github.com/odigos-io/odigos/instrumentor/instrumentation"
"github.com/odigos-io/odigos/instrumentor/sdks"
"github.com/odigos-io/odigos/k8sutils/pkg/conditions"
odigosk8sconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
"github.com/odigos-io/odigos/k8sutils/pkg/workload"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -51,26 +53,24 @@ func clearInstrumentationEbpf(obj client.Object) {

func isDataCollectionReady(ctx context.Context, c client.Client) bool {
logger := log.FromContext(ctx)
var collectorGroups odigosv1.CollectorsGroupList
err := c.List(ctx, &collectorGroups, client.InNamespace(env.GetCurrentNamespace()))
if err != nil {
logger.Error(err, "error getting collectors groups, skipping instrumentation")
return false
}

for _, cg := range collectorGroups.Items {
// up until v1.0.31, the collectors group role names were "GATEWAY" and "DATA_COLLECTION".
// in v1.0.32, the role names were changed to "CLUSTER_GATEWAY" and "NODE_COLLECTOR",
// due to adding the Processor CRD which uses these role names.
// the new names are more descriptive and are preparations for future roles.
// the check for "DATA_COLLECTION" is a temporary support for users that upgrade from <=v1.0.31 to >=v1.0.32.
// once we drop support for <=v1.0.31, we can remove this comparison.
if (cg.Spec.Role == odigosv1.CollectorsGroupRoleNodeCollector || cg.Spec.Role == "DATA_COLLECTION") && cg.Status.Ready {
return true
nodeCollectorsGroup := odigosv1.CollectorsGroup{}
err := c.Get(ctx, client.ObjectKey{
Namespace: env.GetCurrentNamespace(),
Name: odigosk8sconsts.OdigosNodeCollectorCollectorGroupName,
}, &nodeCollectorsGroup)

if err != nil {
if apierrors.IsNotFound(err) {
// if node collector is not yet created, then it is not ready
return false
} else {
logger.Error(err, "error getting node collector group, skipping instrumentation")
return false
}
}

return false
return nodeCollectorsGroup.Status.Ready
}

func addInstrumentationDeviceToWorkload(ctx context.Context, kubeClient client.Client, runtimeDetails *odigosv1.InstrumentedApplication) error {
Expand Down

0 comments on commit d9dd276

Please sign in to comment.