You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by wi...@apache.org on 2026/10/02 06:27:46 UTC

(yunikorn-k8shim) branch master updated: [YUNIKORN-3485] Remove UpdatePod from KubeClient (#1112)

This is an automated email from the ASF dual-hosted git repository.

wilfred-s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new d48d2657 [YUNIKORN-3485] Remove UpdatePod from KubeClient (#1112)
d48d2657 is described below

commit d48d2657a39ed781e4c98adb428cd936c22b78a3
Author: rjgoyln <pt...@gmail.com>
AuthorDate: Fri Oct 2 16:26:40 2026 +1000

    [YUNIKORN-3485] Remove UpdatePod from KubeClient (#1112)
    
    Task.UpdateTaskPod has no callers and is the only caller of
    KubeClient.UpdatePod, so the whole chain is dead code. Removing it also
    drops one of the uncancellable K8s write paths tracked in YUNIKORN-3437.
    
    Closes: #1112
    
    Signed-off-by: Wilfred Spiegelenburg <wi...@apache.org>
---
 pkg/cache/task.go             |  4 ----
 pkg/client/interfaces.go      |  3 ---
 pkg/client/kubeclient.go      | 35 -----------------------------------
 pkg/client/kubeclient_mock.go | 17 -----------------
 4 files changed, 59 deletions(-)

diff --git a/pkg/cache/task.go b/pkg/cache/task.go
index 3571acf7..eec7dd47 100644
--- a/pkg/cache/task.go
+++ b/pkg/cache/task.go
@@ -199,10 +199,6 @@ func (task *Task) UpdateTaskPodStatus(pod *v1.Pod) (*v1.Pod, error) {
 	return task.context.apiProvider.GetAPIs().KubeClient.UpdateStatus(pod)
 }
 
-func (task *Task) UpdateTaskPod(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error) {
-	return task.context.apiProvider.GetAPIs().KubeClient.UpdatePod(pod, podMutator)
-}
-
 func (task *Task) isTerminated() bool {
 	for _, states := range TaskStates().Terminated {
 		if task.GetTaskState() == states {
diff --git a/pkg/client/interfaces.go b/pkg/client/interfaces.go
index 207f46c7..1281e780 100644
--- a/pkg/client/interfaces.go
+++ b/pkg/client/interfaces.go
@@ -34,9 +34,6 @@ type KubeClient interface {
 	// Delete a pod from a host
 	Delete(pod *v1.Pod) error
 
-	// Update a pod
-	UpdatePod(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error)
-
 	// Update the status of a pod
 	UpdateStatus(pod *v1.Pod) (*v1.Pod, error)
 
diff --git a/pkg/client/kubeclient.go b/pkg/client/kubeclient.go
index 6132ab75..5f96ff39 100644
--- a/pkg/client/kubeclient.go
+++ b/pkg/client/kubeclient.go
@@ -172,41 +172,6 @@ func (nc SchedulerKubeClient) Get(podNamespace string, podName string) (*v1.Pod,
 	return pod, nil
 }
 
-func (nc SchedulerKubeClient) UpdatePod(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error) {
-	var updatedPod *v1.Pod
-	var updateErr error
-	// Retrieve the latest version of Pod before attempting update
-	// RetryOnConflict uses exponential backoff to avoid exhausting the API server
-	retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
-		latestPod, getErr := nc.clientSet.CoreV1().Pods(pod.Namespace).Get(context.Background(), pod.Name, apis.GetOptions{})
-		if getErr != nil {
-			log.Log(log.ShimClient).Warn("failed to get latest version of Pod",
-				zap.Error(getErr))
-		}
-		// allow mutator to update pod
-		podMutator(latestPod)
-		if updatedPod, updateErr = nc.clientSet.CoreV1().Pods(pod.Namespace).Update(context.Background(), latestPod, apis.UpdateOptions{}); updateErr != nil {
-			log.Log(log.ShimClient).Warn("failed to update pod",
-				zap.String("namespace", pod.Namespace),
-				zap.String("podName", pod.Name),
-				zap.Error(updateErr))
-			return updateErr
-		}
-		return nil
-	})
-	if retryErr != nil {
-		log.Log(log.ShimClient).Error("Update pod failed",
-			zap.String("namespace", pod.Namespace),
-			zap.String("podName", pod.Name),
-			zap.Error(retryErr))
-		return pod, retryErr
-	}
-	log.Log(log.ShimClient).Info("Successfully updated pod",
-		zap.String("namespace", pod.Namespace),
-		zap.String("podName", pod.Name))
-	return updatedPod, nil
-}
-
 func (nc SchedulerKubeClient) UpdateStatus(pod *v1.Pod) (*v1.Pod, error) {
 	var updatedPod *v1.Pod
 	var updateErr error
diff --git a/pkg/client/kubeclient_mock.go b/pkg/client/kubeclient_mock.go
index 3143f4d3..bb314305 100644
--- a/pkg/client/kubeclient_mock.go
+++ b/pkg/client/kubeclient_mock.go
@@ -37,7 +37,6 @@ type KubeClientMock struct {
 	bindFn         func(pod *v1.Pod, hostID string) error
 	deleteFn       func(pod *v1.Pod) error
 	createFn       func(pod *v1.Pod) (*v1.Pod, error)
-	updateFn       func(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error)
 	updateStatusFn func(pod *v1.Pod) (*v1.Pod, error)
 	getFn          func(podName string) (*v1.Pod, error)
 	clientSet      kubernetes.Interface
@@ -80,15 +79,6 @@ func NewKubeClientMock(err bool) *KubeClientMock {
 				zap.String("PodName", pod.Name))
 			return pod, nil
 		},
-		updateFn: func(pod *v1.Pod, podMutator func(*v1.Pod)) (*v1.Pod, error) {
-			if err {
-				return pod, fmt.Errorf("error updating pod")
-			}
-			podMutator(pod)
-			log.Log(log.Test).Info("pod updated",
-				zap.String("PodName", pod.Name))
-			return pod, nil
-		},
 		updateStatusFn: func(pod *v1.Pod) (*v1.Pod, error) {
 			if err {
 				return pod, fmt.Errorf("error updating pod status")
@@ -166,13 +156,6 @@ func (c *KubeClientMock) Create(pod *v1.Pod) (*v1.Pod, error) {
 	return c.createFn(pod)
 }
 
-func (c *KubeClientMock) UpdatePod(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error) {
-	c.lock.Lock()
-	defer c.lock.Unlock()
-	c.pods[getPodKey(pod)] = pod
-	return c.updateFn(pod, podMutator)
-}
-
 func (c *KubeClientMock) UpdateStatus(pod *v1.Pod) (*v1.Pod, error) {
 	c.lock.Lock()
 	defer c.lock.Unlock()


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org