Skip to content

Commit 01ea169

Browse files
committed
fix vmss dirty cache issue
add logging
1 parent ce11622 commit 01ea169

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_vmss.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
8888
defer cancel()
8989

9090
// Invalidate the cache right after updating
91-
if err = ss.deleteCacheForNode(vmName); err != nil {
92-
return err
93-
}
91+
defer ss.deleteCacheForNode(vmName)
9492

9593
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s, %s) with DiskEncryptionSetID(%s)", nodeResourceGroup, nodeName, diskName, diskURI, diskEncryptionSetID)
9694
_, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, newVM, "attach_disk")
@@ -160,9 +158,7 @@ func (ss *scaleSet) DetachDisk(diskName, diskURI string, nodeName types.NodeName
160158
defer cancel()
161159

162160
// Invalidate the cache right after updating
163-
if err = ss.deleteCacheForNode(vmName); err != nil {
164-
return nil, err
165-
}
161+
defer ss.deleteCacheForNode(vmName)
166162

167163
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - detach disk(%s, %s)", nodeResourceGroup, nodeName, diskName, diskURI)
168164
return ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, newVM, "detach_disk")

staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,8 @@ func (ss *scaleSet) EnsureHostInPool(service *v1.Service, nodeName types.NodeNam
850850
return err
851851
}
852852

853-
// Invalidate the cache since we would update it.
854-
if err = ss.deleteCacheForNode(vmName); err != nil {
855-
return err
856-
}
853+
// Invalidate the cache since right after update
854+
defer ss.deleteCacheForNode(vmName)
857855

858856
// Update vmssVM with backoff.
859857
ctx, cancel := getContextWithCancel()
@@ -1129,10 +1127,8 @@ func (ss *scaleSet) ensureBackendPoolDeletedFromNode(service *v1.Service, nodeNa
11291127
return err
11301128
}
11311129

1132-
// Invalidate the cache since we would update it.
1133-
if err = ss.deleteCacheForNode(nodeName); err != nil {
1134-
return err
1135-
}
1130+
// Invalidate the cache since right after update
1131+
defer ss.deleteCacheForNode(nodeName)
11361132

11371133
// Update vmssVM with backoff.
11381134
ctx, cancel := getContextWithCancel()

staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss_cache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (ss *scaleSet) newVMSSVirtualMachinesCache() (*timedCache, error) {
117117
func (ss *scaleSet) deleteCacheForNode(nodeName string) error {
118118
cached, err := ss.vmssVMCache.Get(vmssVirtualMachinesKey, cacheReadTypeUnsafe)
119119
if err != nil {
120+
klog.Errorf("deleteCacheForNode(%s) failed with error: %v", nodeName, err)
120121
return err
121122
}
122123

0 commit comments

Comments
 (0)