Skip to content

Commit

Permalink
[Fix] CSS: Fix CSS tags update (#2760)
Browse files Browse the repository at this point in the history
[Fix] CSS: Fix CSS tags update

Summary of the Pull Request
Fix CSS tag update
PR Checklist

 Refers to: #2748
 Tests added/passed.
 Documentation updated.
 Schema updated.
 Release notes added.

Acceptance Steps Performed
=== RUN   TestAccCssClusterV1_tags
=== PAUSE TestAccCssClusterV1_tags
=== CONT  TestAccCssClusterV1_tags
--- PASS: TestAccCssClusterV1_tags (850.28s)
PASS

Process finished with the exit code 0

Reviewed-by: Anton Sidelnikov
  • Loading branch information
artem-lifshits authored Dec 11, 2024
1 parent eefce21 commit d5ed85b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ func TestAccCssClusterV1_tags(t *testing.T) {
resource.TestCheckResourceAttr(resourceClusterName, "tags.say", "hi"),
),
},
{
Config: testAccCssClusterV1TagsUpdate(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckCssClusterV1Exists(resourceClusterName, &cluster),
resource.TestCheckResourceAttr(resourceClusterName, "nodes.#", "1"),
resource.TestCheckResourceAttr(resourceClusterName, "tags.say", "hi"),
resource.TestCheckResourceAttr(resourceClusterName, "tags.mao", "nihao"),
),
},
},
})
}
Expand Down Expand Up @@ -307,6 +316,44 @@ resource "opentelekomcloud_css_cluster_v1" "cluster" {
`, common.DataSourceSecGroupDefault, common.DataSourceSubnet, name, env.OS_AVAILABILITY_ZONE)
}

func testAccCssClusterV1TagsUpdate(name string) string {
return fmt.Sprintf(`
%s
%s
resource "opentelekomcloud_css_cluster_v1" "cluster" {
expect_node_num = 1
name = "%s"
node_config {
flavor = "css.medium.8"
network_info {
security_group_id = data.opentelekomcloud_networking_secgroup_v2.default_secgroup.id
network_id = data.opentelekomcloud_vpc_subnet_v1.shared_subnet.network_id
vpc_id = data.opentelekomcloud_vpc_subnet_v1.shared_subnet.vpc_id
}
volume {
volume_type = "COMMON"
size = 40
}
availability_zone = "%s"
}
datastore {
version = "7.6.2"
}
enable_https = true
enable_authority = true
admin_pass = "QwertyUI!"
tags = {
say = "hi"
mao = "nihao"
}
}
`, common.DataSourceSecGroupDefault, common.DataSourceSubnet, name, env.OS_AVAILABILITY_ZONE)
}

func testAccCssClusterV1TooSmall(name string) string {
return fmt.Sprintf(`
%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func ResourceCssClusterV1() *schema.Resource {
"tags": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: common.ValidateTags,
},
"endpoint": {
Expand Down Expand Up @@ -325,6 +325,12 @@ func resourceCssClusterV1Update(ctx context.Context, d *schema.ResourceData, met
return fmterr.Errorf("error creating CSS v1 client: %s", err)
}

if d.HasChange("tags") {
if err := common.UpdateResourceTags(client, d, "css-cluster", d.Id()); err != nil {
return fmterr.Errorf("error updating tags of CSS cluster %s: %s", d.Id(), err)
}
}

if !d.HasChange("expect_node_num") && !d.HasChange("node_config.0.volume.0.size") {
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/css_cluster_tags-dbd741d8dea6f683.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
**[CSS]** CSS cluster fix tags update ``resource/opentelekomcloud_css_cluster_v1``
(`#2760 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2760>`_)

0 comments on commit d5ed85b

Please sign in to comment.