Skip to content

Commit 2314456

Browse files
authored
fix(kubernetes): ignore first 404 responses when waiting cluster state (#267)
1 parent c177ecd commit 2314456

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
55

66
## [Unreleased]
77

8+
### Changed
9+
- kubernetes: `WaitForKubernetesClusterState` ignores two first 404 responses to avoid errors caused by possible false _not found_ responses right after cluster has been created.
10+
811
## [6.8.0]
912
- Managed Object Storage support
1013

upcloud/service/kubernetes.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package service
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
7+
"log"
8+
"net/http"
69
"time"
710

811
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
@@ -83,7 +86,13 @@ func (s *Service) WaitForKubernetesClusterState(ctx context.Context, r *request.
8386
UUID: r.UUID,
8487
})
8588
if err != nil {
86-
return nil, err
89+
// Ignore first two 404 responses to avoid errors caused by possible false NOT_FOUND responses right after cluster has been created.
90+
var ucErr *upcloud.Problem
91+
if errors.As(err, &ucErr) && ucErr.Status == http.StatusNotFound && attempts < 3 {
92+
log.Printf("ERROR: %+v", err)
93+
} else {
94+
return nil, err
95+
}
8796
}
8897

8998
if details.State == r.DesiredState {

0 commit comments

Comments
 (0)