Skip to content

Commit 68885c4

Browse files
chore(kubernetes): WaitForKubernetesNodeGroupState method to wait first (#274)
1 parent b64f2f0 commit 68885c4

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

upcloud/service/kubernetes.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,16 @@ func (s *Service) WaitForKubernetesNodeGroupState(ctx context.Context, r *reques
117117

118118
for {
119119
attempts++
120+
time.Sleep(sleepDuration)
120121

121122
ng, err := s.GetKubernetesNodeGroup(ctx, &request.GetKubernetesNodeGroupRequest{
122123
ClusterUUID: r.ClusterUUID,
123124
Name: r.Name,
124125
})
125126
if err != nil {
126-
// Ignore first two 404 responses to avoid errors caused by possible false NOT_FOUND responses right after cluster has been created.
127+
// Ignore first two 404 responses to avoid errors caused by possible false NOT_FOUND responses right after cluster or node group has been created.
127128
var ucErr *upcloud.Problem
128-
if errors.As(err, &ucErr) && ucErr.Status == http.StatusNotFound && attempts < 3 {
129-
log.Printf("ERROR: %+v", err)
130-
} else {
129+
if !(errors.As(err, &ucErr) && ucErr.Status == http.StatusNotFound) || attempts >= 3 {
131130
return nil, err
132131
}
133132
}
@@ -136,8 +135,6 @@ func (s *Service) WaitForKubernetesNodeGroupState(ctx context.Context, r *reques
136135
return &ng.KubernetesNodeGroup, nil
137136
}
138137

139-
time.Sleep(sleepDuration)
140-
141138
if time.Duration(attempts)*sleepDuration >= r.Timeout {
142139
return nil, fmt.Errorf("timeout reached while waiting for Kubernetes node group to enter state \"%s\"", r.DesiredState)
143140
}

0 commit comments

Comments
 (0)