Skip to content

Commit 9034610

Browse files
mingxiaravinitp
authored andcommitted
Added - Support for OKE: Node Cycling Improvements
1 parent 97ff1b6 commit 9034610

10 files changed

+341
-9
lines changed

examples/container_engine/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ variable "node_pool_cycling_details_maximum_unavailable" {
4848
default = "0"
4949
}
5050

51+
variable "node_pool_cycling_details_cycle_modes" {
52+
default = ["INSTANCE_REPLACE"]
53+
}
54+
5155
variable "node_pool_state" {
5256
default = []
5357
}
@@ -261,6 +265,7 @@ resource "oci_containerengine_node_pool" "test_node_pool" {
261265
is_node_cycling_enabled = var.node_pool_cycling_details_is_node_cycling_enabled
262266
maximum_surge = var.node_pool_cycling_details_maximum_surge
263267
maximum_unavailable = var.node_pool_cycling_details_maximum_unavailable
268+
cycle_modes = var.node_pool_cycling_details_cycle_modes
264269
}
265270

266271
node_source_details {
@@ -282,7 +287,7 @@ resource "oci_containerengine_node_pool" "test_flex_shape_node_pool" {
282287
compartment_id = var.compartment_ocid
283288
kubernetes_version = reverse(data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions)[0]
284289
name = "flexShapePool"
285-
node_shape = "VM.Standard.E4.Flex"
290+
node_shape = "VM.Standard.E5.Flex"
286291
subnet_ids = [oci_core_subnet.nodePool_Subnet_1.id]
287292

288293
node_source_details {

internal/integrationtest/containerengine_node_pool_cycling_test.go

Lines changed: 250 additions & 0 deletions
Large diffs are not rendered by default.

internal/integrationtest/containerengine_node_pool_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var (
5959
"node_pool_cycling_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ContainerengineNodePoolNodePoolCyclingDetailsRepresentation},
6060
"ssh_public_key": acctest.Representation{RepType: acctest.Optional, Create: `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample`},
6161
"node_config_details": acctest.RepresentationGroup{RepType: acctest.Required, Group: nodeConfigDetailsRepresentation},
62-
"node_eviction_node_pool_settings": acctest.RepresentationGroup{RepType: acctest.Optional, Group: nodePoolNodeEvictionNodePoolSettingsRepresentation},
62+
"node_eviction_node_pool_settings": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ContainerengineNodePoolNodeEvictionNodePoolSettingsRepresentation},
6363
}
6464

6565
nodeConfigDetailsRepresentation = map[string]interface{}{
@@ -88,11 +88,14 @@ var (
8888
"key": acctest.Representation{RepType: acctest.Optional, Create: `key`, Update: `key2`},
8989
"value": acctest.Representation{RepType: acctest.Optional, Create: `value`, Update: `value2`},
9090
}
91-
nodePoolNodeEvictionNodePoolSettingsRepresentation = map[string]interface{}{
91+
92+
ContainerengineNodePoolNodeEvictionNodePoolSettingsRepresentation = map[string]interface{}{
9293
"eviction_grace_duration": acctest.Representation{RepType: acctest.Optional, Create: `PT1H`, Update: `PT50M`},
94+
"is_force_action_after_grace_duration": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
9395
"is_force_delete_after_grace_duration": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
9496
}
9597
ContainerengineNodePoolNodePoolCyclingDetailsRepresentation = map[string]interface{}{
98+
"cycle_modes": acctest.Representation{RepType: acctest.Optional, Create: []string{"INSTANCE_REPLACE"}, Update: []string{"INSTANCE_REPLACE"}},
9699
"is_node_cycling_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
97100
"maximum_surge": acctest.Representation{RepType: acctest.Optional, Create: `1`, Update: `2`},
98101
"maximum_unavailable": acctest.Representation{RepType: acctest.Optional, Create: `0`, Update: `1`},
@@ -164,7 +167,10 @@ var (
164167
})) +
165168
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "nodePool_Subnet_1", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{"security_list_ids": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_core_security_list.test_security_list.id}`}}, "route_table_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_route_table.test_route_table.id}`}, "availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`}, "cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.22.0/24`}, "dns_label": acctest.Representation{RepType: acctest.Required, Create: `nodepool1`}})) +
166169
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "nodePool_Subnet_2", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{"security_list_ids": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_core_security_list.test_security_list.id}`}}, "route_table_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_route_table.test_route_table.id}`}, "availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`}, "cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.23.0/24`}, "dns_label": acctest.Representation{RepType: acctest.Required, Create: `nodepool2`}})) +
167-
acctest.GenerateResourceFromRepresentationMap("oci_containerengine_cluster", "test_cluster", acctest.Required, acctest.Create, ContainerengineClusterRepresentation) +
170+
acctest.GenerateResourceFromRepresentationMap("oci_containerengine_cluster", "test_cluster", acctest.Required, acctest.Create,
171+
acctest.RepresentationCopyWithNewProperties(ContainerengineClusterRepresentation, map[string]interface{}{
172+
"type": acctest.Representation{RepType: acctest.Required, Create: `ENHANCED_CLUSTER`, Update: `ENHANCED_CLUSTER`},
173+
})) +
168174
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "clusterSubnet_1", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{"security_list_ids": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_core_security_list.test_security_list.id}`}}, "availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`}, "cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.20.0/24`}, "dns_label": acctest.Representation{RepType: acctest.Required, Create: `cluster1`}})) +
169175
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "clusterSubnet_2", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{"security_list_ids": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_core_security_list.test_security_list.id}`}}, "availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}`}, "cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.21.0/24`}, "dns_label": acctest.Representation{RepType: acctest.Required, Create: `cluster2`}})) +
170176
AvailabilityDomainConfig +
@@ -201,7 +207,8 @@ func TestContainerengineNodePoolResource_basic(t *testing.T) {
201207
acctest.ResourceTest(t, testAccCheckContainerengineNodePoolDestroy, []resource.TestStep{
202208
// verify Create
203209
{
204-
Config: config + compartmentIdVariableStr + ContainerengineNodePoolResourceDependencies + nodePoolResourceConfigForVMStandard + acctest.GenerateResourceFromRepresentationMap("oci_containerengine_node_pool", "test_node_pool", acctest.Required, acctest.Create, nodePoolRepresentation),
210+
Config: config + compartmentIdVariableStr + ContainerengineNodePoolResourceDependencies + nodePoolResourceConfigForVMStandard +
211+
acctest.GenerateResourceFromRepresentationMap("oci_containerengine_node_pool", "test_node_pool", acctest.Required, acctest.Create, nodePoolRepresentation),
205212
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
206213
resource.TestCheckResourceAttrSet(resourceName, "cluster_id"),
207214
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -235,10 +242,12 @@ func TestContainerengineNodePoolResource_basic(t *testing.T) {
235242
resource.TestCheckResourceAttr(resourceName, "name", "name"),
236243
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.#", "1"),
237244
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.eviction_grace_duration", "PT1H"),
245+
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.is_force_action_after_grace_duration", "false"),
238246
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.is_force_delete_after_grace_duration", "false"),
239247
resource.TestCheckResourceAttrSet(resourceName, "node_image_id"),
240248
resource.TestCheckResourceAttr(resourceName, "node_metadata.%", "1"),
241249
resource.TestCheckResourceAttr(resourceName, "node_pool_cycling_details.#", "1"),
250+
resource.TestCheckResourceAttr(resourceName, "node_pool_cycling_details.0.cycle_modes.#", "1"),
242251
resource.TestCheckResourceAttr(resourceName, "node_pool_cycling_details.0.is_node_cycling_enabled", "false"),
243252
resource.TestCheckResourceAttr(resourceName, "node_pool_cycling_details.0.maximum_surge", "1"),
244253
resource.TestCheckResourceAttr(resourceName, "node_pool_cycling_details.0.maximum_unavailable", "0"),
@@ -275,6 +284,7 @@ func TestContainerengineNodePoolResource_basic(t *testing.T) {
275284
resource.TestCheckResourceAttr(resourceName, "name", "name2"),
276285
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.#", "1"),
277286
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.eviction_grace_duration", "PT50M"),
287+
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.is_force_action_after_grace_duration", "false"),
278288
resource.TestCheckResourceAttr(resourceName, "node_eviction_node_pool_settings.0.is_force_delete_after_grace_duration", "true"),
279289
resource.TestCheckResourceAttrSet(resourceName, "node_image_id"),
280290
resource.TestCheckResourceAttrSet(resourceName, "node_image_name"),
@@ -320,6 +330,7 @@ func TestContainerengineNodePoolResource_basic(t *testing.T) {
320330
resource.TestCheckResourceAttr(datasourceName, "node_pools.0.name", "name2"),
321331
resource.TestCheckResourceAttr(datasourceName, "node_pools.0.node_eviction_node_pool_settings.#", "1"),
322332
resource.TestCheckResourceAttr(datasourceName, "node_pools.0.node_eviction_node_pool_settings.0.eviction_grace_duration", "PT50M"),
333+
resource.TestCheckResourceAttr(datasourceName, "node_pools.0.node_eviction_node_pool_settings.0.is_force_action_after_grace_duration", "false"),
323334
resource.TestCheckResourceAttr(datasourceName, "node_pools.0.node_eviction_node_pool_settings.0.is_force_delete_after_grace_duration", "true"),
324335
resource.TestCheckResourceAttrSet(datasourceName, "node_pools.0.node_image_id"),
325336
resource.TestCheckResourceAttrSet(datasourceName, "node_pools.0.node_image_name"),
@@ -352,6 +363,7 @@ func TestContainerengineNodePoolResource_basic(t *testing.T) {
352363
resource.TestCheckResourceAttr(singularDatasourceName, "name", "name2"),
353364
resource.TestCheckResourceAttr(singularDatasourceName, "node_eviction_node_pool_settings.#", "1"),
354365
resource.TestCheckResourceAttr(singularDatasourceName, "node_eviction_node_pool_settings.0.eviction_grace_duration", "PT50M"),
366+
resource.TestCheckResourceAttr(singularDatasourceName, "node_eviction_node_pool_settings.0.is_force_action_after_grace_duration", "false"),
355367
resource.TestCheckResourceAttr(singularDatasourceName, "node_eviction_node_pool_settings.0.is_force_delete_after_grace_duration", "true"),
356368
resource.TestCheckResourceAttrSet(singularDatasourceName, "node_image_id"),
357369
resource.TestCheckResourceAttrSet(singularDatasourceName, "node_image_name"),

internal/service/containerengine/containerengine_cluster_data_source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func ContainerengineClusterDataSource() *schema.Resource {
1919
Type: schema.TypeString,
2020
Required: true,
2121
}
22+
fieldMap["should_include_oidc_config_file"] = &schema.Schema{
23+
Type: schema.TypeString,
24+
Optional: true,
25+
}
2226
return tfresource.GetSingularDataSourceItemSchema(ContainerengineClusterResource(), fieldMap, readSingularContainerengineCluster)
2327
}
2428

@@ -48,6 +52,11 @@ func (s *ContainerengineClusterDataSourceCrud) Get() error {
4852
request.ClusterId = &tmp
4953
}
5054

55+
if shouldIncludeOidcConfigFile, ok := s.D.GetOkExists("should_include_oidc_config_file"); ok {
56+
tmp := shouldIncludeOidcConfigFile.(bool)
57+
request.ShouldIncludeOidcConfigFile = &tmp
58+
}
59+
5160
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(false, "containerengine")
5261

5362
response, err := s.Client.GetCluster(context.Background(), request)

internal/service/containerengine/containerengine_cluster_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,11 @@ func (s *ContainerengineClusterResourceCrud) Get() error {
961961
tmp := s.D.Id()
962962
request.ClusterId = &tmp
963963

964+
if shouldIncludeOidcConfigFile, ok := s.D.GetOkExists("should_include_oidc_config_file"); ok {
965+
tmp := shouldIncludeOidcConfigFile.(bool)
966+
request.ShouldIncludeOidcConfigFile = &tmp
967+
}
968+
964969
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "containerengine")
965970

966971
response, err := s.Client.GetCluster(context.Background(), request)

internal/service/containerengine/containerengine_node_pool_resource.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ func ContainerengineNodePoolResource() *schema.Resource {
300300
Optional: true,
301301
Computed: true,
302302
},
303+
"is_force_action_after_grace_duration": {
304+
Type: schema.TypeBool,
305+
Optional: true,
306+
Computed: true,
307+
},
303308
"is_force_delete_after_grace_duration": {
304309
Type: schema.TypeBool,
305310
Optional: true,
@@ -343,6 +348,14 @@ func ContainerengineNodePoolResource() *schema.Resource {
343348
// Required
344349

345350
// Optional
351+
"cycle_modes": {
352+
Type: schema.TypeList,
353+
Optional: true,
354+
Computed: true,
355+
Elem: &schema.Schema{
356+
Type: schema.TypeString,
357+
},
358+
},
346359
"is_node_cycling_enabled": {
347360
Type: schema.TypeBool,
348361
Optional: true,
@@ -1631,6 +1644,11 @@ func (s *ContainerengineNodePoolResourceCrud) mapToNodeEvictionNodePoolSettings(
16311644
result.EvictionGraceDuration = &tmp
16321645
}
16331646

1647+
if isForceActionAfterGraceDuration, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_force_action_after_grace_duration")); ok {
1648+
tmp := isForceActionAfterGraceDuration.(bool)
1649+
result.IsForceActionAfterGraceDuration = &tmp
1650+
}
1651+
16341652
if isForceDeleteAfterGraceDuration, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_force_delete_after_grace_duration")); ok {
16351653
tmp := isForceDeleteAfterGraceDuration.(bool)
16361654
result.IsForceDeleteAfterGraceDuration = &tmp
@@ -1646,6 +1664,10 @@ func NodeEvictionNodePoolSettingsToMap(obj *oci_containerengine.NodeEvictionNode
16461664
result["eviction_grace_duration"] = string(*obj.EvictionGraceDuration)
16471665
}
16481666

1667+
if obj.IsForceActionAfterGraceDuration != nil {
1668+
result["is_force_action_after_grace_duration"] = bool(*obj.IsForceActionAfterGraceDuration)
1669+
}
1670+
16491671
if obj.IsForceDeleteAfterGraceDuration != nil {
16501672
result["is_force_delete_after_grace_duration"] = bool(*obj.IsForceDeleteAfterGraceDuration)
16511673
}
@@ -1656,6 +1678,19 @@ func NodeEvictionNodePoolSettingsToMap(obj *oci_containerengine.NodeEvictionNode
16561678
func (s *ContainerengineNodePoolResourceCrud) mapToNodePoolCyclingDetails(fieldKeyFormat string) (oci_containerengine.NodePoolCyclingDetails, error) {
16571679
result := oci_containerengine.NodePoolCyclingDetails{}
16581680

1681+
if cycleModes, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "cycle_modes")); ok {
1682+
interfaces := cycleModes.([]interface{})
1683+
tmp := make([]oci_containerengine.CycleModeEnum, len(interfaces))
1684+
for i := range interfaces {
1685+
if interfaces[i] != nil {
1686+
tmp[i] = oci_containerengine.CycleModeEnum(interfaces[i].(string))
1687+
}
1688+
}
1689+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "cycle_modes")) {
1690+
result.CycleModes = tmp
1691+
}
1692+
}
1693+
16591694
if isNodeCyclingEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_node_cycling_enabled")); ok {
16601695
tmp := isNodeCyclingEnabled.(bool)
16611696
result.IsNodeCyclingEnabled = &tmp
@@ -1677,6 +1712,8 @@ func (s *ContainerengineNodePoolResourceCrud) mapToNodePoolCyclingDetails(fieldK
16771712
func NodePoolCyclingDetailsToMap(obj *oci_containerengine.NodePoolCyclingDetails) map[string]interface{} {
16781713
result := map[string]interface{}{}
16791714

1715+
result["cycle_modes"] = obj.CycleModes
1716+
16801717
if obj.IsNodeCyclingEnabled != nil {
16811718
result["is_node_cycling_enabled"] = bool(*obj.IsNodeCyclingEnabled)
16821719
}

website/docs/d/containerengine_cluster.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Get the details of a cluster.
1818
data "oci_containerengine_cluster" "test_cluster" {
1919
#Required
2020
cluster_id = oci_containerengine_cluster.test_cluster.id
21+
22+
#Optional
23+
should_include_oidc_config_file = var.cluster_should_include_oidc_config_file
2124
}
2225
```
2326

@@ -26,6 +29,7 @@ data "oci_containerengine_cluster" "test_cluster" {
2629
The following arguments are supported:
2730

2831
* `cluster_id` - (Required) The OCID of the cluster.
32+
* `should_include_oidc_config_file` - (Optional) Boolean value to determine if the OpenIdConnectAuth configuration file should be displayed for the provided cluster.
2933

3034

3135
## Attributes Reference

website/docs/d/containerengine_node_pool.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ The following attributes are exported:
6868
* `size` - The number of nodes in the node pool.
6969
* `node_eviction_node_pool_settings` - Node Eviction Details configuration
7070
* `eviction_grace_duration` - Duration after which OKE will give up eviction of the pods on the node. PT0M will indicate you want to delete the node without cordon and drain. Default PT60M, Min PT0M, Max: PT60M. Format ISO 8601 e.g PT30M
71+
* `is_force_action_after_grace_duration` - If the node action should be performed if not all the pods can be evicted in the grace period
7172
* `is_force_delete_after_grace_duration` - If the underlying compute instance should be deleted if you cannot evict all the pods in grace period
7273
* `node_image_id` - Deprecated. see `nodeSource`. The OCID of the image running on the nodes in the node pool.
7374
* `node_image_name` - Deprecated. see `nodeSource`. The name of the image running on the nodes in the node pool.
7475
* `node_metadata` - A list of key/value pairs to add to each underlying Oracle Cloud Infrastructure instance in the node pool on launch.
7576
* `node_pool_cycling_details` - Node Pool Cycling Details
76-
* `is_node_cycling_enabled` - If nodes in the nodepool will be cycled to have new changes.
77+
* `cycle_modes` - An ordered list of cycle modes that should be performed on the OKE nodes.
78+
* `is_node_cycling_enabled` - If cycling operation should be performed on the nodes in the node pool.
7779
* `maximum_surge` - Maximum additional new compute instances that would be temporarily created and added to nodepool during the cycling nodepool process. OKE supports both integer and percentage input. Defaults to 1, Ranges from 0 to Nodepool size or 0% to 100%
7880
* `maximum_unavailable` - Maximum active nodes that would be terminated from nodepool during the cycling nodepool process. OKE supports both integer and percentage input. Defaults to 0, Ranges from 0 to Nodepool size or 0% to 100%
7981
* `node_shape` - The name of the node shape of the nodes in the node pool.

0 commit comments

Comments
 (0)