Skip to content
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

CCE: Nodes extend_params volume parameter introduced #2056

Merged
merged 3 commits into from Jan 19, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/resources/cce_node_pool_v3.md
Expand Up @@ -36,6 +36,13 @@ resource "opentelekomcloud_cce_node_pool_v3" "node_pool_1" {
size = 100
volumetype = "SSD"
}
data_volumes {
size = 100
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}
}
```

Expand Down Expand Up @@ -114,13 +121,17 @@ the AZ based on the AZ sequence. For more details see
* `root_volume` - (Required) It corresponds to the system disk related configuration. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.
* `extend_params` - (Optional) Disk expansion parameters. A list of strings which describes additional disk parameters.
* `extend_param` **DEPRECATED** - (Optional) Disk expansion parameters.
Please use alternative parameter `extend_params`.
* `kms_id` - (Optional) The Encryption KMS ID of the system volume. By default, it tries to get from env by `OS_KMS_ID`.

* `data_volumes` - (Required) Represents the data disk to be created. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.
* `extend_params` - (Optional) Disk expansion parameters. A list of strings which describes additional disk parameters.
* `extend_param` **DEPRECATED** - (Optional) Disk expansion parameters.
Please use alternative parameter `extend_params`.
* `kms_id` - (Optional) The Encryption KMS ID of the data volume. By default, it tries to get from env by `OS_KMS_ID`.

-> To enable encryption with the KMS. Firstly, you need to create the agency to grant KMS rights to EVS.
Expand Down
15 changes: 13 additions & 2 deletions docs/resources/cce_node_v3.md
Expand Up @@ -33,6 +33,13 @@ resource "opentelekomcloud_cce_node_v3" "node_1" {
size = 100
volumetype = "SATA"
}
data_volumes {
size = 100
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}
}
```

Expand Down Expand Up @@ -134,13 +141,17 @@ The following arguments are supported:
* `root_volume` - (Required) It corresponds to the system disk related configuration. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.
* `extend_params` - (Optional) Disk expansion parameters. A list of strings which describes additional disk parameters.
* `extend_param` **DEPRECATED** - (Optional) Disk expansion parameters.
Please use alternative parameter `extend_params`.
* `kms_id` - (Optional) The Encryption KMS ID of the system volume. By default, it tries to get from env by `OS_KMS_ID`.

* `data_volumes` - (Required) Represents the data disk to be created. Changing this parameter will create a new resource.
* `size` - (Required) Disk size in GB.
* `volumetype` - (Required) Disk type.
* `extend_param` - (Optional) Disk expansion parameters.
* `extend_params` - (Optional) Disk expansion parameters. A list of strings which describes additional disk parameters.
* `extend_param` **DEPRECATED** - (Optional) Disk expansion parameters.
Please use alternative parameter `extend_params`.
* `kms_id` - (Optional) The Encryption KMS ID of the data volume. By default, it tries to get from env by `OS_KMS_ID`.

