Skip to content

Commit 8f9e476

Browse files
committed
feat(modelarts): add new resource to manage v2 resource pool
1 parent f0c6357 commit 8f9e476

File tree

6 files changed

+1675
-2
lines changed

6 files changed

+1675
-2
lines changed

docs/resources/modelarts_resource_pool.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ description: ""
77

88
# huaweicloud_modelarts_resource_pool
99

10-
Manages a ModelArts dedicated resource pool resource within HuaweiCloud.
10+
Manages a ModelArts dedicated resource pool resource within HuaweiCloud.
11+
12+
-> It is recommended to use `huaweicloud_modelartsv2_resource_pool` resource to create resource pool.
1113

1214
~> If you want to expand hyper instance nodes, the provider version must be `1.75.5` or later.
1315

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
---
2+
subcategory: "AI Development Platform (ModelArts)"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_modelartsv2_resource_pool"
5+
description: |-
6+
Manages a ModelArts resource pool resource within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_modelartsv2_resource_pool
10+
11+
Manages a ModelArts resource pool resource within HuaweiCloud.
12+
13+
## Example Usage
14+
15+
```hcl
16+
17+
```
18+
19+
## Argument Reference
20+
21+
The following arguments are supported:
22+
23+
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
24+
If omitted, the provider-level region will be used.
25+
Changing this creates a new resource.
26+
27+
* `metadata` - (Required, List) Specifies the metadata of the resource pool.
28+
The [metadata](#v2_resource_pool_metadata) structure is documented below.
29+
For more fileds details, please refer to the [document](https://support.huaweicloud.com/intl/en-us/api-modelarts/CreatePool.html#EN-US_TOPIC_0000001868289874__request_PoolMetadataCreation).
30+
31+
* `spec` - (Optional, List) Specifies the specification of the resource pool.
32+
The [spec](#v2_resource_pool_spec) structure is documented below.
33+
34+
<a name="v2_resource_pool_metadata"></a>
35+
The `metadata` block supports:
36+
37+
* `labels` - (Required, String) Specifies the labels of the resource pool, in JSON format.
38+
39+
* `annotations` - (Optional, String) Specifies the annotations of the resource pool, in JSON format.
40+
41+
-> When creating a resource pool, the billing-related parameters in this parameter indicate the resource pool,
42+
and when expanding, it indicates the nodes and will be applied to all nodes that are expanded under
43+
the `resources` parameter.
44+
45+
<a name="v2_resource_pool_spec"></a>
46+
The `spec` block supports:
47+
48+
* `type` - (Required, String, NonUpdatable) Specifies the type of the resource pool.
49+
50+
* `resources` - (Required, List) Specifies the list of resource specifications in the resource pool.
51+
Including resource flavors and the number of resources of the corresponding flavors.
52+
The [resources](#v2_resource_pool_spec_resources) structure is documented below.
53+
54+
-> If you want to update `resources`, the order of the `resources` list must be consistent with the one
55+
used during creation.
56+
57+
~> If the updated `resources` list is inconsistent with the created one, the expanded node may extend to other nodes.
58+
59+
* `scope` - (Optional, List) Specifies the list of job types supported by the resource pool.
60+
The valid values are as follows:
61+
+ **Train**: Training job.
62+
+ **Infer**: Inference job.
63+
+ **Notebook**: Notebook job.
64+
65+
* `network` - (Optional, List, NonUpdatable) Specifies the network of the resource pool.
66+
This parameter is only valid and required for physical resource pool.
67+
The [network](#v2_resource_pool_spec_network) structure is documented below.
68+
69+
* `user_login` - (Optional, List, NonUpdatable) Specifies the user login information of the privileged pool.
70+
The [user_login](#v2_resource_pool_spec_user_login) structure is documented below.
71+
72+
* `clusters` - (Optional, List, NonUpdatable) Specifies the cluster information of the privileged pool.
73+
The [clusters](#v2_resource_pool_spec_clusters) structure is documented below.
74+
75+
<a name="v2_resource_pool_spec_resources"></a>
76+
The `resources` block supports:
77+
78+
* `flavor` - (Required, String) Specifies the flavor of the resource pool.
79+
80+
* `count` - (Required, Int) Specifies the count of the resource pool.
81+
82+
* `max_count` - (Optional, Int) Specifies the max number of resources of the corresponding flavors.
83+
84+
* `node_pool` - (Optional, String) Specifies the name of resource pool nodes.
85+
86+
* `taints` - (Optional, List) Specifies the taint list of the resource pool.
87+
This parameter cannot be specified for non-privileged pools.
88+
The [taints](#v2_resource_pool_spec_resources_taints) structure is documented below.
89+
90+
* `labels` - (Optional, Map) Specifies the key/value pairs labels of resource pool.
91+
This parameter cannot be specified for non-privileged pools.
92+
93+
* `tags` - (Optional, List) Specifies the tags of resource pool.
94+
The [tags](#v2_resource_pool_spec_resources_tags) structure is documented below.
95+
96+
* `network` - (Optional, List) Specifies the network of the privileged pool.
97+
This parameter cannot be specified for non-privileged pools.
98+
The [network](#v2_resource_pool_spec_resources_network) structure is documented below.
99+
100+
* `extend_params` - (Optional, String) Specifies the extend params of the resource pool, in JSON format.
101+
102+
* `creating_step` - (Optional, List) Specifies the creation step configuration of the
103+
resource pool nodes.
104+
This parameter cannot be updated.
105+
The [creating_step](#v2_resource_pool_spec_resources_creating_step) structure is documented below.
106+
107+
* `root_volume` - (Optional, List) Specifies the root volume of the resource pool nodes.
108+
The [root_volume](#v2_resource_pool_spec_resources_root_volume) structure is documented below.
109+
110+
* `data_volumes` - (Optional, List) Specifies the data volumes of the resource pool nodes.
111+
The [data_volumes](#v2_resource_pool_spec_resources_data_volumes) structure is documented below.
112+
113+
* `volume_group_configs` - (Optional, List) Specifies the extend configurations of the volume groups.
114+
This parameter is required when custom data disks is specified.
115+
The [volume_group_configs](#v2_resource_pool_spec_resources_volume_group_configs) structure is documented below.
116+
117+
* `os` - (Optional, List) Specifies the image information for the specified OS.
118+
The [os](#v2_resource_pool_spec_resources_os) structure is documented below.
119+
120+
* `driver` - (Optional, List) Specifies the driver information.
121+
The [driver](#v2_resource_pool_spec_resources_driver) structure is documented below.
122+
123+
<a name="v2_resource_pool_spec_resources_taints"></a>
124+
The `taints` block supports:
125+
126+
* `key` - (Required, String) Specifies the key of the taint.
127+
128+
* `effect` - (Required, String) Specifies the effect of the taint.
129+
130+
* `value` - (Optional, String) Specifies the value of the taint.
131+
132+
<a name="v2_resource_pool_spec_resources_tags"></a>
133+
The `tags` block supports:
134+
135+
* `key` - (Required, String) Specifies the key of the tag.
136+
Cannot start with `CCE-` or `__type_baremetal`.
137+
138+
* `value` - (Required, String) Specifies the value of the tag.
139+
140+
<a name="v2_resource_pool_spec_resources_network"></a>
141+
The `network` block supports:
142+
143+
* `vpc` - (Optional, String) Specifies the ID of the VPC.
144+
145+
* `subnet` - (Optional, String) Specifies the ID of the subnet.
146+
147+
* `security_groups` - (Optional, List) Specifies the ID list of the security group.
148+
149+
<a name="v2_resource_pool_spec_resources_creating_step"></a>
150+
The `creating_step` block supports:
151+
152+
* `step` - (Required, Int) Specifies the creation step of the resource pool nodes.
153+
154+
* `type` - (Required, String) Specifies the type of the resource pool nodes.
155+
The valid values are as follows:
156+
+ **hyperinstance**
157+
158+
<a name="v2_resource_pool_spec_resources_root_volume"></a>
159+
The `root_volume` block supports:
160+
161+
* `size` - (Required, String) Specifies the size of the root volume.
162+
163+
* `volume_type` - (Required, String) Specifies the type of the root volume, in Gi.
164+
The valid values are as follows:
165+
+ **SSD**
166+
+ **GPSSD**
167+
+ **SAS**
168+
169+
<a name="v2_resource_pool_spec_resources_data_volumes"></a>
170+
The `data_volumes` block supports:
171+
172+
* `volume_type` - (Required, String) Specifies the type of the data volume.
173+
The valid values are as follows:
174+
+ **SSD**
175+
+ **GPSSD**
176+
+ **SAS**
177+
178+
* `size` - (Required, String) Specifies the size of the data volume, in Gi.
179+
180+
* `extend_params` - (Optional, String) Specifies the extend parameters of the data volume, in JSON format.
181+
182+
* `count` - (Optional, Int) Specifies the count of the current data volume configuration.
183+
184+
<a name="v2_resource_pool_spec_resources_volume_group_configs"></a>
185+
The `volume_group_configs` block supports:
186+
187+
* `volume_group` - (Required, String) Specifies the name of the volume group.
188+
189+
* `docker_thin_pool` - (Optional, Int) Specifies the percentage of container volumes to data volumes
190+
on resource pool nodes.
191+
This is only valid when the disk group name is **vgpass**.
192+
193+
* `lvm_config` - (Optional, List) Specifies the configuration of the LVM management.
194+
The [lvm_config](#v2_resource_pool_spec_resources_volume_group_configs_lvm_config) structure is documented below.
195+
196+
* `types` - (Optional, List) Specifies the storage types of the volume group.
197+
The valid values are as follows:
198+
+ **volume**
199+
+ **local**: Local disk, this parameter must be specified.
200+
201+
<a name="v2_resource_pool_spec_resources_os"></a>
202+
The `os` block supports:
203+
204+
* `name` - (Optional, String) Specifies the OS name of the image.
205+
206+
* `image_id` - (Optional, String) Specifies the image ID.
207+
208+
* `image_type` - (Optional, String) Specifies the image type.
209+
210+
<a name="v2_resource_pool_spec_resources_driver"></a>
211+
The `driver` block supports:
212+
213+
* `version` - (Optional, String) Specifies the driver version.
214+
215+
<a name="v2_resource_pool_spec_resources_volume_group_configs_lvm_config"></a>
216+
The `lvm_config` block supports:
217+
218+
* `lv_type` - (Required, String) Specifies the LVM write mode.
219+
The valid values are as follows:
220+
+ **liner**: Linear mode.
221+
+ **striped**: Stripe mode.
222+
223+
* `path` - (Optional, String) Specifies the volume mount path.
224+
Only numbers, letters, dots (.), hyphens (-), and underscores (_) are allowed.
225+
226+
<a name="v2_resource_pool_spec_network"></a>
227+
The `network` block supports:
228+
229+
* `name` - (Optional, String, NonUpdatable) Specifies the name of the network.
230+
231+
* `vpc_id` - (Optional, String, NonUpdatable) Specifies the ID of the VPC.
232+
For privileged pool, this parameter is only valid and required.
233+
234+
* `subnet_id` - (Optional, String, NonUpdatable) Specifies the ID of the subnet.
235+
For privileged pool, this parameter is only valid and required.
236+
237+
<a name="v2_resource_pool_spec_user_login"></a>
238+
The `user_login` block supports:
239+
240+
* `key_pair_name` - (Optional, String, NonUpdatable) Specifies the name of the key pair.
241+
242+
* `password` - (Optional, String, NonUpdatable) Specifies the password of the resource pool.
243+
The value needs to be salted, encrypted and Base64 encoded. Default user is **root**.
244+
245+
<a name="v2_resource_pool_spec_clusters"></a>
246+
The `clusters` block supports:
247+
248+
* `name` - (Optional, String, NonUpdatable) Specifies the name of the cluster.
249+
250+
* `provider_id` - (Optional, String, NonUpdatable) Specifies the provider ID of the cluster.
251+
252+
## Attribute Reference
253+
254+
In addition to all arguments above, the following attributes are exported:
255+
256+
* `id` - The resource ID.
257+
258+
## Timeouts
259+
260+
This resource provides the following timeouts configuration options:
261+
262+
* `create` - Default is 90 minutes.
263+
* `update` - Default is 90 minutes.
264+
* `delete` - Default is 30 minutes.
265+
266+
## Import
267+
268+
The resource can be imported using `id`, e.g.
269+
270+
```bash
271+
$ terraform import huaweicloud_modelartsv2_resource_pool.test <id>
272+
```
273+
274+
Please add the followings if some attributes are missing when importing the resource.
275+
276+
Note that the imported state may not be identical to your resource definition, due to some attributes missing from the
277+
API response, security or some other reason.
278+
The missing attributes include: `user_login`.
279+
It is generally recommended running `terraform plan` after importing the resource.
280+
You can then decide if changes should be applied to the resource, or the resource definition should be updated to
281+
align with the resource. Also you can ignore changes as below.
282+
283+
```hcl
284+
resource "huaweicloud_modelartsv2_resource_pool" "test" {
285+
...
286+
287+
lifecycle {
288+
ignore_changes = [
289+
user_login, metadata.annotations,
290+
]
291+
}
292+
}

huaweicloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,7 @@ func Provider() *schema.Provider {
23452345
// Resource management via V2 APIs.
23462346
"huaweicloud_modelartsv2_node_batch_delete": modelarts.ResourceV2NodeBatchDelete(),
23472347
"huaweicloud_modelartsv2_node_batch_unsubscribe": modelarts.ResourceV2NodeBatchUnsubscribe(),
2348+
"huaweicloud_modelartsv2_resource_pool": modelarts.Resourcev2ResourcePool(),
23482349
"huaweicloud_modelartsv2_service": modelarts.ResourceV2Service(),
23492350
"huaweicloud_modelartsv2_service_action": modelarts.ResourceV2ServiceAction(),
23502351

huaweicloud/services/modelarts/resource_huaweicloud_modelarts_node_batch_unsubscribe.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func waitForV2NodeBatchUnsubscribeCompleted(ctx context.Context, client *golangs
7474
Target: []string{"COMPLETED"},
7575
Refresh: func() (interface{}, string, error) {
7676
nodes, err := listV2ResourcePoolNodes(client, resourcePoolName)
77+
// 404: The resource pool does not exist.
78+
if _, ok := err.(golangsdk.ErrDefault404); ok {
79+
return nil, "COMPLETED", nil
80+
}
81+
7782
if err != nil {
7883
return nil, "ERROR", err
7984
}

huaweicloud/services/modelarts/resource_huaweicloud_modelarts_resource_pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ func resourceModelartsResourcePoolUpdate(ctx context.Context, d *schema.Resource
14711471
}
14721472

14731473
updateResourcePoolOpt.JSONBody = utils.RemoveNil(buildUpdateResourcePoolBodyParams(d))
1474-
updateModelartsResourcePoolResp, err := updateResourcePoolClient.Request("PATCH", updateResourcePoolPath, &updateResourcePoolOpt)
1474+
updateModelartsResourcePoolResp, err := updateResourcePoolClient.Request("PATCH11", updateResourcePoolPath, &updateResourcePoolOpt)
14751475
if err != nil {
14761476
return diag.Errorf("error updating Modelarts resource pool: %s", err)
14771477
}

0 commit comments

Comments
 (0)