Skip to content

Commit

Permalink
fix(kubernetes): sleep before GET request in `WaitForKubernetesClus…
Browse files Browse the repository at this point in the history
…terState` (#275)

Sleep before `GET` request in `WaitForKubernetesClusterState` to avoid getting stale state in some scenarios.
This will also align function behavior with other services.
  • Loading branch information
peknur authored Oct 26, 2023
1 parent 68885c4 commit 7c9ca73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
## Added
- kubernetes: `WaitForKubernetesNodeGroupState` method for waiting the node group to achieve a desired state

### Changed
- kubernetes: sleep before `GET` request in `WaitForKubernetesClusterState`

## [6.8.2]
### Added
- account: `NetworkPeerings`, `NTPExcessGiB`, `StorageMaxIOPS`, and `LoadBalancers` fields to the `ResourceLimits` struct.
Expand Down
3 changes: 1 addition & 2 deletions upcloud/service/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (s *Service) WaitForKubernetesClusterState(ctx context.Context, r *request.

for {
attempts++
time.Sleep(sleepDuration)

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

time.Sleep(sleepDuration)

if time.Duration(attempts)*sleepDuration >= r.Timeout {
return nil, fmt.Errorf("timeout reached while waiting for Kubernetes cluster to enter state \"%s\"", r.DesiredState)
}
Expand Down

0 comments on commit 7c9ca73

Please sign in to comment.