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

cli: support wildcard namespace in alloc subcommands #18095

Merged
merged 1 commit into from Jul 31, 2023

Conversation

tgross
Copy link
Member

@tgross tgross commented Jul 28, 2023

The alloc exec and filesystem/logs commands allow passing the -job flag to select a random allocation. If the namespace for the command is set to *, the RPC handler doesn't handle this correctly as it's expecting to query for a specific job. Most commands handle this ambiguity by first verifying that only a single object of the type in question exists (ex. a single node or job).

Update these commands so that when the -job flag is set we first verify there's a single job that matches. This also allows us to extend the functionality to allow for the -job flag to support prefix matching.

Fixes: #12097


What this looks like if there are multiple matching jobs:

$ nomad alloc exec -namespace '*' -job httpd /bin/sh
Prefix "httpd" matched multiple jobs

ID     Namespace  Type     Priority  Status   Submit Date
httpd  dev        service  50        running  2023-07-28T16:29:13-04:00
httpd  prod       service  50        running  2023-07-28T16:29:18-04:00

@tgross
Copy link
Member Author

tgross commented Jul 31, 2023

Failing test is because of #18100. I'll rebase this on main once that merges.

The alloc exec and filesystem/logs commands allow passing the `-job` flag to
select a random allocation. If the namespace for the command is set to `*`, the
RPC handler doesn't handle this correctly as it's expecting to query for a
specific job. Most commands handle this ambiguity by first verifying that only a
single object of the type in question exists (ex. a single node or job).

Update these commands so that when the `-job` flag is set we first verify
there's a single job that matches. This also allows us to extend the
functionality to allow for the `-job` flag to support prefix matching.

Fixes: #12097
@tgross tgross force-pushed the alloc-command-wildcard-namespace branch from 54ef908 to e5c6a28 Compare July 31, 2023 15:54
@tgross tgross merged commit 4fb5bf9 into main Jul 31, 2023
27 checks passed
Nomad - Community Issues Triage automation moved this from In Progress to Done Jul 31, 2023
@tgross tgross deleted the alloc-command-wildcard-namespace branch July 31, 2023 17:15
tgross added a commit that referenced this pull request Jul 31, 2023
The alloc exec and filesystem/logs commands allow passing the `-job` flag to
select a random allocation. If the namespace for the command is set to `*`, the
RPC handler doesn't handle this correctly as it's expecting to query for a
specific job. Most commands handle this ambiguity by first verifying that only a
single object of the type in question exists (ex. a single node or job).

Update these commands so that when the `-job` flag is set we first verify
there's a single job that matches. This also allows us to extend the
functionality to allow for the `-job` flag to support prefix matching.

Fixes: #12097
@tgross
Copy link
Member Author

tgross commented Jul 31, 2023

Backported to 1.6.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants