Skip to content

Commit 900cd4a

Browse files
XinruXiao-9ravinitp
authored andcommitted
Bug Fix - allow update native pod networking, only update placement config when there is a change
1 parent 2f1e004 commit 900cd4a

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

examples/container_engine/main.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ variable defined_tag_namespace_name {
7070

7171
provider "oci" {
7272
region = var.region
73-
tenancy_ocid = var.tenancy_ocid
74-
user_ocid = var.user_ocid
75-
fingerprint = var.fingerprint
76-
private_key_path = var.private_key_path
73+
auth = "SecurityToken"
74+
config_file_profile = "terraform-federation-test"
7775
}
7876

7977
resource "oci_identity_tag_namespace" "tag-namespace1" {
@@ -111,7 +109,7 @@ data "oci_kms_vault" "test_vault" {
111109

112110
data "oci_kms_keys" "test_keys_dependency_RSA" {
113111
#Required
114-
compartment_id = var.tenancy_ocid
112+
compartment_id = var.compartment_ocid
115113
management_endpoint = data.oci_kms_vault.test_vault.management_endpoint
116114
algorithm = "RSA"
117115

@@ -284,8 +282,8 @@ resource "oci_containerengine_node_pool" "test_flex_shape_node_pool" {
284282
compartment_id = var.compartment_ocid
285283
kubernetes_version = reverse(data.oci_containerengine_cluster_option.test_cluster_option.kubernetes_versions)[0]
286284
name = "flexShapePool"
287-
node_shape = "VM.Standard.E3.Flex"
288-
subnet_ids = [oci_core_subnet.nodePool_Subnet_1.id, oci_core_subnet.nodePool_Subnet_2.id]
285+
node_shape = "VM.Standard.E4.Flex"
286+
subnet_ids = [oci_core_subnet.nodePool_Subnet_1.id]
289287

290288
node_source_details {
291289
#Required
@@ -344,6 +342,7 @@ data "oci_containerengine_cluster_option" "test_cluster_option" {
344342

345343
data "oci_containerengine_node_pool_option" "test_node_pool_option" {
346344
node_pool_option_id = "all"
345+
compartment_id = var.compartment_ocid
347346
}
348347

349348
data "oci_core_images" "shape_specific_images" {

examples/container_engine/regional_subnet/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ variable "node_pool_node_shape" {
4646
}
4747

4848
variable "node_pool_quantity_per_subnet" {
49-
default = 2
49+
default = 1
5050
}
5151

5252
variable "node_pool_ssh_public_key" {

internal/integrationtest/containerengine_node_pool_option_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
var (
1919
ContainerengineContainerengineNodePoolOptionSingularDataSourceRepresentation = map[string]interface{}{
2020
"node_pool_option_id": acctest.Representation{RepType: acctest.Required, Create: `all`},
21-
"compartment_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compartment_id}`},
21+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
2222
}
2323

2424
ContainerengineNodePoolOptionResourceConfig = ""

internal/integrationtest/containerengine_node_pool_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
"placement_configs": acctest.RepresentationGroup{RepType: acctest.Required, Group: nodePoolNodeConfigDetailsPlacementConfigsRepresentation},
5959
"size": acctest.Representation{RepType: acctest.Required, Create: `2`, Update: `4`},
6060
}
61+
6162
nodePoolNodeConfigDetailsPlacementConfigsRepresentation = map[string]interface{}{
6263
"availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`, Update: `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}`},
6364
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.node_pool_regional_subnet_1.id}`, Update: `${oci_core_subnet.node_pool_regional_subnet_2.id}`},

internal/integrationtest/containerengine_node_pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ var (
175175
DefinedTagsDependencies +
176176
acctest.GenerateResourceFromRepresentationMap("oci_core_compute_capacity_reservation", "test_compute_capacity_reservation", acctest.Optional, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreComputeCapacityReservationRepresentation, map[string]interface{}{
177177
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.tenancy_ocid}`}, "instance_reservation_configs": acctest.RepresentationGroup{RepType: acctest.Required, Group: acctest.RepresentationCopyWithNewProperties(CoreComputeCapacityReservationInstanceReservationConfigsRepresentation, map[string]interface{}{
178-
"instance_shape": acctest.Representation{RepType: acctest.Required, Create: `VM.Standard2.1`}, "fault_domain": acctest.Representation{RepType: acctest.Optional, Create: `FAULT-DOMAIN-1`}, "reserved_count": acctest.Representation{RepType: acctest.Required, Create: `6`},
178+
"instance_shape": acctest.Representation{RepType: acctest.Required, Create: `VM.Standard2.1`}, "fault_domain": acctest.Representation{RepType: acctest.Optional, Create: `FAULT-DOMAIN-1`}, "reserved_count": acctest.Representation{RepType: acctest.Required, Create: `6`}, "cluster_placement_group_id": acctest.Representation{RepType: acctest.Optional, Create: ``},
179179
})}}))
180180
)
181181

internal/service/containerengine/containerengine_node_pool_resource.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func ContainerengineNodePoolResource() *schema.Resource {
240240
"FLANNEL_OVERLAY",
241241
"OCI_VCN_IP_NATIVE",
242242
}, true),
243+
ForceNew: true,
243244
},
244245

245246
// Optional
@@ -1770,7 +1771,6 @@ func NodePoolPlacementConfigDetailsToMap(obj oci_containerengine.NodePoolPlaceme
17701771
if obj.SubnetId != nil {
17711772
result["subnet_id"] = string(*obj.SubnetId)
17721773
}
1773-
17741774
return result
17751775
}
17761776

@@ -2044,8 +2044,6 @@ func (s *ContainerengineNodePoolResourceCrud) hasNodeConfigDetailsChange(fieldKe
20442044

20452045
func (s *ContainerengineNodePoolResourceCrud) mapToUpdateNodePoolNodeConfigDetails(fieldKeyFormat string) (oci_containerengine.UpdateNodePoolNodeConfigDetails, error) {
20462046
result := oci_containerengine.UpdateNodePoolNodeConfigDetails{}
2047-
2048-
result.PlacementConfigs = []oci_containerengine.NodePoolPlacementConfigDetails{}
20492047
if placementConfigs, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "placement_configs")); ok {
20502048
set := placementConfigs.(*schema.Set)
20512049
interfaces := set.List()
@@ -2059,34 +2057,45 @@ func (s *ContainerengineNodePoolResourceCrud) mapToUpdateNodePoolNodeConfigDetai
20592057
}
20602058
tmp[i] = converted
20612059
}
2062-
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "placement_configs")) {
2060+
if len(tmp) != 0 && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "placement_configs")) {
20632061
result.PlacementConfigs = tmp
20642062
}
20652063
}
20662064

