X Tutup
Skip to content

Neutron 2: Update NetFloatingIP to fetch and set all the fields#51

Merged
olivergondza merged 2 commits intoopenstack4j:masterfrom
olivergondza:update-fips
Apr 3, 2020
Merged

Neutron 2: Update NetFloatingIP to fetch and set all the fields#51
olivergondza merged 2 commits intoopenstack4j:masterfrom
olivergondza:update-fips

Conversation

@olivergondza
Copy link
Copy Markdown
Member

@olivergondza olivergondza commented Mar 21, 2020

Add remaining fields missing in NetFloatingIP so all documented fields can be read.

https://docs.openstack.org/api-ref/network/v2/?expanded=list-floating-ips-detail

@olivergondza
Copy link
Copy Markdown
Member Author

@openstack4j/reviewers, review would be highly appreciated.

Copy link
Copy Markdown
Contributor

@pjdarton pjdarton left a comment

Choose a reason for hiding this comment

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

Personally, I prefer refactoring/reformatting changes and functional changes not to be in the same changeset - it makes it more difficult to see what the functional changes are when there's also diffs from non-functional changes.
e.g. NetFloatingIP.java line 63, 70, 72, NetFloatingIPBuilder.java line 12-28, NeutronFloatingIP.java line 183, 191, 195-197, 200-201, 204-226

There's also inconsistency within the code w.r.t. {@inheritDoc}. I think that we should either have a consistent policy of always having /** {@inheritDoc} */ comments for @Override methods or never having them; this PR removes some but adds others.

FYI I approve of the refactoring / whitespace changes, I'd just prefer them in their own PR that can be reviewed as a "no brainer", merged and then provide a nice clean starting point for the new functionality that's desired.

My only comments w.r.t. functionality are that NeutronFloatingIP.toString() no longer includes the tenantId field and now includes a \n. Given that we're calling omitNullValues() I think it'd be better to include all fields and, personally, I'm not a fan of embedded \n characters in toString methods - if a caller wants a linebreak then that's their business and it's trivial to add, whereas taking things away is more complicated.

I've not compared NeutronFloatingIP's json metadata against the OpenStack spec (mostly because I'm not 100% clear what this PR is trying to do) but I'd hope that these fields are (a) correctly spelled and (b) in the same order they're listed in the spec.
I believe that adding new fields that go unused by client code will have no effect because null values don't get written into the json, so there should be no fear of backwards-compatibility issues from adding new fields to outgoing requests, but I guess it's possible we might throw if the json we receive from incoming results has fields we now support but in formats we don't. It's probably the lowest risk option we can do.

Lastly, I'd recommend adding a description to the PR - while I can see what code changes have been made, I don't know what functional changes were intended or what need these changes were intending to address, so I can't make any informed decisions on whether or not the code meets requirements/design; this also limits the utility of any code review I can give.

@olivergondza
Copy link
Copy Markdown
Member Author

olivergondza commented Mar 25, 2020

@pjdarton, I tried to stay from whitespace changes but some of the files ware badly messed (three space indent, tabs mixed with spaces) so I gave up at places. There ware no intent to rectify the bed formatting. I track that effort in https://github.com/openstack4j/openstack4j/projects/1. /** {@inheritDoc} */ falls into the category of useless javadoc as that is what javadoc would do anyway.

My only comments w.r.t. functionality are that NeutronFloatingIP.toString() no longer includes the tenantId field and now includes a \n. Given that we're calling omitNullValues() I think it'd be better to include all fields and, personally, I'm not a fan of embedded \n characters in toString methods - if a caller wants a linebreak then that's their business and it's trivial to add, whereas taking things away is more complicated.

100% agreed, mind the \n is being removed, not added. w.r.t. s/tenantId/projectId/, they are the same as the way I understand that, OS is switching terminology from tenant to project. So both getters are present not to break API for clients, but I saw no purpose to print both fields in toString when their value is guaranteed to be the same - so I chose to stick with modern naming.

I believe that adding new fields that go unused by client code will have no effect because null values don't get written into the json

Correct, I have verified that. One nasty thing about the openstack4j design is, the same object are often used for sending and receiving the entity even though the fields documented on GET and POST do not always 100% match (revision_number is read only, etc.).

but I'd hope that these fields are (a) correctly spelled

oh, are they not?

Lastly, I'd recommend adding a description to the PR

Valid point. My apology.

@pjdarton
Copy link
Copy Markdown
Contributor

pjdarton commented Mar 26, 2020

😁 Yeah, I have similar tendencies myself - a near-uncontrollable need to tidy up messy code as I go along - the problem with that is that those changes then make the main changes harder to see. That's why I prefer to keep functional changes in PRs that have no other others, and tidy-up/refactor PRs to have no functional changes.
What I generally end up doing is making a "combined" set of changes, then submitting a change that's just the non-functional stuff, get that merged in, and then rebase the "combined" one so it's just the minimal set of changes required to change the functionality.
...or I lose patience with the duff code entirely, park my "proper work" and tidy it all up before going back to what I was originally trying to do 😉

the \n is being removed, not added

Ok, my bad; I'm glad the \n is gone now 😁

s/tenantId/projectId/

If they're separate fields, they're not guaranteed to be the same value - a user could set them to different values.
I'd suggest that we do one of two things:
a) Force them to be the same by putting extra code in the getters/setters
b) Have the toString field show both if they're different but only the new name otherwise.

correctly spelled ... are they not?

I hadn't checked; I'd not looked up the spec when I first reviewed the code.
As you've since added a description and a link to the spec, I've since checked.
The spelling looks right ... but personally I'd prefer the fields to be in the code in the same order they are in the spec (or in alphabetical order).
I noticed that qos_policy_id isn't explicitly listed in either the JSON request or response - presumably there's some magic whereby the QoS extension adds this attribute into specific (but unspecified) requests/responses?

@olivergondza
Copy link
Copy Markdown
Member Author

@pjdarton, good idea with the tenantId. Updated.

Re reformatting all the code and property reordering, I prefer to keep the code changes conservative since the fork day to simplify eventual merging back. In fact, we are having discussions with past maintainers of ContianX/openstack4j to move beck there taking advantage of existing .org domain, continuation of maven coordinates and the fact most users are filing issues and PRs there. Once we merge or we get clear that we won't, I am happy to do that.

@pjdarton
Copy link
Copy Markdown
Contributor

Ah, if we're planning on merging back then, yes, I agree that we should keep our code changes as simple as possible.
...but if we're doing that, I'd suggest that it's even more important that we avoid all unnecessary changes, e.g. the whitespace/formatting changes, in any functional-change PR.

@olivergondza olivergondza merged commit 6287675 into openstack4j:master Apr 3, 2020
@olivergondza
Copy link
Copy Markdown
Member Author

Thanks for the review, @pjdarton. We are in agreement, I hope we will be able to get rid of the messed formatting soon.

@olivergondza olivergondza deleted the update-fips branch April 3, 2020 05:48
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

X Tutup