Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removal of inject instrumentation label when uninstall using cli #2341

Merged
Merged
Changes from all commits
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
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 {
AvihuHenya marked this conversation as resolved.
Show resolved Hide resolved
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
Loading