Skip to content

Commit dbf1cf6

Browse files
committed
modify description of cdh and return nonRetryError when cdh sold out
1 parent 48fcfa8 commit dbf1cf6

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

tencentcloud/data_source_tc_cdh_instances.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,22 @@ func dataSourceTencentCloudCdhInstances() *schema.Resource {
151151
"memory_total_size": {
152152
Type: schema.TypeFloat,
153153
Computed: true,
154-
Description: "Instance memory total capacity, unit in GiB.",
154+
Description: "Instance memory total capacity, unit in GB.",
155155
},
156156
"memory_available_size": {
157157
Type: schema.TypeFloat,
158158
Computed: true,
159-
Description: "Instance memory available capacity, unit in GiB.",
159+
Description: "Instance memory available capacity, unit in GB.",
160160
},
161161
"disk_total_size": {
162162
Type: schema.TypeInt,
163163
Computed: true,
164-
Description: "Instance disk total capacity, unit in GiB.",
164+
Description: "Instance disk total capacity, unit in GB.",
165165
},
166166
"disk_available_size": {
167167
Type: schema.TypeInt,
168168
Computed: true,
169-
Description: "Instance disk available capacity, unit in GiB.",
169+
Description: "Instance disk available capacity, unit in GB.",
170170
},
171171
"disk_type": {
172172
Type: schema.TypeString,

tencentcloud/extension_cdh.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const (
1111
CDH_HOST_STATE_LAUNCH_FAILURE = "LAUNCH_FAILURE"
1212
CDH_HOST_RUNNING = "RUNNING"
1313
CDH_HOST_EXPIRED = "EXPIRED"
14+
15+
CDH_ZONE_SOLD_OUT_FOR_SPECIFIED_INSTANCE_ERROR = "ResourceInsufficient.ZoneSoldOutForSpecifiedInstance"
1416
)
1517

1618
var CDH_PREPAID_PERIOD = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36}

tencentcloud/resource_tc_cdh_instance.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
3737
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
38+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
3839
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
3940
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
4041
)
@@ -138,22 +139,22 @@ func resourceTencentCloudCdhInstance() *schema.Resource {
138139
"memory_total_size": {
139140
Type: schema.TypeFloat,
140141
Computed: true,
141-
Description: "Instance memory total capacity, unit in GiB.",
142+
Description: "Instance memory total capacity, unit in GB.",
142143
},
143144
"memory_available_size": {
144145
Type: schema.TypeFloat,
145146
Computed: true,
146-
Description: "Instance memory available capacity, unit in GiB.",
147+
Description: "Instance memory available capacity, unit in GB.",
147148
},
148149
"disk_total_size": {
149150
Type: schema.TypeInt,
150151
Computed: true,
151-
Description: "Instance disk total capacity, unit in GiB.",
152+
Description: "Instance disk total capacity, unit in GB.",
152153
},
153154
"disk_available_size": {
154155
Type: schema.TypeInt,
155156
Computed: true,
156-
Description: "Instance disk available capacity, unit in GiB.",
157+
Description: "Instance disk available capacity, unit in GB.",
157158
},
158159
"disk_type": {
159160
Type: schema.TypeString,
@@ -202,6 +203,9 @@ func resourceTencentCloudCdhInstanceCreate(d *schema.ResourceData, meta interfac
202203
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
203204
hostId, inErr = cdhService.CreateCdhInstance(ctx, &placement, &hostChargePrepaid, chargeType, hostType)
204205
if inErr != nil {
206+
if sdkErr, ok := inErr.(*sdkErrors.TencentCloudSDKError); ok && sdkErr.Code == CDH_ZONE_SOLD_OUT_FOR_SPECIFIED_INSTANCE_ERROR {
207+
return resource.NonRetryableError(inErr)
208+
}
205209
return retryError(inErr)
206210
}
207211
return nil

website/docs/d/cdh_instances.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ In addition to all arguments above, the following attributes are exported:
5050
* `host_resource` - An information list of host resource. Each element contains the following attributes:
5151
* `cpu_available_num` - The number of available CPU cores of the instance.
5252
* `cpu_total_num` - The number of total CPU cores of the instance.
53-
* `disk_available_size` - Instance disk available capacity, unit in GiB.
54-
* `disk_total_size` - Instance disk total capacity, unit in GiB.
53+
* `disk_available_size` - Instance disk available capacity, unit in GB.
54+
* `disk_total_size` - Instance disk total capacity, unit in GB.
5555
* `disk_type` - Type of the disk.
56-
* `memory_available_size` - Instance memory available capacity, unit in GiB.
57-
* `memory_total_size` - Instance memory total capacity, unit in GiB.
56+
* `memory_available_size` - Instance memory available capacity, unit in GB.
57+
* `memory_total_size` - Instance memory total capacity, unit in GB.
5858
* `host_state` - State of the CDH instance.
5959
* `host_type` - Type of the CDH instance.
6060
* `prepaid_renew_flag` - Auto renewal flag.

website/docs/r/cdh_instance.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ In addition to all arguments above, the following attributes are exported:
5151
* `host_resource` - An information list of host resource. Each element contains the following attributes:
5252
* `cpu_available_num` - The number of available CPU cores of the instance.
5353
* `cpu_total_num` - The number of total CPU cores of the instance.
54-
* `disk_available_size` - Instance disk available capacity, unit in GiB.
55-
* `disk_total_size` - Instance disk total capacity, unit in GiB.
54+
* `disk_available_size` - Instance disk available capacity, unit in GB.
55+
* `disk_total_size` - Instance disk total capacity, unit in GB.
5656
* `disk_type` - Type of the disk.
57-
* `memory_available_size` - Instance memory available capacity, unit in GiB.
58-
* `memory_total_size` - Instance memory total capacity, unit in GiB.
57+
* `memory_available_size` - Instance memory available capacity, unit in GB.
58+
* `memory_total_size` - Instance memory total capacity, unit in GB.
5959
* `host_state` - State of the CDH instance.
6060

6161

0 commit comments

Comments
 (0)