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

NAS-131083 / 25.04 / service.stop return values are swapped #14463

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

creatorcary
Copy link
Contributor

@creatorcary creatorcary commented Sep 9, 2024

The API documentation states: 'Will return true if service successfully stopped' but the opposite is true.

Return True on successful stop, or raise a CallError if the service is still running.

Tests: http://jenkins.eng.ixsystems.net:8080/job/tests/job/api_tests/630/

@creatorcary creatorcary requested a review from a team September 9, 2024 18:28
@bugclerk
Copy link
Contributor

bugclerk commented Sep 9, 2024

@bugclerk bugclerk changed the title service.stop return values are swapped NAS-131083 / 25.04 / service.stop return values are swapped Sep 9, 2024
Copy link
Contributor

@anodos325 anodos325 left a comment

Choose a reason for hiding this comment

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

Should we do this or fix the docs? The latter is less likely to cause a regression unless you're absolutely certain it won't break anything.

Copy link
Contributor

@bmeagherix bmeagherix left a comment

Choose a reason for hiding this comment

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

If we're going to change the behavior then I'd suggest a CI run run as a prerequisite of the PR.

@creatorcary
Copy link
Contributor Author

creatorcary commented Sep 9, 2024

Should we do this or fix the docs? The latter is less likely to cause a regression unless you're absolutely certain it won't break anything.

Amazingly I only see one place in middleware where the return value is used and it's in a test, but I'm definitely not certain about anywhere else yet.

@anodos325
Copy link
Contributor

Amazingly I only see one place in middleware where the return value is used

Our codebase is rarely that simple. It's a trap.

@anodos325
Copy link
Contributor

If you go down the path of changing the return value, you should also first socialize change with the QE team as they may be explicitly testing this.

@creatorcary
Copy link
Contributor Author

If you go down the path of changing the return value, you should also first socialize change with the QE team as they may be explicitly testing this.

Definitely, I'm just gauging opinion for now to see if this would be worth changing. To me a return value of True just intuitively means success

Copy link
Contributor

@themylogin themylogin left a comment

Choose a reason for hiding this comment

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

I checked the UI code, they are using this method's return value too.

@mgrimesix
Copy link
Contributor

My vote would be to update the docstrings to indicate what is returned.

@yocalebo
Copy link
Contributor

yocalebo commented Sep 9, 2024

I hate this (anti)-pattern. It has plagued us since freeBSD days 🙂. Why would we keep this behavior? Is there any logical reason (other than the apprehension to change)? I'm not going to die on this hill but I find it weird to keep something like this in code that is (and has) caused lots of confusion over the years.

@mgrimesix
Copy link
Contributor

I'm not going to defend it. I find 44 usages of 'service.stop' in middleware. Maybe 1/3 to 1/2 in tests.

@jordan-mcgillivray005
Copy link

jordan-mcgillivray005 commented Sep 10, 2024

We assert status_code == 200 for service.stop. Changing the return to be True if successfully stopped (the correct behavior in my opinion) doesn't affect us.

@anodos325
Copy link
Contributor

I hate this (anti)-pattern. It has plagued us since freeBSD days 🙂. Why would we keep this behavior? Is there any logical reason (other than the apprehension to change)? I'm not going to die on this hill but I find it weird to keep something like this in code that is (and has) caused lots of confusion over the years.

I'm not defending it, we just need to make sure that all stakeholders are aware (in addition to making sure we don't break our own CI :) )

@creatorcary
Copy link
Contributor Author

Copy link
Contributor

@yocalebo yocalebo left a comment

Choose a reason for hiding this comment

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

This looks good to me. Just make sure UI team is aware of the behavioral change (they might not care). You also need to make sure the TC team is aware of the change too.

@creatorcary creatorcary merged commit 24a5f2b into master Sep 12, 2024
3 checks passed
@creatorcary creatorcary deleted the NAS-131083 branch September 12, 2024 14:29
@bugclerk
Copy link
Contributor

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants