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

Allow to configure nsx_id for locale service #1040

Merged
merged 1 commit into from
Dec 7, 2023
Merged

Conversation

annakhm
Copy link
Collaborator

@annakhm annakhm commented Nov 23, 2023

Rather than recreating locale services with every update, allow to change existing locale service by specifying it nsx_id
When nsx_id is specified for locale service, update will happen in place. When not specified, update on locale service will force new gateway object, thus recreating dependant objects such as service interfaces.

@annakhm
Copy link
Collaborator Author

annakhm commented Nov 23, 2023

/test-all

@annakhm annakhm marked this pull request as draft November 23, 2023 22:18
@annakhm
Copy link
Collaborator Author

annakhm commented Nov 25, 2023

/test-all

@annakhm annakhm marked this pull request as ready for review November 27, 2023 17:57
@annakhm
Copy link
Collaborator Author

annakhm commented Nov 28, 2023

/test-all

@annakhm
Copy link
Collaborator Author

annakhm commented Nov 29, 2023

/test-all

1 similar comment
@annakhm
Copy link
Collaborator Author

annakhm commented Nov 30, 2023

/test-all

@annakhm annakhm requested a review from ksamoray November 30, 2023 20:49
@ksamoray
Copy link
Collaborator

ksamoray commented Dec 3, 2023

As the code validates ha_mode, let's rebase on top of PR #1042 (which is merged already), and run against NSX v4.1.1 and above, just to make sure that it works there as well?

@annakhm
Copy link
Collaborator Author

annakhm commented Dec 4, 2023

/test-all

Copy link
Member

@salv-orlando salv-orlando left a comment

Choose a reason for hiding this comment

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

LGTM - some questions inline (mostly for my own culture)

}
}

return keyMap
Copy link
Member

Choose a reason for hiding this comment

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

The implementation looks good, and I'm not questioning anything.

I'm just curious if we really need a map or we could have just returned an array of ids

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just for lookup speed it is easier to have a map


keyMap := make(map[string]bool)
for _, item := range schemaSet.(*schema.Set).List() {
mapItem := item.(map[string]interface{})
Copy link
Member

Choose a reason for hiding this comment

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

is this case always guaranteed to work? Wondering if there are case where the list element is not a map.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is tailored for TypeSet of nested schema, in which case its always a list of maps. I will clarify this in the comment.

func getTestAdvancedTopology() string {
// Non-basic testing topology available
// For now this is used by tests that have minimum 2 edge nodes per cluster
return os.Getenv("NSXT_TEST_ADVANCED_TOPOLOGY")
Copy link
Member

Choose a reason for hiding this comment

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

I understand the env variable is an easy solution, but in theory could have we verified the number of edges in the cluster with a precheck?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought it would be a good idea to have extra test granularity for basic topologies and complex topologies. But you're right, we could leverage the precheck here as well.

@ksamoray
Copy link
Collaborator

ksamoray commented Dec 5, 2023

/test-all

@annakhm
Copy link
Collaborator Author

annakhm commented Dec 5, 2023

/test-all

Rather than recreating locale services with every update, allow
to change existing locale service by specifying it nsx_id
When nsx_id is specified for locale service, update will happen
in place, thus keeping all objects dependant on the locale service
intact (for example, service interfaces).

Note that nsx_id would only be set in state if specified by user,
otherwise non-empty plan would always be produced due to SDK design
issue that offers limited support for Computed fields in TypeSet
nested schema. This workaround should be removed after upgrading
to plugin framework.

When nsx_id is not speicified, there is no change of behavior.

Signed-off-by: Anna Khmelnitsky <[email protected]>
@annakhm annakhm merged commit 7ab3043 into master Dec 7, 2023
2 checks passed
@annakhm annakhm deleted the locale_service_id branch February 5, 2024 18:43
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.

3 participants