Skip to content

Commit

Permalink
Merge branch 'feat/ebmNuma' into 'feat/mysqlProject'
Browse files Browse the repository at this point in the history
feat: support numa_per_socket for ebm instance

See merge request iaasng/terraform-provider-volcengine!467
  • Loading branch information
zpp12354321 committed Jan 2, 2024
2 parents 2c2e46b + 9d0492e commit 7a000a3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
24 changes: 22 additions & 2 deletions volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,29 @@ func ResourceVolcengineEcsInstance() *schema.Resource {
Schema: map[string]*schema.Schema{
"threads_per_core": {
Type: schema.TypeInt,
Required: true,
Optional: true,
Computed: true,
ForceNew: true,
Description: "The per core of threads, only support for ebm. `1` indicates disabling hyper threading function.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
//暂时增加这个逻辑 在不包含ebm的情况下 忽略掉这个变化 目前这个方式比较hack 后续接口能力完善后改变一下
if it, ok := d.Get("instance_type").(string); ok {
its := strings.Split(it, ".")
if len(its) == 3 && !strings.Contains(strings.ToLower(its[1]), "ebm") {
return true
} else {
return false
}
} else {
return true
}
},
},
"numa_per_socket": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Description: "The per core of threads,only support for ebm.",
Description: "The number of subnuma in socket, only support for ebm. `1` indicates disabling SNC/NPS function. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
//暂时增加这个逻辑 在不包含ebm的情况下 忽略掉这个变化 目前这个方式比较hack 后续接口能力完善后改变一下
if it, ok := d.Get("instance_type").(string); ok {
Expand Down
14 changes: 14 additions & 0 deletions volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ func (s *VolcengineEcsService) ReadResource(resourceData *schema.ResourceData, i
if len(data) == 0 {
return data, fmt.Errorf("Ecs Instance %s not exist ", instanceId)
}

if numa := resourceData.Get("cpu_options.0.numa_per_socket"); numa != 0 {
if v, exist := data["CpuOptions"]; exist {
cpuOptions, ok := v.(map[string]interface{})
if !ok {
return data, fmt.Errorf("CpuOptions is not map ")
}
cpuOptions["NumaPerSocket"] = numa
}
}

return data, nil
}

Expand Down Expand Up @@ -440,6 +451,9 @@ func (s *VolcengineEcsService) CreateResource(resourceData *schema.ResourceData,
"threads_per_core": {
TargetField: "ThreadsPerCore",
},
"numa_per_socket": {
TargetField: "NumaPerSocket",
},
},
},
"secondary_network_interfaces": {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/ecs_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ SpotWithPriceLimit: spot instance with a set upper limit for bidding price.

The `cpu_options` object supports the following:

* `threads_per_core` - (Required, ForceNew) The per core of threads,only support for ebm.
* `numa_per_socket` - (Optional, ForceNew) The number of subnuma in socket, only support for ebm. `1` indicates disabling SNC/NPS function. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.
* `threads_per_core` - (Optional, ForceNew) The per core of threads, only support for ebm. `1` indicates disabling hyper threading function.

The `data_volumes` object supports the following:

Expand Down

0 comments on commit 7a000a3

Please sign in to comment.