-
Notifications
You must be signed in to change notification settings - Fork 50
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
cmd: support high-level URIs and JOBID arguments in flux-top and flux-proxy #4004
Conversation
Public API function or not? The header won't be installed but the |
No sorry, I'll fix that |
Problem: A typo identified during review of the flux-uri(1) manpage was missed before the initial version was merged, URI should stand for Uniform Resource Identifier not "Indicator". Correct the mistake.
I've renamed |
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.
Nice improvement! Looks good, just a minor error path issue in the uri_resolve()
implementation.
src/common/libutil/uri.c
Outdated
char **argv = malloc (4 * sizeof (char *)); | ||
if (!(argv[0] = strdup ("flux")) | ||
|| !(argv[1] = strdup ("uri")) | ||
|| !(argv[2] = strdup (uri))) { | ||
free (argv); | ||
return NULL; | ||
} | ||
argv[3] = NULL; | ||
return argv; |
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.
Check malloc return, and free all allocated memory on error path.
src/common/libutil/uri.c
Outdated
} | ||
} | ||
free (cpy); | ||
if (!(argv = get_uri_cmd_create (uri)) |
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.
Would it be a little simpler to just allocate argv on the stack since it's fixed length? e.g.
char *argv[] = { "flux", "uri", uri, NULL };
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.
Yeah, I don't know what I was thinking there. 😕
Ok, I pushed an update to simplify |
src/common/libutil/uri.c
Outdated
static void nullify_newline (char *str) | ||
{ | ||
int n; | ||
if (str && (n = strlen (str) > 0)) { |
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.
Missing set of parens around n = strlen (str)
?
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.
Yeah, sorry, typo that my local compiler didn't catch. Fixed now.
61580a7
to
4238015
Compare
Problem: The "jobid" URI resolver returns a URI for Flux instances that have already completed, in most cases resulting in a less useful later error when the caller attempts to connecto to the completed instance. Update the jobid URI resolver to raise an error if the target jobid is not running.
Problem: The description of the jobid scheme in flux-uri(1) does not note that an error will be raised for jobs that are not running. Update flux-uri(1) to indicate the error.
I actually realized there was a loss in usability here for I've got a fix that updates the |
Oops, a new test in |
Problem: The t2802-uri-cmd.t sharness test does not test the check for running jobs in the jobid uri resolver. Add a check that a completed job fails URI resolution with a descriptive error message.
Problem: Multiple flux-core utilities could benefit from calling out to flux-uri to resolve high-level URIs to native URIs, but this requires a lot of boilerplate code to launch the external process and read its output, etc. Add a uri_resolve() convenience function to libutil which takes a possibly unresolved URI and calls `flux uri` on it, returning the resolved URI on success.
Problem: The flux-proxy tests ensure failure with a non-supported scheme, but we want to allow the command to take resolver schemes such as 'jobid' and 'pid'. Remove the test for now, to be replaced with a different test after support for calling out to flux-uri is added.
Problem: The usability of flux-proxy is suboptimal because it requires a fully-resolved, native Flux URI, whereas users typically know only the jobid of the instance they want to target. Use the new `uri_resolve()` libutil function to process the first argument to `flux-proxy`. This allows flux-proxy to accept any URI which can be processed by `flux uri`, including: 1. A Flux jobid, e.g. `flux proxy ƒAaDN391` 2. A nested Flux jobid e.g. `flux proxy jobid:ƒAaDN391/ƒQABnKR` 3. A Slurm job `flux proxy slurm:1234` 4. A local PID `flux proxy pid:1234` Since `flux uri` supports plugins for addition of other resolver schemes, site-specific or user custom schemes may be supported as well. Fixes flux-framework#3921
Problem: The flux-proxy manpage is out of date now that flux-proxy can take URI or jobid argument, where URI can be resolved to a job URI using `flux get-uri`. Update the manpage describing the new usage of flux-proxy.
Problem: t1105-proxy.t doesn't test flux-proxy behavior when it calls out to flux-uri via flux_uri_resolve() Add a few tests to ensure flux-proxy works and fails in an expected way when calling flux_uri_resolve().
Problem: The argument to flux-top(1) (if provided) can only be a valid jobid in the enclosing instance, but for enhanced usability any high-level URI accepted by `flux uri` should be allowed. If an argument is provided to `flux top`, attempt to resolve it with the new `uri_resolve()` function, which calls out to `flux uri`. Thus, any high-level URI accepted by `flux uri` can also be used directly with `flux top`.
Problem: Many flux-top expected failure tests now fail since flux-top resolves its target argument with flux_uri_resolve(). Updated expected failure output and other tests in t2801-top-cmd.t.
Codecov Report
@@ Coverage Diff @@
## master #4004 +/- ##
=======================================
Coverage 83.47% 83.48%
=======================================
Files 371 372 +1
Lines 53636 53647 +11
=======================================
+ Hits 44774 44787 +13
+ Misses 8862 8860 -2
|
Thanks! Setting MWP |
This PR adds a C function
flux_uri_resolve()
to libutil which calls out toflux-uri(1)
to resolve a high-level URI "target" to a native Flux URI.Then, support for high-level URIs is added to both
flux top
andflux proxy
by callingflux_uri_resolve()
to resolve the command argument, if provided.This allows these commands to connect to jobs using any resolvable URI argument supported by
flux-uri(1)
, including plain jobids, nested jobids, e.g.:(Here I used
?local
because I don't have passwordlessssh
set up)