Skip to content

Commit 2315ffd

Browse files
authored
fix(k8s): fix waitK8SClusterDeleted function (#2323)
1 parent 55af5e7 commit 2315ffd

20 files changed

+26856
-9741
lines changed

scaleway/helpers_k8s.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,17 @@ func waitK8SClusterDeleted(ctx context.Context, k8sAPI *k8s.API, region scw.Regi
111111
retryInterval = *DefaultWaitRetryInterval
112112
}
113113

114-
cluster, err := k8sAPI.WaitForCluster(&k8s.WaitForClusterRequest{
114+
_, err := k8sAPI.WaitForCluster(&k8s.WaitForClusterRequest{
115115
ClusterID: clusterID,
116116
Region: region,
117+
Status: k8s.ClusterStatusDeleted,
117118
Timeout: scw.TimeDurationPtr(timeout),
118119
RetryInterval: &retryInterval,
119120
}, scw.WithContext(ctx))
120-
if err != nil {
121-
if is404Error(err) {
122-
return nil
123-
}
121+
if err != nil && !is404Error(err) {
124122
return err
125123
}
126124

127-
if cluster.Status != k8s.ClusterStatusDeleted {
128-
return fmt.Errorf("cluster %s has state %s, wants %s", clusterID, cluster.Status, k8s.ClusterStatusDeleted)
129-
}
130125
return nil
131126
}
132127

scaleway/testdata/data-source-k8s-cluster-basic.cassette.yaml

Lines changed: 574 additions & 507 deletions
Large diffs are not rendered by default.

scaleway/testdata/data-source-k8s-pool-basic.cassette.yaml

Lines changed: 2207 additions & 721 deletions
Large diffs are not rendered by default.

scaleway/testdata/data-source-k8s-version-basic.cassette.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ interactions:
1111
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
1212
method: GET
1313
response:
14-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
14+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
1515
1.26.2","name":"1.26.2","region":"fr-par"}'
1616
headers:
1717
Content-Length:
18-
- "726"
18+
- "720"
1919
Content-Security-Policy:
2020
- default-src 'none'; frame-ancestors 'none'
2121
Content-Type:
2222
- application/json
2323
Date:
24-
- Wed, 19 Jul 2023 12:08:40 GMT
24+
- Wed, 20 Dec 2023 16:18:14 GMT
2525
Server:
2626
- Scaleway API-Gateway
2727
Strict-Transport-Security:
@@ -31,7 +31,7 @@ interactions:
3131
X-Frame-Options:
3232
- DENY
3333
X-Request-Id:
34-
- c5b11d18-0441-4251-b946-a087045474dd
34+
- cfc0ebd7-b8b9-4cdf-9bfe-84286b7d44ad
3535
status: 200 OK
3636
code: 200
3737
duration: ""
@@ -45,17 +45,17 @@ interactions:
4545
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
4646
method: GET
4747
response:
48-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
48+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
4949
1.26.2","name":"1.26.2","region":"fr-par"}'
5050
headers:
5151
Content-Length:
52-
- "726"
52+
- "720"
5353
Content-Security-Policy:
5454
- default-src 'none'; frame-ancestors 'none'
5555
Content-Type:
5656
- application/json
5757
Date:
58-
- Wed, 19 Jul 2023 12:08:40 GMT
58+
- Wed, 20 Dec 2023 16:18:14 GMT
5959
Server:
6060
- Scaleway API-Gateway
6161
Strict-Transport-Security:
@@ -65,7 +65,7 @@ interactions:
6565
X-Frame-Options:
6666
- DENY
6767
X-Request-Id:
68-
- 19d62cb1-e4da-45d0-8862-12c462ad7b77
68+
- 826ca1c4-2601-4642-84d6-d777963cf3d6
6969
status: 200 OK
7070
code: 200
7171
duration: ""
@@ -79,17 +79,17 @@ interactions:
7979
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
8080
method: GET
8181
response:
82-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
82+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
8383
1.26.2","name":"1.26.2","region":"fr-par"}'
8484
headers:
8585
Content-Length:
86-
- "726"
86+
- "720"
8787
Content-Security-Policy:
8888
- default-src 'none'; frame-ancestors 'none'
8989
Content-Type:
9090
- application/json
9191
Date:
92-
- Wed, 19 Jul 2023 12:08:40 GMT
92+
- Wed, 20 Dec 2023 16:18:14 GMT
9393
Server:
9494
- Scaleway API-Gateway
9595
Strict-Transport-Security:
@@ -99,7 +99,7 @@ interactions:
9999
X-Frame-Options:
100100
- DENY
101101
X-Request-Id:
102-
- 7a6cd4ac-997a-4d2e-8b57-20e7be7cfda0
102+
- 5aa10bab-2378-465b-91ca-0cbf46eb12ec
103103
status: 200 OK
104104
code: 200
105105
duration: ""
@@ -113,17 +113,17 @@ interactions:
113113
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
114114
method: GET
115115
response:
116-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
116+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
117117
1.26.2","name":"1.26.2","region":"fr-par"}'
118118
headers:
119119
Content-Length:
120-
- "726"
120+
- "720"
121121
Content-Security-Policy:
122122
- default-src 'none'; frame-ancestors 'none'
123123
Content-Type:
124124
- application/json
125125
Date:
126-
- Wed, 19 Jul 2023 12:08:40 GMT
126+
- Wed, 20 Dec 2023 16:18:14 GMT
127127
Server:
128128
- Scaleway API-Gateway
129129
Strict-Transport-Security:
@@ -133,7 +133,7 @@ interactions:
133133
X-Frame-Options:
134134
- DENY
135135
X-Request-Id:
136-
- 142edf57-7153-42ab-9611-113024f89d76
136+
- f569dccf-a4f8-4fed-aa10-39991d5af342
137137
status: 200 OK
138138
code: 200
139139
duration: ""
@@ -147,17 +147,17 @@ interactions:
147147
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
148148
method: GET
149149
response:
150-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
150+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
151151
1.26.2","name":"1.26.2","region":"fr-par"}'
152152
headers:
153153
Content-Length:
154-
- "726"
154+
- "720"
155155
Content-Security-Policy:
156156
- default-src 'none'; frame-ancestors 'none'
157157
Content-Type:
158158
- application/json
159159
Date:
160-
- Wed, 19 Jul 2023 12:08:40 GMT
160+
- Wed, 20 Dec 2023 16:18:14 GMT
161161
Server:
162162
- Scaleway API-Gateway
163163
Strict-Transport-Security:
@@ -167,7 +167,7 @@ interactions:
167167
X-Frame-Options:
168168
- DENY
169169
X-Request-Id:
170-
- 5cff89d9-501f-4afc-a06c-933d772e21b5
170+
- 9d2fe15b-2a95-4f8e-abc1-6e290cde1bcc
171171
status: 200 OK
172172
code: 200
173173
duration: ""
@@ -181,17 +181,17 @@ interactions:
181181
url: https://api.scaleway.com/k8s/v1/regions/fr-par/versions/1.26.2
182182
method: GET
183183
response:
184-
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":["none"],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
184+
body: '{"available_admission_plugins":["PodNodeSelector","AlwaysPullImages","PodTolerationRestriction"],"available_cnis":["cilium","calico","kilo"],"available_container_runtimes":["containerd"],"available_feature_gates":["HPAScaleToZero","GRPCContainerProbe","ReadWriteOncePod","ValidatingAdmissionPolicy","CSINodeExpandSecret"],"available_ingresses":[],"available_kubelet_args":{"containerLogMaxFiles":"uint16","containerLogMaxSize":"quantity","cpuCFSQuota":"bool","cpuCFSQuotaPeriod":"duration","cpuManagerPolicy":"enum:none|static","enableDebuggingHandlers":"bool","imageGCHighThresholdPercent":"uint32","imageGCLowThresholdPercent":"uint32","maxPods":"uint16"},"label":"Kubernetes
185185
1.26.2","name":"1.26.2","region":"fr-par"}'
186186
headers:
187187
Content-Length:
188-
- "726"
188+
- "720"
189189
Content-Security-Policy:
190190
- default-src 'none'; frame-ancestors 'none'
191191
Content-Type:
192192
- application/json
193193
Date:
194-
- Wed, 19 Jul 2023 12:08:40 GMT
194+
- Wed, 20 Dec 2023 16:18:14 GMT
195195
Server:
196196
- Scaleway API-Gateway
197197
Strict-Transport-Security:
@@ -201,7 +201,7 @@ interactions:
201201
X-Frame-Options:
202202
- DENY
203203
X-Request-Id:
204-
- 7a4cbbcb-64ad-48f0-baca-f4335d482751
204+
- 256fc2db-0a57-47c6-aee5-828670acf620
205205
status: 200 OK
206206
code: 200
207207
duration: ""

0 commit comments

Comments
 (0)