Skip to content

Commit a8807c7

Browse files
committed
Introduce error handling for potential JSON encoding errors
This commit adds an error handler to catch and manage potential JSON encoding errors. By handling these errors explicitly, we can prevent crashes and improve the stability of the application. Signed-off-by: ronin <papillonyi39@gmail.com>
1 parent de46f05 commit a8807c7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/plugin/nvidia/utils.go

+5
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ func UpdatePodAnnotations(kubeClient *kubernetes.Clientset, pod *v1.Pod) error {
213213
Annotations: pod.Annotations,
214214
},
215215
}
216+
216217
patchBytes, err := json.Marshal(&addAnnotationsPath)
218+
if err != nil {
219+
return err
220+
}
221+
217222
_, err = kubeClient.CoreV1().Pods(pod.Namespace).Patch(context.TODO(), pod.Name, types.MergePatchType, patchBytes, metav1.PatchOptions{})
218223
return err
219224
}

0 commit comments

Comments
 (0)