Skip to content

Baremetal: add nodes.automated_clean#2122

Merged
jtopjian merged 1 commit intogophercloud:masterfrom
Nordix:add-automated_clean/feruz
Feb 23, 2021
Merged

Baremetal: add nodes.automated_clean#2122
jtopjian merged 1 commit intogophercloud:masterfrom
Nordix:add-automated_clean/feruz

Conversation

@fmuyassarov
Copy link
Copy Markdown
Contributor

For #2121

@fmuyassarov
Copy link
Copy Markdown
Contributor Author

/cc @dtantsur

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 22, 2021

Coverage Status

Coverage remained the same at 79.83% when pulling 5542088 on Nordix:add-automated_clean/feruz into fe53046 on gophercloud:master.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 22, 2021

Build succeeded.

@fmuyassarov fmuyassarov force-pushed the add-automated_clean/feruz branch from 375d323 to 6cbb091 Compare February 22, 2021 17:05
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 22, 2021

Build succeeded.

@fmuyassarov
Copy link
Copy Markdown
Contributor Author

@jtopjian , @dtantsur PTAL, addressed the comments above. Thanks.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

@fmuyassarov I've noted three small changes. Please let me know if you have any questions.

type CreateOpts struct {

// The interface to configure automated cleaning for a Node
AutomatedClean *bool `json:"automated_clean,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Format nit: Please remove the blank line on line 184.

Can you also add a comment to note which microversion introduced this field? As an exmaple:

// Tags allows a server to be tagged with single-word metadata.
// Requires microversion 2.52 or later.
Tags []string `json:"tags,omitempty"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jtopjian thanks, fixed it.

Copy link
Copy Markdown
Contributor

@dtantsur dtantsur Feb 23, 2021

Choose a reason for hiding this comment

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

Honestly, half of these fields were introduced in a microversion. Somebody should go through https://docs.openstack.org/ironic/latest/contributor/webapi-version-history.html and add these eventually.

I'd like to use this comment to (once again) express his disagreement with how gophercloud handles microversions. They have to be set automatically, not like this:

client.Microversion = "1.47"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Honestly, half of these fields were introduced in a microversion. Somebody should go through https://docs.openstack.org/ironic/latest/contributor/webapi-version-history.html and add these eventually.

I can try to work on this, but can't tell the exact date right now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only if you have spare cycles to spend. Otherwise I'll probably get to it (no ETA as well).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd like to use this comment to (once again) express his disagreement with how gophercloud handles microversions. They have to be set automatically, not like this:

I would be more than happy to discuss a change in implementation. In fact, I'd appreciate the help.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure which venue we should use, but the vision of microversions by the OpenStack API SIG is that the microversions should not be exposed to consumers of all but the most basic and low-level SDKs. Back at the times I wrote https://specs.openstack.org/openstack/api-sig/guidelines/sdk-exposing-microversions.html.

Let's take this patch as an example. If client.Microversion is empty, we provide the minimum microversion we support. But if automated_clean is not nil, we understand that this request can only be executed with API version 1.47 and automatically use it (consumers can still override with by setting client.Microversion explicitly).

When retrieving anything, the situation is a bit more interesting. You need to figure out the maximum version that both the server and gophercloud understand. In openstacksdk, for example, we set the latter per resource: https://github.com/openstack/openstacksdk/blob/master/openstack/baremetal/v1/node.py#L95. This procedure allows exposing maximum fields without the users guessing the right microversion. Instead they can rely on the fact that e.g. automated_clean is not nil.

I hope it all makes sense, I'm open to a more detailed/broad conversation since microversions happened to be more specialization (even though I personally dislike them :) )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the reply - it's very helpful.

Not sure which venue we should use

If there's substantial discussion that won't be resolved in a few comments, then a new Issue would be best.

It sounds like there isn't a problem with the technical details of getting microversions to work. To be honest, that's my biggest priority/concern.

I understand the implementation you've described and I agree with it.

Gophercloud attempts to be, basically, one step above raw HTTP requests. It doesn't try to do anything intelligent unless it's absolutely needed. There isn't a technical reason for this or even an ideological reason. It's really just an issue of available hands and eyes to work on Gophercloud. The amount of volunteer effort available right now is just enough for "one step above raw HTTP requests" and an occasional feature at https://github.com/gophercloud/utils. It'd be awesome if Gophercloud had feature parity with openstacksdk, but it's not possible unless more people work on it regularly.

Again, I do agree with the implementation you described, but it would take a good amount of work. It would take more effort to also make sure Gophercloud fully supported a microversion to the point where I'd feel comfortable tagging a certain Gophercloud release with an officially supported microversion (the concern largely comes from making sure all OpenStack projects/services within Gophercloud have this level of support and one service doesn't get preferential treatment).

This is why anything "two steps" above a raw HTTP requests is punted up the stack. I don't like doing it, but it's better than 2-3 years ago when microversioned features were blocked entirely while trying to figure out a clean solution. If someone would argue that not doing it the ideal way is worse than no support at all, I wouldn't disagree with them, but I'd ask them to field the feature requests that come in :)

Yeah, I realize I'm giving the "not enough time" excuse. But if people began submitting patches to change how Gophercloud works with microversions, I would absolutely be open to merging them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gophercloud had feature parity with openstacksdk, but it's not possible unless more people work on it regularly

Sigh, don't get me started on how many people work full time on openstacksdk (zero)..

I realize I'm giving the "not enough time" excuse

And I understand you very well! Where is my human cloning machine?

Gophercloud attempts to be, basically, one step above raw HTTP requests

There is one problem though: microversions are supposed to be set per request, not per client. It seems that Gophercloud does the latter though. A low-level SDK should do the former. Not sure how ugly it will make the API though. In rust-osauth I ended up with an explicit argument: https://docs.rs/osauth/0.3.4/osauth/struct.Session.html#method.request (but rust-osauth is actually one stop closer to the wire).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

microversions are supposed to be set per request, not per client. It seems that Gophercloud does the latter though

I can't speak for everything that has used Gophercloud+microversions, so it's best to assume that there are cases where this is being done.

However, it's possible to do it on a per-request basis above Gophercloud right now. This is how it's been implemented in Terraform. Some examples are:

These examples could be tightened up to where the microversion is reverted after the individual request, but Terraform's Create, Read, Update, and Delete functions can be thought of as a single request to perform one action.

I do understand that the logic being done in Terraform should be done in Gophercloud. Again, if someone proposed a way to redesign and enable this, I'm open to merging it.

All API calls in Gophercloud have the ability add additional headers, so it should be possible to tuck all of this logic away from the user. For example:

MoreHeaders: map[string]string{"Content-Type": "application/octet-stream"},

Baremetal: add nodes.automated_clean
@fmuyassarov fmuyassarov force-pushed the add-automated_clean/feruz branch from 6cbb091 to 5542088 Compare February 22, 2021 22:42
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 23, 2021

Build succeeded.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

LGTM - thank you!

@jtopjian jtopjian merged commit 78cdb2b into gophercloud:master Feb 23, 2021
@fmuyassarov fmuyassarov deleted the add-automated_clean/feruz branch May 3, 2021 13:21
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.

4 participants