Skip to content

Commit

Permalink
resource/alicloud_cs_kubernetes_addon: fix WaitForState if addon exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyangji committed Jun 25, 2024
1 parent f086e2b commit cdeaf47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions alicloud/resource_alicloud_cs_kubernetes_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func resourceAlicloudCSKubernetesAddonCreate(d *schema.ResourceData, meta interf
// Addon has been installed
err = updateAddon(csClient, d, addon)
if err != nil {
return err
return WrapError(err)
}
}

Expand All @@ -186,7 +186,7 @@ func resourceAlicloudCSKubernetesAddonUpdate(d *schema.ResourceData, meta interf
if d.HasChange("version") || d.HasChange("config") {
err = updateAddon(csClient, d, addon)
if err != nil {
return err
return WrapError(err)
}
}

Expand Down Expand Up @@ -252,6 +252,9 @@ func updateAddon(csClient CsClient, d *schema.ResourceData, addon *Component) er
return WrapErrorf(err, DefaultErrorMsg, ResourceAlicloudCSKubernetesAddon, "updateAddonConfig", err)
}
}
if !updateVersion && !updateConfig {
return nil
}

stateConf := BuildStateConf([]string{}, []string{"Success"}, d.Timeout(schema.TimeoutUpdate), 10*time.Second, csClient.CsKubernetesAddonTaskRefreshFunc(clusterId, name, []string{"Failed"}))
if _, err := stateConf.WaitForState(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions alicloud/resource_alicloud_cs_kubernetes_addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ func TestAccAliCloudCSKubernetesAddon_logtail_ds(t *testing.T) {
Config: testAccConfig(map[string]interface{}{
"cluster_id": "${local.cluster_id}",
"name": "logtail-ds",
"version": "v1.8.3.0-aliyun",
"version": "v1.8.5.0-aliyun",
"depends_on": []string{"alicloud_cs_kubernetes_node_pool.default"},
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"cluster_id": CHECKSET,
"name": "logtail-ds",
"version": "v1.8.3.0-aliyun",
"version": "v1.8.5.0-aliyun",
"next_version": CHECKSET,
"can_upgrade": CHECKSET,
"required": CHECKSET,
Expand All @@ -204,11 +204,11 @@ func TestAccAliCloudCSKubernetesAddon_logtail_ds(t *testing.T) {
},
{
Config: testAccConfig(map[string]interface{}{
"version": "v1.8.4.0-aliyun",
"version": "v1.8.6.0-aliyun",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"version": "v1.8.4.0-aliyun",
"version": "v1.8.6.0-aliyun",
}),
),
},
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cs_kubernetes_addon.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: |-

# alicloud_cs_kubernetes_addon

This resource will help you to manage addon in Kubernetes Cluster, see [What is kubernetes addon](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/developer-reference/api-install-a-component-in-an-ack-cluster).
This resource will help you to manage addon in Kubernetes Cluster, see [What is kubernetes addon](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/developer-reference/api-install-a-component-in-an-ack-cluster). For more usage information, see [Use Terraform to manage addons](https://www.alibabacloud.com/help/en/ack/serverless-kubernetes/developer-reference/use-terraform-to-manage-components).

-> **NOTE:** Available since v1.150.0.

Expand Down

0 comments on commit cdeaf47

Please sign in to comment.