Skip to content

Commit

Permalink
Delay force refresh by DefaultInterval when OCI GetNodePool call retu…
Browse files Browse the repository at this point in the history
…rns 404
  • Loading branch information
vbhargav875 committed Mar 4, 2024
1 parent 79269d8 commit 07e885c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cluster-autoscaler/cloudprovider/oci/nodepools/oci_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import (
)

const (
maxAddTaintRetries = 5
maxAddTaintRetries = 5
maxForceRefreshRetries = 3
)

var (
Expand Down Expand Up @@ -249,11 +250,22 @@ func (m *ociManagerImpl) TaintToPreventFurtherSchedulingOnRestart(nodes []*apiv1
}

func (m *ociManagerImpl) forceRefresh() error {
err := m.nodePoolCache.rebuild(m.staticNodePools)
if err != nil {
return err
for i := 1; i <= maxForceRefreshRetries; i++ {
err := m.nodePoolCache.rebuild(m.staticNodePools)
if err != nil {
if strings.Contains(err.Error(), "404") && i == maxForceRefreshRetries {
m.lastRefresh = time.Now()
klog.Errorf("Failed to fetch the nodepools. Retrying after %v", m.lastRefresh.Add(m.cfg.Global.RefreshInterval))
return err
} else if i == maxForceRefreshRetries {
klog.Error("Failed to fetch the nodepools.")
return err
}
klog.Errorf("Failed to fetch the nodepools. Retries available : %v", maxForceRefreshRetries-i)
} else {
break
}
}

m.lastRefresh = time.Now()
klog.Infof("Refreshed NodePool list, next refresh after %v", m.lastRefresh.Add(m.cfg.Global.RefreshInterval))
return nil
Expand Down Expand Up @@ -441,7 +453,7 @@ func (m *ociManagerImpl) GetNodePoolForInstance(instance ocicommon.OciRef) (Node

np, found := m.staticNodePools[instance.NodePoolID]
if !found {
klog.Infof("did not find node pool for reference: %+v", instance)
klog.V(4).Infof("did not find node pool for reference: %+v", instance)
return nil, errInstanceNodePoolNotFound
}

Expand Down

0 comments on commit 07e885c

Please sign in to comment.