Skip to content

Commit 377cdc0

Browse files
authored
fix(k8s): fix waiting for multicloud cluster (#1325)
1 parent e2625b3 commit 377cdc0

File tree

3 files changed

+4119
-2
lines changed

3 files changed

+4119
-2
lines changed

scaleway/resource_k8s_cluster.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,13 @@ func resourceScalewayK8SClusterCreate(ctx context.Context, d *schema.ResourceDat
385385
}
386386

387387
d.SetId(newRegionalIDString(region, res.ID))
388-
389-
_, err = waitK8SClusterPool(ctx, k8sAPI, region, res.ID, d.Timeout(schema.TimeoutCreate))
388+
if clusterType.(string) == "multicloud" {
389+
// In case of multi-cloud, we do not have the guarantee that a pool will be created in Scaleway.
390+
_, err = waitK8SCluster(ctx, k8sAPI, region, res.ID, d.Timeout(schema.TimeoutCreate))
391+
} else {
392+
// If we are not in multi-cloud, we can wait for the pool to be created.
393+
_, err = waitK8SClusterPool(ctx, k8sAPI, region, res.ID, d.Timeout(schema.TimeoutCreate))
394+
}
390395
if err != nil {
391396
return diag.FromErr(err)
392397
}

scaleway/resource_k8s_cluster_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,30 @@ func TestAccScalewayK8SCluster_AutoUpgrade(t *testing.T) {
384384
})
385385
}
386386

387+
func TestAccScalewayK8SCluster_Multicloud(t *testing.T) {
388+
tt := NewTestTools(t)
389+
defer tt.Cleanup()
390+
391+
latestK8SVersion := testAccScalewayK8SClusterGetLatestK8SVersion(tt)
392+
393+
resource.ParallelTest(t, resource.TestCase{
394+
PreCheck: func() {
395+
testAccPreCheck(t)
396+
},
397+
ProviderFactories: tt.ProviderFactories,
398+
CheckDestroy: testAccCheckScalewayK8SClusterDestroy(tt),
399+
Steps: []resource.TestStep{
400+
{
401+
Config: testAccCheckScalewayK8SClusterMulticloud(latestK8SVersion),
402+
Check: resource.ComposeTestCheckFunc(
403+
testAccCheckScalewayK8SClusterExists(tt, "scaleway_k8s_cluster.multicloud"),
404+
resource.TestCheckResourceAttr("scaleway_k8s_cluster.multicloud", "version", latestK8SVersion),
405+
),
406+
},
407+
},
408+
})
409+
}
410+
387411
func testAccCheckScalewayK8SClusterDestroy(tt *TestTools) resource.TestCheckFunc {
388412
return func(state *terraform.State) error {
389413
for _, rs := range state.RootModule().Resources {
@@ -543,3 +567,21 @@ resource "scaleway_k8s_cluster" "auto_upgrade" {
543567
tags = [ "terraform-test", "scaleway_k8s_cluster", "auto_upgrade" ]
544568
}`, version, enable, hour, day)
545569
}
570+
571+
func testAccCheckScalewayK8SClusterMulticloud(version string) string {
572+
return fmt.Sprintf(`
573+
resource "scaleway_k8s_cluster" "multicloud" {
574+
name = "test-multicloud"
575+
version = "%s"
576+
cni = "kilo"
577+
type = "multicloud"
578+
}
579+
580+
resource "scaleway_k8s_pool" "multicloud" {
581+
cluster_id = "${scaleway_k8s_cluster.multicloud.id}"
582+
name = "test-multicloud"
583+
node_type = "DEV1-M"
584+
size = 1
585+
}
586+
`, version)
587+
}

0 commit comments

Comments
 (0)