Skip to content

Commit

Permalink
Merge pull request #1414 from vmware/fix-vpc-partial
Browse files Browse the repository at this point in the history
Mark partial update when NSX update fails for vpc
  • Loading branch information
annakhm authored Oct 11, 2024
2 parents 9d6103e + bf56af8 commit ff0ac0a
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_policy_project_ip_address_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ func resourceNsxtPolicyProjectIpAddressAllocationUpdate(d *schema.ResourceData,
client := clientLayer.NewIpAddressAllocationsClient(connector)
_, err := client.Update(parents[0], parents[1], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("ProjectIpAddressAllocation", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ func resourceNsxtVpcUpdate(d *schema.ResourceData, m interface{}) error {
client := clientLayer.NewVpcsClient(connector)
_, err := client.Update(parents[0], parents[1], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("Vpc", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_connectivity_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ func resourceNsxtVpcConnectivityProfileUpdate(d *schema.ResourceData, m interfac
client := clientLayer.NewVpcConnectivityProfilesClient(connector)
_, err := client.Update(parents[0], parents[1], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("VpcConnectivityProfile", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_dhcp_v4_static_binding_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ func resourceNsxtVpcSubnetDhcpV4StaticBindingConfigUpdate(d *schema.ResourceData
client := clientLayer.NewDhcpStaticBindingConfigsClient(connector)
_, err := client.Update(parents[0], parents[1], parents[2], parents[3], id, convObj.(*data.StructValue))
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("DhcpV4StaticBindingConfig", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_external_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func resourceNsxtVpcExternalAddressRead(d *schema.ResourceData, m interface{}) e
func resourceNsxtVpcExternalAddressUpdate(d *schema.ResourceData, m interface{}) error {
err := updatePort(d, m, false)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("External Address", "", err)
}
return resourceNsxtVpcExternalAddressRead(d, m)
Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_ip_address_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func resourceNsxtVpcIpAddressAllocationUpdate(d *schema.ResourceData, m interfac
client := clientLayer.NewIpAddressAllocationsClient(connector)
_, err := client.Update(parents[0], parents[1], parents[2], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("VpcIpAddressAllocation", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_nat_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ func resourceNsxtPolicyVpcNatRuleUpdate(d *schema.ResourceData, m interface{}) e
client := clientLayer.NewNatRulesClient(connector)
_, err := client.Update(parents[0], parents[1], parents[2], parents[3], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("PolicyVpcNatRule", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_service_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ func resourceNsxtVpcServiceProfileUpdate(d *schema.ResourceData, m interface{})
client := clientLayer.NewVpcServiceProfilesClient(connector)
_, err := client.Update(parents[0], parents[1], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("VpcServiceProfile", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_static_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func resourceNsxtVpcStaticRoutesUpdate(d *schema.ResourceData, m interface{}) er
client := clientLayer.NewStaticRoutesClient(connector)
_, err := client.Update(parents[0], parents[1], parents[2], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("StaticRoutes", id, err)
}

Expand Down
3 changes: 3 additions & 0 deletions nsxt/resource_nsxt_vpc_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ func resourceNsxtVpcSubnetUpdate(d *schema.ResourceData, m interface{}) error {
client := clientLayer.NewSubnetsClient(connector)
_, err := client.Update(parents[0], parents[1], parents[2], id, obj)
if err != nil {
// Trigger partial update to avoid terraform updating state based on failed intent
// TODO - move this into handleUpdateError
d.Partial(true)
return handleUpdateError("VpcSubnet", id, err)
}

Expand Down

0 comments on commit ff0ac0a

Please sign in to comment.