Skip to content

find_redis_address docstring #11884

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

Merged
merged 3 commits into from
Nov 11, 2020

Conversation

dHannasch
Copy link
Contributor

Why are these changes needed?

Currently, find_redis_address() lacks a docstring, and is somewhat complicated and counter-intuitive when reading the code. This adds a specific example of a string find_redis_address() might process.

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Collaborator

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

Good idea, just a comment about naming.

Also, is it possible to only show the relevant parts of the command that we process or do you think showing the full thing verbatim is necessary? Right now it's hard to scan the docstring to understand what I should be looking for.

Comment on lines 125 to 126
"""
Currently, this extracts the --redis-address from the command that launched
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's call this --address instead of --redis-address everywhere in the comment (--redis-address is the deprecated name).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a note that --redis-address is deprecated, but I think that the fact that this function looks for --redis-address instead of --address is literally the most important thing to know about this function, precisely because it's using the deprecated name.

Right now, if something is going wrong and someone comes poking through this code, that --redis-address sure jumps out, and it's helpful to have something clarifying "If you check ps aux and the command line looks like this, then the problem is not here."

And in the future, when the relevant command lines actually are changed to remove --redis-address --- I mean, this function is going to inevitably break, right? Because in the actual code it is in fact looking for --redis-address. So having a warning here might save some time for the poor developer trying to remove --redis-address.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't actually realize that we hadn't changed --redis-address internally! This makes sense to me, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it sounds like he didn't realize either until he started digging into it: #11735
I don't expect the docstring to help much, but hopefully it'll help at least a little the next time something like #11735 comes up.

@dHannasch
Copy link
Contributor Author

dHannasch commented Nov 10, 2020

is it possible to only show the relevant parts of the command that we process or do you think showing the full thing verbatim is necessary? Right now it's hard to scan the docstring to understand what I should be looking for.

Hmm. There are probably three audiences here.

The original purpose was just to add an explanation for people poking through the code looking for places to set traps because they suspect some function in here is not returning the correct address. Parsing a cmdline certainly looks fragile, so it draws the eye, so it's nice to have a docstring explaining what this function is doing.

But as long as I was adding a docstring, I figured I'd to add a warning for passing developers. Maybe this is just me, but when I see something like this I want to add asserts or something to check everything that's in the line, to be sure we're not pulling out --redis-address when the correct address is --redis_address which was also present but ignored.

The big long string is to get across just how hard this problem is. (For one thing, there actually is a --redis_address, and we don't want it.) It's actually very much reduced in its current form; the verbatim string has a bunch of long arguments that make it even harder to eyeball what's going on.

And the third purpose is for developers who come seeking this function specifically because it has broken, which is probably will sooner or later. (If nothing else, as you note, --redis-address is deprecated.) If, for example, the control flow gets rearranged so that those nested commands aren't sitting in front of the raylet command, this function will break, and someone looking at what it's trying to parse and what it's not finding might assume that the problem is that it's looking for --redis_address as --redis-address.

For that hypothetical where the function isn't working and it's not clear why, it seems worth knowing "So exactly what input did this thing get back when it was working?"

@edoakes edoakes merged commit 396ae0b into ray-project:master Nov 11, 2020
@dHannasch dHannasch deleted the find_redis_address_docstring branch November 11, 2020 20:59
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