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 rule order bug #967

Merged
merged 1 commit into from
Sep 15, 2023
Merged

Fix rule order bug #967

merged 1 commit into from
Sep 15, 2023

Conversation

annakhm
Copy link
Collaborator

@annakhm annakhm commented Sep 13, 2023

NSX can not guarantee rule order unless sequence_number is provided, or revise API is called.
This change auto-assigns sequence number to all rules in list, for which it was not provided by the user.
It takes care of provider upgrade by making sure rules without assigned sequence number are updated even if terraform does not detect a change in them.

NSX can not guarantee rule order unless sequence_number is provided, or
`revise` API is called.
This change auto-assigns sequence number to all rules in list, for which
it was not provided by the user.
It takes care of provider upgrade by making sure rules without assigned
sequence number are updated even if terraform does not detect a change
in them.

Signed-off-by: Anna Khmelnitsky <[email protected]>
@annakhm
Copy link
Collaborator Author

annakhm commented Sep 13, 2023

/test-all

Copy link
Collaborator

@ksamoray ksamoray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a question for understanding how it works.

@@ -469,6 +470,11 @@ func getPolicyRulesFromSchema(d *schema.ResourceData) []model.Rule {
}

resourceType := "Rule"
if sequenceNumber == 0 {
sequenceNumber = lastSequence + 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to set sequence numbers with some gap between them? e.g 10, 20... etc so later a rule can be inserted between without recreating the whole list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From terraform perspective the list is ordered, which means if rule 3.5 is inserted between rule 3 and rule 4, this will result in diff for rule 4, and a new rule 5. As a result, we will update all rules starting from the inserted rule, hence we don't need to bother about gaps in sequence numbers.

@annakhm annakhm merged commit 8e7f276 into master Sep 15, 2023
2 checks passed
@annakhm annakhm deleted the fix-rule-order-bug branch August 10, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants