Skip to content

Commit 522c6fc

Browse files
authored
Merge pull request #7085 from bskiba/invalidate-instances
[GCE cloudprovider] Invalidate mig instances cache after node deletion
2 parents aff50d7 + f5d4e35 commit 522c6fc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cluster-autoscaler/cloudprovider/gce/cache.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ func (gc *GceCache) InvalidateAllMigInstances() {
244244
gc.instancesUpdateTime = make(map[GceRef]time.Time)
245245
}
246246

247+
// InvalidateMigInstances clears the mig instances cache for a given Mig
248+
func (gc *GceCache) InvalidateMigInstances(migRef GceRef) {
249+
gc.cacheMutex.Lock()
250+
defer gc.cacheMutex.Unlock()
251+
252+
klog.V(5).Infof("Mig instances cache invalidated for %v", migRef.Name)
253+
delete(gc.instances, migRef)
254+
delete(gc.instancesUpdateTime, migRef)
255+
}
256+
247257
// InvalidateInstancesToMig clears the instance to mig mapping for a GceRef
248258
func (gc *GceCache) InvalidateInstancesToMig(migRef GceRef) {
249259
gc.cacheMutex.Lock()

cluster-autoscaler/cloudprovider/gce/gce_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ func (m *gceManagerImpl) DeleteInstances(instances []GceRef) error {
277277
}
278278
}
279279
m.cache.InvalidateMigTargetSize(commonMig.GceRef())
280+
m.cache.InvalidateMigInstances(commonMig.GceRef())
280281
return m.GceService.DeleteInstances(commonMig.GceRef(), instances)
281282
}
282283

0 commit comments

Comments
 (0)