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

Fix change detection in lb virtual server rules #774

Merged
merged 1 commit into from
Aug 29, 2022
Merged
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
10 changes: 8 additions & 2 deletions nsxt/resource_nsxt_policy_lb_virtual_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1702,8 +1702,11 @@ func resourceNsxtPolicyLBVirtualServerRead(d *schema.ResourceData, m interface{}
This, in turn, should also not trigger the "plan" phase for existing rules, so we also ignore any existing "live"
rules unless we find rules to also exist in the resource state.
*/
if d.State().Attributes["rule.#"] != "0" {
rules := d.Get("rule").([]interface{})
if len(rules) > 0 {
setPolicyLbRulesInSchema(d, obj.Rules)
} else {
log.Printf("[INFO] Ignoring rules since the user did not specify them in configuration")
}

return nil
Expand Down Expand Up @@ -1778,7 +1781,8 @@ func resourceNsxtPolicyLBVirtualServerUpdate(d *schema.ResourceData, m interface
rules in resource / rules in state / rules in NSX => rules will be changed
no rules in resource / rules in state / rules in NSX => rules will be deleted
*/
if !d.HasChange("rule.#") {
if d.HasChange("rule") {
log.Printf("[INFO] Changes detected in rule section")
existingObj, err := client.Get(id)
if err != nil {
return handleUpdateError("LBVirtualServer", id, err)
Expand All @@ -1787,6 +1791,8 @@ func resourceNsxtPolicyLBVirtualServerUpdate(d *schema.ResourceData, m interface
if len(existingObj.Rules) > 0 {
obj.Rules = existingObj.Rules
}
} else {
log.Printf("[INFO] No changes in rule section")
}

if maxNewConnectionRate > 0 {
Expand Down