Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: add more logging in azure disk attach/detach What you expected to happen: How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Others: /sig azure /assign
The issue message here doesn't say why a change was desired. The PR "Original logging is not clear when dealing with managed disk, since diskName is empty". That's more informative.

Discussion:
}, }, } <del> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s)", nodeResourceGroup, vmName, diskName) </del> <ins> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s, %s)", nodeResourceGroup, vmName, diskName, diskURI) </ins> ctx, cancel := getContextWithCancel() defer cancel()

_, err = as.VirtualMachinesClient.CreateOrUpdate(ctx, nodeResourceGroup, vmName, newVM) if err != nil { <del> klog.Errorf("azureDisk - attach disk(%s) failed, err: %v", diskName, err) </del> <ins> klog.Errorf("azureDisk - attach disk(%s, %s) failed, err: %v", diskName, diskURI, err) </ins> detail := err.Error() if strings.Contains(detail, errLeaseFailed) || strings.Contains(detail, errDiskBlobNotFound) { // if lease cannot be acquired or disk not found, immediately detach the disk and return the original error <del> klog.V(2).Infof("azureDisk - err %v, try detach disk(%s)", err, diskName) </del> <ins> klog.V(2).Infof("azureDisk - err %v, try detach disk(%s, %s)", err, diskName, diskURI) </ins> as.DetachDiskByName(diskName, diskURI, nodeName) } } else { <del> klog.V(2).Infof("azureDisk - attach disk(%s) succeeded", diskName) </del> <ins> klog.V(2).Infof("azureDisk - attach disk(%s, %s) succeeded", diskName, diskURI) </ins> } return err }

vm, err := as.getVirtualMachine(nodeName) if err != nil { // if host doesn't exist, no need to detach <del> klog.Warningf("azureDisk - cannot find node %s, skip detaching disk %s", nodeName, diskName) </del> <ins> klog.Warningf("azureDisk - cannot find node %s, skip detaching disk(%s, %s)", nodeName, diskName, diskURI) </ins> return nil }

}, }, } <del> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - detach disk(%s)", nodeResourceGroup, vmName, diskName) </del> <ins> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - detach disk(%s, %s)", nodeResourceGroup, vmName, diskName, diskURI) </ins> ctx, cancel := getContextWithCancel() defer cancel()

} } if err != nil { <del> klog.Errorf("azureDisk - detach disk(%s, %s)) failed, err: %v", diskName, diskURI, err) </del> <ins> klog.Errorf("azureDisk - detach disk(%s, %s) failed, err: %v", diskName, diskURI, err) </ins> } else { klog.V(2).Infof("azureDisk - detach disk(%s, %s) succeeded", diskName, diskURI) }

key := buildVmssCacheKey(nodeResourceGroup, ss.makeVmssVMName(ssName, instanceID)) defer ss.vmssVMCache.Delete(key) <del> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s)", nodeResourceGroup, nodeName, diskName) </del> <ins> klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s, %s)", nodeResourceGroup, nodeName, diskName, diskURI) </ins> _, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, newVM) if err != nil { detail := err.Error() if strings.Contains(detail, errLeaseFailed) || strings.Contains(detail, errDiskBlobNotFound) { // if lease cannot be acquired or disk not found, immediately detach the disk and return the original error <del> klog.Infof("azureDisk - err %s, try detach disk(%s)", detail, diskName) </del> <ins> klog.Infof("azureDisk - err %s, try detach disk(%s, %s)", detail, diskName, diskURI) </ins> ss.DetachDiskByName(diskName, diskURI, nodeName) } } else { <del> klog.V(2).Infof("azureDisk - attach disk(%s) succeeded", diskName) </del> <ins> klog.V(2).Infof("azureDisk - attach disk(%s, %s) succeeded", diskName, diskURI) </ins> } return err }