From 34e3faa54da28ab777113c5e72bc6fa092d178e1 Mon Sep 17 00:00:00 2001 From: ONE7live Date: Wed, 27 Mar 2024 19:00:24 +0800 Subject: [PATCH] fix: pod convert nil value exception Signed-off-by: ONE7live --- .../controllers/pod/root_pod_controller.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/clustertree/cluster-manager/controllers/pod/root_pod_controller.go b/pkg/clustertree/cluster-manager/controllers/pod/root_pod_controller.go index 7b937eb9f..934fec2d2 100644 --- a/pkg/clustertree/cluster-manager/controllers/pod/root_pod_controller.go +++ b/pkg/clustertree/cluster-manager/controllers/pod/root_pod_controller.go @@ -825,17 +825,17 @@ func (r *RootPodReconciler) mutatePod(ctx context.Context, pod *corev1.Pod, node klog.V(4).Infof("Converting pod %v/%+v", pod.Namespace, pod.Name) cpcpList := &kosmosv1alpha1.ClusterPodConvertPolicyList{} - err := r.Client.List(ctx, cpcpList, &client.ListOptions{}) - if err != nil { - return fmt.Errorf("list cluster pod convert policy error: %v", err) - } - pcpList := &kosmosv1alpha1.PodConvertPolicyList{} - err = r.Client.List(ctx, pcpList, &client.ListOptions{ - Namespace: pod.Namespace, - }) - if err != nil { - return fmt.Errorf("list pod convert policy error: %v", err) + err := r.Client.List(ctx, cpcpList, &client.ListOptions{}) + if err != nil && !errors.IsNotFound(err) { + klog.Infof("list cluster pod convert policy error: %v", err) + } else { + err = r.Client.List(ctx, pcpList, &client.ListOptions{ + Namespace: pod.Namespace, + }) + if err != nil && !errors.IsNotFound(err) { + klog.Infof("list pod convert policy error: %v", err) + } } if len(cpcpList.Items) <= 0 && len(pcpList.Items) <= 0 {