Skip to content

Commit

Permalink
passing drain context only in drainNode
Browse files Browse the repository at this point in the history
  • Loading branch information
sssash18 committed Jul 2, 2024
1 parent 25c1646 commit 9dde1f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/util/provider/drain/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ func (o *Options) evictPodWithoutPVInternal(ctx context.Context, attemptEvict bo
if i >= nretries {
attemptEvict = false
}

if attemptEvict {
err = o.evictPod(ctx, pod, policyGroupVersion)
} else {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/provider/machinecontroller/machine_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ func (c *controller) drainNode(ctx context.Context, deleteMachineRequest *driver
ReadonlyFilesystem v1.NodeConditionType = "ReadonlyFilesystem"
)

drainContext, cancelFn := context.WithDeadline(ctx, deleteMachineRequest.Machine.DeletionTimestamp.Add(timeOutDuration))
drainContext, cancelFn := context.WithDeadline(ctx, time.Now().Add(timeOutDuration))
defer cancelFn()
if !isValidNodeName(nodeName) {
message := "Skipping drain as nodeName is not a valid one for machine."
Expand Down Expand Up @@ -1114,7 +1114,7 @@ func (c *controller) drainNode(ctx context.Context, deleteMachineRequest *driver
}

// update node with the machine's phase prior to termination
if err = c.UpdateNodeTerminationCondition(drainContext, machine); err != nil {
if err = c.UpdateNodeTerminationCondition(ctx, machine); err != nil {
if forceDeleteMachine {
klog.Warningf("Failed to update node conditions: %v. However, since it's a force deletion shall continue deletion of VM.", err)
} else {
Expand Down Expand Up @@ -1185,7 +1185,7 @@ func (c *controller) drainNode(ctx context.Context, deleteMachineRequest *driver
}

updateRetryPeriod, updateErr := c.machineStatusUpdate(
drainContext,
ctx,
machine,
v1alpha1.LastOperation{
Description: description,
Expand Down

0 comments on commit 9dde1f8

Please sign in to comment.