Skip to content

fix(cbs): [123875626]support burst_performance #3345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3345.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_cbs_storage: support burst_performance
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1156
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1159
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1153
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1111
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1154 h1:tc2
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1154/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1156 h1:Uz9TqzwTAtRYuV7gB0Fh2E013qPrUJpS6CeNJ7vlfAI=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1156/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1159 h1:Jl1XE3cY6Bz0lBexvX8z+u2KmDO3tnFxtwHIalM5YS4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1159/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
Expand Down
25 changes: 24 additions & 1 deletion tencentcloud/services/cbs/resource_tc_cbs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ func ResourceTencentCloudCbsStorage() *schema.Resource {
Computed: true,
Description: "The quota of backup points of cloud disk.",
},
"burst_performance": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Whether to enable performance burst when creating a cloud disk.",
},
// computed
"storage_status": {
Type: schema.TypeString,
Expand Down Expand Up @@ -217,6 +223,10 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
}
}

if v, ok := d.GetOkExists("burst_performance"); ok {
request.BurstPerformance = helper.Bool(v.(bool))
}

storageId := ""
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
response, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseCbsClient().CreateDisks(request)
Expand Down Expand Up @@ -324,6 +334,7 @@ func resourceTencentCloudCbsStorageRead(d *schema.ResourceData, meta interface{}
_ = d.Set("charge_type", storage.DiskChargeType)
_ = d.Set("prepaid_renew_flag", storage.RenewFlag)
_ = d.Set("throughput_performance", storage.ThroughputPerformance)
_ = d.Set("burst_performance", storage.BurstPerformance)

if storage.KmsKeyId != nil {
_ = d.Set("kms_key_id", storage.KmsKeyId)
Expand Down Expand Up @@ -380,9 +391,21 @@ func resourceTencentCloudCbsStorageUpdate(d *schema.ResourceData, meta interface
projectId = d.Get("project_id").(int)
}

var burstPerformanceOperation string
if d.HasChange("burst_performance") {
if v, ok := d.GetOkExists("burst_performance"); ok {
if v.(bool) {
burstPerformanceOperation = "CREATE"
} else {
burstPerformanceOperation = "CANCEL"
}
changed = true
}
}

if changed {
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
e := cbsService.ModifyDiskAttributes(ctx, storageId, storageName, projectId)
e := cbsService.ModifyDiskAttributes(ctx, storageId, storageName, projectId, burstPerformanceOperation)
if e != nil {
return tccommon.RetryError(e)
}
Expand Down
49 changes: 49 additions & 0 deletions tencentcloud/services/cbs/resource_tc_cbs_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ func TestAccTencentCloudCbsStorageResource_basic(t *testing.T) {
})
}

func TestAccTencentCloudCbsStorageResource_burstPerformance(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
CheckDestroy: testAccCheckCbsStorageDestroy,
Steps: []resource.TestStep{
{
Config: testAccCbsStorage_burstPerformance,
Check: resource.ComposeTestCheckFunc(
testAccCheckStorageExists("tencentcloud_cbs_storage.burst_performance"),
resource.TestCheckResourceAttr("tencentcloud_cbs_storage.burst_performance", "burst_performance", "true"),
),
},
{
Config: testAccCbsStorage_burstPerformanceUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckStorageExists("tencentcloud_cbs_storage.burst_performance"),
resource.TestCheckResourceAttr("tencentcloud_cbs_storage.burst_performance", "burst_performance", "false"),
),
},
{
ResourceName: "tencentcloud_cbs_storage.burst_performance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"force_delete"},
},
},
})
}

