Skip to content

Commit 7c9ca73

Browse files
authored
fix(kubernetes): sleep before GET request in WaitForKubernetesClusterState (#275)
Sleep before `GET` request in `WaitForKubernetesClusterState` to avoid getting stale state in some scenarios. This will also align function behavior with other services.
1 parent 68885c4 commit 7c9ca73

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
77
## Added
88
- kubernetes: `WaitForKubernetesNodeGroupState` method for waiting the node group to achieve a desired state
99

10+
### Changed
11+
- kubernetes: sleep before `GET` request in `WaitForKubernetesClusterState`
12+
1013
## [6.8.2]
1114
### Added
1215
- account: `NetworkPeerings`, `NTPExcessGiB`, `StorageMaxIOPS`, and `LoadBalancers` fields to the `ResourceLimits` struct.

upcloud/service/kubernetes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (s *Service) WaitForKubernetesClusterState(ctx context.Context, r *request.
8282

8383
for {
8484
attempts++
85+
time.Sleep(sleepDuration)
8586

8687
details, err := s.GetKubernetesCluster(ctx, &request.GetKubernetesClusterRequest{
8788
UUID: r.UUID,
@@ -100,8 +101,6 @@ func (s *Service) WaitForKubernetesClusterState(ctx context.Context, r *request.
100101
return details, nil
101102
}
102103

103-
time.Sleep(sleepDuration)
104-
105104
if time.Duration(attempts)*sleepDuration >= r.Timeout {
106105
return nil, fmt.Errorf("timeout reached while waiting for Kubernetes cluster to enter state \"%s\"", r.DesiredState)
107106
}

0 commit comments

Comments
 (0)