-
Notifications
You must be signed in to change notification settings - Fork 510
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
Compute V2: implement server tags filtering support #1759
Conversation
Build failed.
|
Build succeeded.
|
@Fedosin Thank you for submitting this. The referenced issue #1669 has been closed, but I'm OK with re-opening it for this PR. However, there are a few things that need worked out. Per our contributor tutorial we need to see links to the actual API service implementation of listing tags, not just documentation. To save some time, here's the needed information. Next, you are adding a field of @ozerovandrei on that note, I believe this can be removed since we already have this functionality in the servers' On the core topic of this PR, the additions to the I'll open a PR to fix the tags extension and then this PR can be rebased. Once that's done, this should be ready to go. Please let me know if anyone has any questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
serverWithTags := serverWithTagsExt{} | ||
serverWithTags := servers.Server{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per other comments, please revert this change and rebase. After the rebase, I believe this file can go unmodified. Let me know if you have any questions.
NotTags []string `q:"not-tags"` | ||
|
||
// NotTagsAny filters on specific server tags. At least one of the tags must be absent for the server. | ||
NotTagsAny []string `q:"not-tags-any"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit with these in-line comments: can you add:
// This requires the client to be set to microversion 2.26 or later.
To each field?
|
||
// Tags is a list of server tags. Tags are arbitrarily defined strings | ||
// attached to a server. | ||
Tags []string `json:"tags"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the other comments/discussion, please revert this as there's already a way to achieve this. Let me know if you have any questions with the current implementation, though.
3cd51a5
to
385867a
Compare
I made this as an extension to ListOpts, plus added a test. |
I'm so sorry for the confusion. Adding the parameters directly in There are three forms of an API amendment/extension that we try to deal with:
Nova used to have more well-defined/first-class extensions but collapsed them all into the core code, but other services (such as Neutron) still have a concept of extensions. So between that and the existing
These go under We could add the field So we use the concept of composing new structs and the developer can add their own conditional logic on when they want to do this, with the thinking that the developer will know when they need to support a microversion and when the response should have a microversion-amended response.
Because we have control over how the request body is sent, we can omit fields that are sent in a request body. So it's possible for us to support microversion amendments in-line of the original structs and functions in the It would be great if we could do this for responses, but as mentioned above, the zero-value makes it indeterminable, so that's why there's the extra work involved. You can see some other examples of existing microversion amendments here:
Long story short, the way you originally had the ListOpts is correct. Just add an in-line comment that it requires the Adding the fields to ListOpts is the only change needed to add the functionality you want, so the PR can be trimmed to just that. I'm really sorry about the confusion and the extra work you put in because of it. |
Build failed.
|
Server tags filtering support was added in Nova API since 2.26, so we can implement it here as well. This patch adds new filters `tags`, `tags-any`, `not-tags`, `not-tags-any` to server list options.
Build failed.
|
recheck |
Build failed.
|
The test failures are not related to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thank you so much for your patience.
My pleasure :) thanks for your support! |
Now to delete servers we first get a list of all available servers from Nova, and then we iterate through them to find those with required metadata. In the case of a large number of servers, this can take a very long time. Fortunately gophercloud introduced filtering by tags, so we can start using this feature to get only servers with the required tag. gophercloud/gophercloud#1759
Now to delete servers we first get a list of all available servers from Nova, and then we iterate through them to find those with required metadata. In the case of a large number of servers, this can take a very long time. Fortunately gophercloud introduced filtering by tags, so we can start using this feature to get only servers with the required tag. gophercloud/gophercloud#1759
Server tags support was added in Nova API since 2.26, so we can implement it here as well.
For #1669
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
https://github.com/openstack/nova/blob/3b54979ae02cc74bcf215713c16916bbf4131443/nova/api/openstack/compute/schemas/servers.py#L645-L651
https://docs.openstack.org/api-ref/compute/?expanded=list-servers-detail,show-server-details-detail#list-servers