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

Nomad CLI exec and logs randomly fails when used with -task and -job combination #24938

Open
Ranjandas opened this issue Jan 24, 2025 · 1 comment
Labels
hcc/jira stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/allocation API theme/cli type/bug

Comments

@Ranjandas
Copy link

Nomad version

$ nomad version
Nomad v1.9.5
BuildDate 2025-01-14T18:35:12Z
Revision 0b7bb8b60758981dae2a78a0946742e09f8316f5+CHANGES

Operating system and Environment details

OS Independent (happens on macOS and Linux)

Issue

The nomad CLI subcommand exec and logs fails randomly when used with -task and -job combinations, when used without explicitly specifying allocation ID.

Reproduction steps

(ref: https://asciinema.org/a/0oRoEEcho4rs78NosVvOgm8jn)

  • Create the countdash example job

    nomad init -short -connect
    
  • Run the job against the cluster

    nomad run example.nomad.hcl
    
  • Try to exec or use logs subcommand against a task without explicitly specifying the allocation ID

    nomad exec -task web -job countdash sh 
    

    or

    nomad logs -task web -job countdash sh
    

Both the above subcommands would randomly fail to pick the right task.

Expected Result

❯ nomad exec -task web -job countdash sh                                                                                                                                                  
/opt 

Actual Result

❯ nomad exec -task web -job countdash sh                                                                                                                                                  
Could not find task named: web, found:                                                                                                                                                       
dashboard                                                                                                                                                                                    
connect-proxy-count-dashboard

However, repeating the command multiple times will finally work.

Job file (if appropriate)

nomad init -short -connect

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

@jrasell jrasell moved this from Needs Triage to Needs Roadmapping in Nomad - Community Issues Triage Jan 24, 2025
@jrasell jrasell added theme/allocation API stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Jan 24, 2025
@tgross
Copy link
Member

tgross commented Jan 24, 2025

The challenge here is that alloc exec picks a random allocation and the job you're targeting has multiple groups. So it's picking an allocation at random, but not all allocations will have the same tasks. We probably should add a -group flag to cover this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hcc/jira stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/allocation API theme/cli type/bug
Projects
Status: Needs Roadmapping
Development

No branches or pull requests

3 participants