mirror of https://github.com/k3s-io/k3s
Fix for detach volume when node is not present/ powered off
parent
d82e51edc5
commit
9fe3cf9ec3
|
@ -924,11 +924,12 @@ func (vs *VSphere) DiskIsAttached(volPath string, nodeName k8stypes.NodeName) (b
|
|||
}
|
||||
|
||||
if !nodeExist {
|
||||
glog.Warningf(
|
||||
"Node %q does not exist. DiskIsAttached will assume vmdk %q is not attached to it.",
|
||||
vSphereInstance,
|
||||
volPath)
|
||||
return false, nil
|
||||
glog.Errorf("DiskIsAttached failed to determine whether disk %q is still attached: node %q does not exist",
|
||||
volPath,
|
||||
vSphereInstance)
|
||||
return false, fmt.Errorf("DiskIsAttached failed to determine whether disk %q is still attached: node %q does not exist",
|
||||
volPath,
|
||||
vSphereInstance)
|
||||
}
|
||||
|
||||
// Get VM device list
|
||||
|
@ -975,11 +976,12 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
|
|||
}
|
||||
|
||||
if !nodeExist {
|
||||
glog.Warningf(
|
||||
"Node %q does not exist. DisksAreAttached will assume vmdk %v are not attached to it.",
|
||||
vSphereInstance,
|
||||
volPaths)
|
||||
return attached, nil
|
||||
glog.Errorf("DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist",
|
||||
volPaths,
|
||||
vSphereInstance)
|
||||
return attached, fmt.Errorf("DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist",
|
||||
volPaths,
|
||||
vSphereInstance)
|
||||
}
|
||||
|
||||
// Get VM device list
|
||||
|
@ -1145,21 +1147,6 @@ func (vs *VSphere) DetachDisk(volPath string, nodeName k8stypes.NodeName) error
|
|||
vSphereInstance = nodeNameToVMName(nodeName)
|
||||
}
|
||||
|
||||
nodeExist, err := vs.NodeExists(vs.client, nodeName)
|
||||
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to check whether node exist. err: %s.", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if !nodeExist {
|
||||
glog.Warningf(
|
||||
"Node %q does not exist. DetachDisk will assume vmdk %q is not attached to it.",
|
||||
nodeName,
|
||||
volPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
vm, vmDevices, _, dc, err := getVirtualMachineDevices(ctx, vs.cfg, vs.client, vSphereInstance)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue