adityadtu5 commented on code in PR #1052:
URL: https://github.com/apache/yunikorn-k8shim/pull/1052#discussion_r3726321495


##########
pkg/cache/context.go:
##########
@@ -897,6 +897,37 @@ func (ctx *Context) ForgetPod(name string) {
        log.Log(log.ShimContext).Debug("unable to forget pod: not found in 
cache", zap.String("pod", name))
 }
 
+// RevertPodVolumeAssumptions undoes any PV/PVC assumptions made by the volume 
binder
+// for the given pod on the given node. This is idempotent and safe to call 
even if
+// AssumePodVolumes was never called or already reverted internally.
+func (ctx *Context) RevertPodVolumeAssumptions(podName, nodeID string) {
+       ctx.lock.Lock()
+       defer ctx.lock.Unlock()
+       pod := ctx.schedulerCache.GetPod(podName)
+       if pod == nil {
+               return
+       }
+       node := ctx.schedulerCache.GetNode(nodeID)
+       if node == nil {
+               return
+       }
+       podVolumeClaims, err := 
ctx.apiProvider.GetAPIs().VolumeBinder.GetPodVolumeClaims(ctx.klogger, pod)
+       if err != nil {
+               log.Log(log.ShimContext).Debug("RevertPodVolumeAssumptions: 
failed to get pod volume claims",

Review Comment:
   changes log levels in the last commit



##########
pkg/cache/context.go:
##########
@@ -897,6 +897,37 @@ func (ctx *Context) ForgetPod(name string) {
        log.Log(log.ShimContext).Debug("unable to forget pod: not found in 
cache", zap.String("pod", name))
 }
 
+// RevertPodVolumeAssumptions undoes any PV/PVC assumptions made by the volume 
binder
+// for the given pod on the given node. This is idempotent and safe to call 
even if
+// AssumePodVolumes was never called or already reverted internally.
+func (ctx *Context) RevertPodVolumeAssumptions(podName, nodeID string) {
+       ctx.lock.Lock()
+       defer ctx.lock.Unlock()
+       pod := ctx.schedulerCache.GetPod(podName)
+       if pod == nil {
+               return
+       }
+       node := ctx.schedulerCache.GetNode(nodeID)
+       if node == nil {
+               return
+       }
+       podVolumeClaims, err := 
ctx.apiProvider.GetAPIs().VolumeBinder.GetPodVolumeClaims(ctx.klogger, pod)
+       if err != nil {
+               log.Log(log.ShimContext).Debug("RevertPodVolumeAssumptions: 
failed to get pod volume claims",
+                       zap.String("pod", podName), zap.Error(err))
+               return
+       }
+       podVolumes, _, err := 
ctx.apiProvider.GetAPIs().VolumeBinder.FindPodVolumes(ctx.klogger, pod, 
podVolumeClaims, node.Node())
+       if err != nil || podVolumes == nil {
+               log.Log(log.ShimContext).Debug("RevertPodVolumeAssumptions: 
failed to find pod volumes",

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to