Skip to content

Commit

Permalink
call in the nodegroup API to avoid type assertion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Sep 16, 2020
1 parent c153a63 commit e146e3e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cluster-autoscaler/cloudprovider/azure/azure_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,25 @@ func newAsgCache() (*asgCache, error) {
}

// Register registers a node group if it hasn't been registered.
func (m *asgCache) Register(asg cloudprovider.NodeGroup) bool {
func (m *asgCache) Register(newAsg cloudprovider.NodeGroup) bool {
m.mutex.Lock()
defer m.mutex.Unlock()

for i := range m.registeredAsgs {
if existing := m.registeredAsgs[i]; strings.EqualFold(existing.Id(), asg.Id()) {
e := existing.(*ScaleSet)
a := asg.(*ScaleSet)
if e.minSize == a.minSize && e.maxSize == a.maxSize && e.curSize == a.curSize {
if existing := m.registeredAsgs[i]; strings.EqualFold(existing.Id(), newAsg.Id()) {
if existing.MinSize() == newAsg.MinSize() && existing.MaxSize() == newAsg.MaxSize() {
return false
}

m.registeredAsgs[i] = asg
klog.V(4).Infof("ASG %q updated", asg.Id())
m.registeredAsgs[i] = newAsg
klog.V(4).Infof("ASG %q updated", newAsg.Id())
m.invalidateUnownedInstanceCache()
return true
}
}

klog.V(4).Infof("Registering ASG %q", asg.Id())
m.registeredAsgs = append(m.registeredAsgs, asg)
klog.V(4).Infof("Registering ASG %q", newAsg.Id())
m.registeredAsgs = append(m.registeredAsgs, newAsg)
m.invalidateUnownedInstanceCache()
return true
}
Expand Down

0 comments on commit e146e3e

Please sign in to comment.