func TestAccTencentCloudCbsStorageResource_full(t *testing.T) {

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -256,6 +287,24 @@ resource "tencentcloud_cbs_storage" "storage_basic" {
}
`

const testAccCbsStorage_burstPerformance = `
resource "tencentcloud_cbs_storage" "burst_performance" {
storage_type = "CLOUD_HSSD"
storage_name = "burst-performance"
storage_size = 500
availability_zone = "ap-guangzhou-3"
burst_performance = true
}
`
const testAccCbsStorage_burstPerformanceUpdate = `
resource "tencentcloud_cbs_storage" "burst_performance" {
storage_type = "CLOUD_HSSD"
storage_name = "burst-performance"
storage_size = 500
availability_zone = "ap-guangzhou-3"
burst_performance = false
}
`
const testAccCbsStorage_full = `
resource "tencentcloud_cbs_storage" "storage_full" {
storage_type = "CLOUD_PREMIUM"
Expand Down
5 changes: 4 additions & 1 deletion tencentcloud/services/cbs/service_tencentcloud_cbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (me *CbsService) DescribeDisksInParallelByFilter(ctx context.Context, param
return
}

func (me *CbsService) ModifyDiskAttributes(ctx context.Context, diskId, diskName string, projectId int) error {
func (me *CbsService) ModifyDiskAttributes(ctx context.Context, diskId, diskName string, projectId int, burstPerformanceOperation string) error {
logId := tccommon.GetLogId(ctx)
request := cbs.NewModifyDiskAttributesRequest()
request.DiskIds = []*string{&diskId}
Expand All @@ -253,6 +253,9 @@ func (me *CbsService) ModifyDiskAttributes(ctx context.Context, diskId, diskName
if projectId >= 0 {
request.ProjectId = helper.IntUint64(projectId)
}
if burstPerformanceOperation != "" {
request.BurstPerformanceOperation = helper.String(burstPerformanceOperation)
}
ratelimit.Check(request.GetAction())
response, err := me.client.UseCbsClient().ModifyDiskAttributes(request)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tencentcloud/services/cvm/resource_tc_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ func resourceTencentCloudInstanceUpdate(d *schema.ResourceData, meta interface{}
if d.HasChange(nameKey) {
name := d.Get(nameKey).(string)
diskId := d.Get(idKey).(string)
err := cbsService.ModifyDiskAttributes(ctx, diskId, name, -1)
err := cbsService.ModifyDiskAttributes(ctx, diskId, name, -1, "")
if err != nil {
return fmt.Errorf("an error occurred when modifying data disk name: %s, reason: %s", name, err.Error())
}
Expand Down Expand Up @@ -1880,7 +1880,7 @@ func resourceTencentCloudInstanceUpdate(d *schema.ResourceData, meta interface{}
if v, ok := d.GetOk("system_disk_id"); ok {
systemDiskId := v.(string)
cbsService := svccbs.NewCbsService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
err := cbsService.ModifyDiskAttributes(ctx, systemDiskId, systemDiskName, -1)
err := cbsService.ModifyDiskAttributes(ctx, systemDiskId, systemDiskName, -1, "")
if err != nil {
return fmt.Errorf("an error occurred when modifying system disk name %s, reason: %s", systemDiskName, err.Error())
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148
## explicit; go 1.14
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1156
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1159
## explicit; go 1.11
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/cbs_storage.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ The following arguments are supported:
* `storage_name` - (Required, String) Name of CBS. The maximum length can not exceed 60 bytes.
* `storage_size` - (Required, Int) Volume of CBS, and unit is GB.
* `storage_type` - (Required, String, ForceNew) Type of CBS medium. Valid values: CLOUD_BASIC: HDD cloud disk, CLOUD_PREMIUM: Premium Cloud Storage, CLOUD_BSSD: General Purpose SSD, CLOUD_SSD: SSD, CLOUD_HSSD: Enhanced SSD, CLOUD_TSSD: Tremendous SSD.
* `burst_performance` - (Optional, Bool) Whether to enable performance burst when creating a cloud disk.
* `charge_type` - (Optional, String) The charge type of CBS instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `CDCPAID` and `DEDICATED_CLUSTER_PAID`. The default is `POSTPAID_BY_HOUR`.
* `dedicated_cluster_id` - (Optional, String, ForceNew) Exclusive cluster id.
* `disk_backup_quota` - (Optional, Int) The quota of backup points of cloud disk.
Expand Down
Loading