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

fix: fix cases instrumented application does not deleted due to workl… #1338

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func deleteWorkloadInstrumentedApplication(ctx context.Context, kubeClient clien

ns := workloadObject.GetNamespace()
name := workloadObject.GetName()
kind := workloadObject.GetObjectKind().GroupVersionKind().Kind
kind := workload.GetWorkloadKind(workloadObject)
instrumentedApplicationName := workload.GetRuntimeObjectName(name, kind)

err := kubeClient.Delete(ctx, &odigosv1.InstrumentedApplication{
Expand Down
16 changes: 14 additions & 2 deletions k8sutils/pkg/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

"github.com/odigos-io/odigos/common/consts"
"k8s.io/api/apps/v1"
v1 "k8s.io/api/apps/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -56,7 +56,6 @@ func ObjectToWorkload(obj client.Object) (Workload, error) {
}
}


// runtime name is a way to store workload specific CRs with odigos
// and give the k8s object a name which is unique and can be used to extract the workload name and kind
func GetRuntimeObjectName(name string, kind string) string {
Expand Down Expand Up @@ -104,3 +103,16 @@ func IsObjectLabeledForInstrumentation(obj client.Object) bool {

return val == consts.InstrumentationEnabled
}

func GetWorkloadKind(w client.Object) string {
switch w.(type) {
case *v1.Deployment:
return "Deployment"
case *v1.DaemonSet:
return "Daemonset"
case *v1.StatefulSet:
return "Statefulset"
default:
return "Unknown"
}
}
Loading