From 81a7ec4ff0089e6e8553874cbf9c6031c6e15728 Mon Sep 17 00:00:00 2001 From: jacksontong Date: Fri, 5 Apr 2024 22:59:16 +0800 Subject: [PATCH] bugfix --- pkg/application/controller/app/action/daemonset.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/application/controller/app/action/daemonset.go b/pkg/application/controller/app/action/daemonset.go index df4a95ad1..775d20d6b 100644 --- a/pkg/application/controller/app/action/daemonset.go +++ b/pkg/application/controller/app/action/daemonset.go @@ -20,6 +20,7 @@ package action import ( "context" + "encoding/json" "fmt" "strconv" "strings" @@ -31,6 +32,8 @@ import ( extensionsv1beta1 "k8s.io/api/extensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" applicationv1 "tkestack.io/tke/api/application/v1" applicationversionedclient "tkestack.io/tke/api/client/clientset/versioned/typed/application/v1" @@ -145,7 +148,14 @@ func getOndeleteDaemonsets(ctx context.Context, for _, v := range clusterResource { switch kube.AsVersioned(v).(type) { case *extensionsv1beta1.DaemonSet, *appsv1.DaemonSet, *appsv1beta2.DaemonSet: - daemonset := v.Object.(*appsv1.DaemonSet) + data, _ := json.Marshal(v.Object) + log.Infof("object is %s", string(data)) + daemonsetObj := v.Object.(*unstructured.Unstructured) + var daemonset appsv1.DaemonSet + err = runtime.DefaultUnstructuredConverter.FromUnstructured(daemonsetObj.UnstructuredContent(), &daemonset) + if err != nil { + log.Fatalf("Error converting *unstructured.Unstructured to *v1.DaemonSet: %v", err) + } if daemonset.Spec.UpdateStrategy.Type == appsv1.OnDeleteDaemonSetStrategyType { ds = append(ds, daemonset.Namespace+"/"+daemonset.Name) }