Skip to content

Commit

Permalink
removal of inject instrumentation label when uninstall using cli (#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvihuHenya authored Feb 4, 2025
1 parent 6628afe commit de210c0
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions cli/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"github.com/odigos-io/odigos/api/k8sconsts"
"github.com/odigos-io/odigos/common/envOverwrite"
"github.com/odigos-io/odigos/k8sutils/pkg/envoverwrite"

Expand Down Expand Up @@ -150,9 +151,11 @@ func rollbackPodChanges(ctx context.Context, client *kube.Client) error {
errs = multierr.Append(errs, err)
continue
}
_, err = client.AppsV1().Deployments(dep.Namespace).Patch(ctx, dep.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
if len(jsonPatchPayloadBytes) > 0 {
_, err = client.AppsV1().Deployments(dep.Namespace).Patch(ctx, dep.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
}
}
}

Expand All @@ -166,9 +169,11 @@ func rollbackPodChanges(ctx context.Context, client *kube.Client) error {
errs = multierr.Append(errs, err)
continue
}
_, err = client.AppsV1().StatefulSets(s.Namespace).Patch(ctx, s.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
if len(jsonPatchPayloadBytes) > 0 {
_, err = client.AppsV1().StatefulSets(s.Namespace).Patch(ctx, s.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
}
}
}

Expand All @@ -182,9 +187,11 @@ func rollbackPodChanges(ctx context.Context, client *kube.Client) error {
errs = multierr.Append(errs, err)
continue
}
_, err = client.AppsV1().DaemonSets(d.Namespace).Patch(ctx, d.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
if len(jsonPatchPayloadBytes) > 0 {
_, err = client.AppsV1().DaemonSets(d.Namespace).Patch(ctx, d.Name, types.JSONPatchType, jsonPatchPayloadBytes, metav1.PatchOptions{})
if err != nil {
errs = multierr.Append(errs, err)
}
}
}

Expand All @@ -209,6 +216,12 @@ func getWorkloadRolloutJsonPatch(obj kube.Object, pts *v1.PodTemplateSpec) ([]by
})
}
}
if _, found := pts.ObjectMeta.Labels[k8sconsts.OdigosInjectInstrumentationLabel]; found {
patchOperations = append(patchOperations, map[string]interface{}{
"op": "remove",
"path": "/spec/template/metadata/labels/" + jsonPatchEscapeKey(k8sconsts.OdigosInjectInstrumentationLabel),
})
}

// remove odigos reported name annotation
if obj.GetAnnotations() != nil {
Expand Down

0 comments on commit de210c0

Please sign in to comment.