2067-
if size, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "size")); ok {
2065+
if nodePoolPodNetworkOptionDetails, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "node_pool_pod_network_option_details")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "node_pool_pod_network_option_details")) {
2066+
if tmpList := nodePoolPodNetworkOptionDetails.([]interface{}); len(tmpList) > 0 {
2067+
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "node_pool_pod_network_option_details"), 0)
2068+
tmp, err := s.mapToNodePoolPodNetworkOptionDetails(fieldKeyFormatNextLevel)
2069+
if err != nil {
2070+
return result, err
2071+
}
2072+
result.NodePoolPodNetworkOptionDetails = tmp
2073+
}
2074+
}
2075+
2076+
if size, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "size")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "size")) {
20682077
tmp := size.(int)
20692078
result.Size = &tmp
20702079
}
20712080

2072-
if isPvEncryptionInTransitEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_pv_encryption_in_transit_enabled")); ok {
2081+
if isPvEncryptionInTransitEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_pv_encryption_in_transit_enabled")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "is_pv_encryption_in_transit_enabled")) {
20732082
tmp := isPvEncryptionInTransitEnabled.(bool)
20742083
result.IsPvEncryptionInTransitEnabled = &tmp
20752084
}
20762085

2077-
if kmsKeyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "kms_key_id")); ok {
2086+
if kmsKeyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "kms_key_id")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "kms_key_id")) {
20782087
tmp := kmsKeyId.(string)
20792088
result.KmsKeyId = &tmp
20802089
}
2081-
if definedTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "defined_tags")); ok {
2090+
if definedTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "defined_tags")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "defined_tags")) {
20822091
tmp, err := tfresource.MapToDefinedTags(definedTags.(map[string]interface{}))
20832092
if err != nil {
20842093
return result, fmt.Errorf("unable to convert defined_tags, encountered error: %v", err)
20852094
}
20862095
result.DefinedTags = tmp
20872096
}
20882097

2089-
if freeformTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeform_tags")); ok {
2098+
if freeformTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeform_tags")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "freeform_tags")) {
20902099
result.FreeformTags = tfresource.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
20912100
}
20922101

0 commit comments

Comments
 (0)