-> To enable encryption with the KMS. Firstly, you need to create the agency to grant KMS rights to EVS.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -14,7 +14,7 @@ require (
github.com/jinzhu/copier v0.3.5
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
github.com/mitchellh/go-homedir v1.1.0
github.com/opentelekomcloud/gophertelekomcloud v0.5.27-0.20230110094736-54b55975ed5c
github.com/opentelekomcloud/gophertelekomcloud v0.5.28-0.20230118161751-e5094ee361b0
github.com/unknwon/com v1.0.1
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -207,8 +207,8 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/opentelekomcloud/gophertelekomcloud v0.5.27-0.20230110094736-54b55975ed5c h1:TOdxLN1shE19C1rufdBZR1mlV5nBvKxDXk+OCfXqr80=
github.com/opentelekomcloud/gophertelekomcloud v0.5.27-0.20230110094736-54b55975ed5c/go.mod h1:/QD0ZIzm3zMdE0iBSAP3+Z9eCViU2PgnQqp4KGrpR/M=
github.com/opentelekomcloud/gophertelekomcloud v0.5.28-0.20230118161751-e5094ee361b0 h1:zbeWVvggP6zeB4wH6zQFsZeYY5vEpEyPAmNcC7QFcqc=
github.com/opentelekomcloud/gophertelekomcloud v0.5.28-0.20230118161751-e5094ee361b0/go.mod h1:/QD0ZIzm3zMdE0iBSAP3+Z9eCViU2PgnQqp4KGrpR/M=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
Expand Up @@ -44,13 +44,15 @@ func TestAccCCENodePoolsV3_basic(t *testing.T) {
resource.TestCheckResourceAttr(nodePoolResourceName, "flavor", "s2.large.2"),
resource.TestCheckResourceAttr(nodePoolResourceName, "os", "EulerOS 2.5"),
resource.TestCheckResourceAttr(nodePoolResourceName, "k8s_tags.kubelet.kubernetes.io/namespace", "muh"),
resource.TestCheckResourceAttr(nodePoolResourceName, "data_volumes.0.extend_params.useType", "docker"),
),
},
{
Config: testAccCCENodePoolV3Update,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(nodePoolResourceName, "initial_node_count", "2"),
resource.TestCheckResourceAttr(nodePoolResourceName, "k8s_tags.kubelet.kubernetes.io/namespace", "kuh"),
resource.TestCheckResourceAttr(nodePoolResourceName, "data_volumes.0.extend_params.useType", "docker"),
),
},
},
Expand Down Expand Up @@ -257,6 +259,9 @@ resource "opentelekomcloud_cce_node_pool_v3" "node_pool" {
data_volumes {
size = 100
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}

k8s_tags = {
Expand All @@ -271,7 +276,7 @@ resource "opentelekomcloud_cce_node_pool_v3" "node_pool" {
cluster_id = data.opentelekomcloud_cce_cluster_v3.cluster.id
name = "opentelekomcloud-cce-node-pool"
os = "EulerOS 2.5"
flavor = "s3.medium.1"
flavor = "s2.large.2"
initial_node_count = 2
availability_zone = "%s"
key_pair = "%s"
Expand All @@ -289,6 +294,9 @@ resource "opentelekomcloud_cce_node_pool_v3" "node_pool" {
data_volumes {
size = 100
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}

k8s_tags = {
Expand Down
Expand Up @@ -45,12 +45,14 @@ func TestAccCCENodesV3Basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceNameNode, "flavor_id", "s2.large.2"),
resource.TestCheckResourceAttr(resourceNameNode, "os", "EulerOS 2.9"),
resource.TestCheckResourceAttr(resourceNameNode, "private_ip", privateIP),
resource.TestCheckResourceAttr(resourceNameNode, "data_volumes.0.extend_params.useType", "docker"),
),
},
{
Config: testAccCCENodeV3Update(privateIP),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceNameNode, "name", "test-node2"),
resource.TestCheckResourceAttr(resourceNameNode, "data_volumes.0.extend_params.useType", "docker"),
),
},
},
Expand Down Expand Up @@ -523,7 +525,10 @@ resource "opentelekomcloud_cce_node_v3" "node_1" {

data_volumes {
size = 100
volumetype = "SATA"
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}

private_ip = "%s"
Expand All @@ -549,7 +554,10 @@ resource "opentelekomcloud_cce_node_v3" "node_1" {
}
data_volumes {
size = 100
volumetype = "SATA"
volumetype = "SSD"
extend_params = {
"useType" = "docker"
}
}

private_ip = "%s"
Expand Down
Expand Up @@ -111,9 +111,16 @@ func ResourceCCENodePoolV3() *schema.Resource {
DefaultFunc: schema.EnvDefaultFunc("OS_KMS_ID", nil),
},
"extend_param": {
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "use extend_params instead",
},
"extend_params": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}},
},
Expand Down Expand Up @@ -141,9 +148,16 @@ func ResourceCCENodePoolV3() *schema.Resource {
DefaultFunc: schema.EnvDefaultFunc("OS_KMS_ID", nil),
},
"extend_param": {
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "use extend_params instead",
},
"extend_params": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}},
},
Expand Down Expand Up @@ -415,9 +429,10 @@ func resourceCCENodePoolV3Read(ctx context.Context, d *schema.ResourceData, meta

rootVolume := []map[string]interface{}{
{
"size": s.Spec.NodeTemplate.RootVolume.Size,
"volumetype": s.Spec.NodeTemplate.RootVolume.VolumeType,
"extend_param": s.Spec.NodeTemplate.RootVolume.ExtendParam,
"size": s.Spec.NodeTemplate.RootVolume.Size,
"volumetype": s.Spec.NodeTemplate.RootVolume.VolumeType,
"extend_params": s.Spec.NodeTemplate.RootVolume.ExtendParam,
"extend_param": "",
},
}
if s.Spec.NodeTemplate.RootVolume.Metadata != nil {
Expand Down Expand Up @@ -462,9 +477,10 @@ func resourceCCENodePoolV3Read(ctx context.Context, d *schema.ResourceData, meta
var volumes []interface{}
for _, pairObject := range s.Spec.NodeTemplate.DataVolumes {
volume := map[string]interface{}{
"size": pairObject.Size,
"volumetype": pairObject.VolumeType,
"extend_param": pairObject.ExtendParam,
"size": pairObject.Size,
"volumetype": pairObject.VolumeType,
"extend_params": pairObject.ExtendParam,
"extend_param": "",
}
if pairObject.Metadata != nil {
volume["kms_id"] = pairObject.Metadata["__system__cmkid"]
Expand Down
Expand Up @@ -149,9 +149,17 @@ func ResourceCCENodeV3() *schema.Resource {
DefaultFunc: schema.EnvDefaultFunc("OS_KMS_ID", nil),
},
"extend_param": {
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "use extend_params instead",
},
"extend_params": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}},
},
Expand All @@ -178,9 +186,17 @@ func ResourceCCENodeV3() *schema.Resource {
DefaultFunc: schema.EnvDefaultFunc("OS_KMS_ID", nil),
},
"extend_param": {
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "use extend_params instead",
},
"extend_params": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}},
},
Expand Down Expand Up @@ -419,7 +435,7 @@ func resourceCCEDataVolume(d *schema.ResourceData) []nodes.VolumeSpec {
volumes[i] = nodes.VolumeSpec{
Size: rawMap["size"].(int),
VolumeType: rawMap["volumetype"].(string),
ExtendParam: rawMap["extend_param"].(string),
ExtendParam: rawMap["extend_params"].(map[string]interface{}),
}
if kmsID := rawMap["kms_id"]; kmsID != "" {
volumes[i].Metadata = map[string]interface{}{
Expand All @@ -435,10 +451,10 @@ func resourceCCERootVolume(d *schema.ResourceData) nodes.VolumeSpec {
var nics nodes.VolumeSpec
nicsRaw := d.Get("root_volume").([]interface{})
if len(nicsRaw) == 1 {
nics.Size = nicsRaw[0].(map[string]interface{})["size"].(int)
nics.VolumeType = nicsRaw[0].(map[string]interface{})["volumetype"].(string)
nics.ExtendParam = nicsRaw[0].(map[string]interface{})["extend_param"].(string)
rawMap := nicsRaw[0].(map[string]interface{})
nics.Size = rawMap["size"].(int)
nics.VolumeType = rawMap["volumetype"].(string)
nics.ExtendParam = rawMap["extend_params"].(map[string]interface{})
if kmsID := rawMap["kms_id"]; kmsID != "" {
nics.Metadata = map[string]interface{}{
"__system__cmkid": kmsID,
Expand Down Expand Up @@ -685,7 +701,8 @@ func resourceCCENodeV3Read(ctx context.Context, d *schema.ResourceData, meta int
volume := make(map[string]interface{})
volume["size"] = dataVolume.Size
volume["volumetype"] = dataVolume.VolumeType
volume["extend_param"] = dataVolume.ExtendParam
volume["extend_params"] = dataVolume.ExtendParam
volume["extend_param"] = ""
if dataVolume.Metadata != nil {
volume["kms_id"] = dataVolume.Metadata["__system__cmkid"]
}
Expand All @@ -697,9 +714,10 @@ func resourceCCENodeV3Read(ctx context.Context, d *schema.ResourceData, meta int

rootVolume := []map[string]interface{}{
{
"size": node.Spec.RootVolume.Size,
"volumetype": node.Spec.RootVolume.VolumeType,
"extend_param": node.Spec.RootVolume.ExtendParam,
"size": node.Spec.RootVolume.Size,
"volumetype": node.Spec.RootVolume.VolumeType,
"extend_params": node.Spec.RootVolume.ExtendParam,
"extend_param": "",
},
}
if node.Spec.RootVolume.Metadata != nil {
Expand Down
12 changes: 12 additions & 0 deletions releasenotes/notes/cce_nodes_volume_fix-c7dd2f17bf531321.yaml
@@ -0,0 +1,12 @@
---
deprecations:
- |
**[CCE]** Deprecate `extend_param` for `volumes` in ``resource/opentelekomcloud_cce_node_v3`` (`#2056 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2056>`_)
- |
**[CCE]** Deprecate `extend_param` for `volumes` in ``resource/opentelekomcloud_cce_node_pool_v3`` (`#2056 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2056>`_)

fixes:
- |
**[CCE]** Added `extend_params` for `volumes` in ``resource/opentelekomcloud_cce_node_v3`` (`#2056 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2056>`_)
- |
**[CCE]** Added `extend_params` for `volumes` in ``resource/opentelekomcloud_cce_node_pool_v3`` (`#2056 <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/pull/2056>`_)