Skip to content

Commit 88e1d6b

Browse files
committed
Updated WaitForClusterState function to check for condition last update before return error
1 parent d5c38e9 commit 88e1d6b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

rancher2/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
rancher2ManagementV2TypePrefix = "management.cattle.io"
2828
rancher2ReadyAnswer = "pong"
2929
rancher2RetriesWait = 5
30+
rancher2WaitFalseCond = 120
3031
rancher2RKEK8sSystemImageVersion = "2.3.0"
3132
rancher2NodeTemplateChangeVersion = "2.3.3" // Change node template id format
3233
rancher2TokeTTLMinutesVersion = "2.4.6" // ttl token is readed in minutes
@@ -735,8 +736,9 @@ func (c *Config) WaitForClusterState(clusterID, state string, interval time.Dura
735736
if obj.Conditions[i].Status == "True" {
736737
return obj, nil
737738
}
738-
// When condition is false, checking if the cluster is transitioning to still wait for condition
739-
if obj.Transitioning == "yes" {
739+
// When cluster condition is false, retrying if it has been updated for last rancher2WaitFalseCond seconds
740+
lastUpdate, err := time.Parse(time.RFC3339, obj.Conditions[i].LastUpdateTime)
741+
if err == nil && time.Since(lastUpdate) < rancher2WaitFalseCond*time.Second {
740742
break
741743
}
742744
return nil, fmt.Errorf("Cluster ID %s: %s", clusterID, obj.Conditions[i].Message)

0 commit comments

Comments
 (0)