diff --git a/nsxt/provider.go b/nsxt/provider.go index ae385786c..362719659 100644 --- a/nsxt/provider.go +++ b/nsxt/provider.go @@ -533,18 +533,6 @@ func configurePolicyConnectorData(d *schema.ResourceData, clients *nsxtClients) return nil } -type enablePartialPatchHeaderProcessor struct { -} - -func newEnablePartialPatchHeaderProcessor() *enablePartialPatchHeaderProcessor { - return &enablePartialPatchHeaderProcessor{} -} - -func (processor enablePartialPatchHeaderProcessor) Process(req *http.Request) error { - req.Header.Set("nsx-enable-partial-patch", "true") - return nil -} - type remoteBasicAuthHeaderProcessor struct { } diff --git a/nsxt/resource_nsxt_policy_lb_virtual_server.go b/nsxt/resource_nsxt_policy_lb_virtual_server.go index 5279214d0..6663f69b7 100644 --- a/nsxt/resource_nsxt_policy_lb_virtual_server.go +++ b/nsxt/resource_nsxt_policy_lb_virtual_server.go @@ -514,9 +514,6 @@ func resourceNsxtPolicyLBVirtualServerRead(d *schema.ResourceData, m interface{} func resourceNsxtPolicyLBVirtualServerUpdate(d *schema.ResourceData, m interface{}) error { connector := getPolicyConnector(m) - // NOTE: Partial patch is required to respect rules that might have - // been added manually - connector.AddRequestProcessor(newEnablePartialPatchHeaderProcessor()) client := infra.NewDefaultLbVirtualServersClient(connector) if client == nil { return policyResourceNotSupportedError() @@ -567,6 +564,16 @@ func resourceNsxtPolicyLBVirtualServerUpdate(d *schema.ResourceData, m interface policyLBVirtualServerVersionDepenantSet(d, &obj) + // The user might have defined the rules outside terraform, lets keep these + existingObj, err := client.Get(id) + if err != nil { + return handleUpdateError("LBVirtualServer", id, err) + } + + if len(existingObj.Rules) > 0 { + obj.Rules = existingObj.Rules + } + if maxNewConnectionRate > 0 { obj.MaxNewConnectionRate = &maxNewConnectionRate } @@ -576,7 +583,7 @@ func resourceNsxtPolicyLBVirtualServerUpdate(d *schema.ResourceData, m interface } // Update the resource using PATCH - err := client.Patch(id, obj) + err = client.Patch(id, obj) if err != nil { return handleUpdateError("LBVirtualServer", id, err) }