Skip to content

Commit

Permalink
Merge branch 'main' into java-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yodigos authored Sep 18, 2024
2 parents 7941200 + 44c27f0 commit ddbe6f6
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function SourcesTableHeader({
showSourcesWithIssues
? filterByConditionStatus('False')
: filterByConditionStatus('All');
}, [showSourcesWithIssues, data]);
}, [showSourcesWithIssues]);

useEffect(() => {
if (namespaces) {
Expand Down
25 changes: 12 additions & 13 deletions instrumentor/controllers/startlangdetection/manager.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package startlangdetection

import (
"github.com/odigos-io/odigos/instrumentor/controllers/utils"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -60,18 +59,18 @@ func SetupWithManager(mgr ctrl.Manager) error {
return err
}

err = builder.
ControllerManagedBy(mgr).
Named("startlangdetection-configmaps").
For(&corev1.ConfigMap{}).
WithEventFilter(&utils.OnlyUpdatesPredicate{}).
Complete(&OdigosConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
})
if err != nil {
return err
}
//err = builder.
// ControllerManagedBy(mgr).
// Named("startlangdetection-configmaps").
// For(&corev1.ConfigMap{}).
// WithEventFilter(&utils.OnlyUpdatesPredicate{}).
// Complete(&OdigosConfigReconciler{
// Client: mgr.GetClient(),
// Scheme: mgr.GetScheme(),
// })
//if err != nil {
// return err
//}

return nil
}
15 changes: 15 additions & 0 deletions instrumentor/controllers/utils/versionsupport/ignored_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package versionsupport

import "github.com/hashicorp/go-version"

type IgnoredVersionCheck struct{}

func (g IgnoredVersionCheck) IsVersionSupported(version *version.Version) bool {
// ignored containers are anyhow not used for device injection.
// we will return true here so not to fail all containers due to this check.
return true
}

func (g IgnoredVersionCheck) GetSupportedVersion() string {
return ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package versionsupport
import (
"context"
"fmt"

"github.com/hashicorp/go-version"
"github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
Expand Down Expand Up @@ -69,6 +70,10 @@ func getRuntimeVersionCheck(language common.ProgrammingLanguage) RuntimeVersionC
return &NginxVersionCheck{}
case common.MySQLProgrammingLanguage:
return &MySQLVersionCheck{}
case common.UnknownProgrammingLanguage:
return &UnknownVersionCheck{}
case common.IgnoredProgrammingLanguage:
return &IgnoredVersionCheck{}
default:
return nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package versionsupport

import (
"testing"

"github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
"github.com/stretchr/testify/assert"
"testing"
)

func TestIsRuntimeVersionSupported_NotSupported(t *testing.T) {
Expand All @@ -21,7 +22,7 @@ func TestIsRuntimeVersionSupported_NotSupported(t *testing.T) {
{"python version not supported", common.PythonProgrammingLanguage, "3.7", "python runtime version not supported by OpenTelemetry SDK. Found: 3.7, supports: 3.8.0"},
{"nginx version not supported", common.NginxProgrammingLanguage, "1.25.4", "nginx runtime version not supported by OpenTelemetry SDK. Found: 1.25.4, supports: 1.25.5, 1.26.0"},
{"nginx version not supported", common.NginxProgrammingLanguage, "1.26.1", "nginx runtime version not supported by OpenTelemetry SDK. Found: 1.26.1, supports: 1.25.5, 1.26.0"},
{"unknown language", common.UnknownProgrammingLanguage, "0.0.0", "Unsupported language: unknown"},
// {"unknown language", common.UnknownProgrammingLanguage, "0.0.0", "Unsupported language: unknown"},
}

for _, tc := range testCases {
Expand Down
15 changes: 15 additions & 0 deletions instrumentor/controllers/utils/versionsupport/unknown_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package versionsupport

import "github.com/hashicorp/go-version"

type UnknownVersionCheck struct{}

func (g UnknownVersionCheck) IsVersionSupported(version *version.Version) bool {
// if we return false here, it will fail all device injection into all containers in the pod.
// we return true here, which anyhow will not inject any device into the container.
return true
}

func (g UnknownVersionCheck) GetSupportedVersion() string {
return ""
}
2 changes: 1 addition & 1 deletion odiglet/pkg/ebpf/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (d *EbpfDirector[T]) Cleanup(pod types.NamespacedName) {
return
}

log.Logger.V(0).Info("Cleaning up ebpf go instrumentation for pod", "pod", pod)
log.Logger.V(0).Info("Cleaning up ebpf instrumentation for pod", "pod", pod, "language", d.language)
delete(d.podsToDetails, pod)

// clear the pod from the workloadToPods map
Expand Down
6 changes: 5 additions & 1 deletion odiglet/pkg/kube/instrumentation_ebpf/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func (i *podPredicate) Update(e event.UpdateEvent) bool {
return true
}

return false
// Sum the restart counts for both oldPod and newPod containers, then compare them.
// If the newPod has a higher restart count than the oldPod, we need to re-instrument it.
// This happens because the pod was abruptly killed, which caused an increment in the restart count.
// This check is required because the pod will remain running during the process kill and re-launch.
return GetPodSumRestarts(newPod) > GetPodSumRestarts(oldPod)
}

func (i *podPredicate) Delete(e event.DeleteEvent) bool {
Expand Down
8 changes: 8 additions & 0 deletions odiglet/pkg/kube/instrumentation_ebpf/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,11 @@ func (p *PodsReconciler) getPodWorkloadObject(ctx context.Context, pod *corev1.P
// Pod does not necessarily have to be managed by a controller
return nil, nil
}

func GetPodSumRestarts(pod *corev1.Pod) int {
restartCount := 0
for _, containerStatus := range pod.Status.ContainerStatuses {
restartCount += int(containerStatus.RestartCount)
}
return restartCount
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/k8sutils/pkg/workload"
"github.com/odigos-io/odigos/opampserver/pkg/connection"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -23,11 +22,7 @@ func (i *InstrumentationConfigReconciler) Reconcile(ctx context.Context, req ctr
err := i.Get(ctx, req.NamespacedName, instrumentationConfig)

if err != nil {
if apierrors.IsNotFound(err) {
instrumentationConfig = nil
} else {
return ctrl.Result{}, err
}
return ctrl.Result{}, client.IgnoreNotFound(err)
}

workloadName, workloadKind, err := workload.ExtractWorkloadInfoFromRuntimeObjectName(req.Name)
Expand Down

0 comments on commit ddbe6f6

Please sign in to comment.