hashicorp / hashicorp/nomad

UI - Provide default executable for 'exec' on tasks

Open
#24,155 3 comments 1 reaction 1 assignee Claimed by @philrenaud View on GitHub
theme/ui type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal

It would be nice if when clicking the 'exec' button on a task, instead of offering the last command entered as a default, allow the job to provide a default command.

Many modern containers don't contain bash and sometimes don't contain sh, it can be very confusing for an operator trying to 'exec' into a task without having full knowledge of that container.

In this proposal, we add a new parameter default_exec_command to the task:

```
task "myawesometask" {
driver = "docker"
config {
image = "bash"
default_exec_command="bash"
}
}
```

When trying to 'exec' into the task via the web us, the command 'bash' would be auto filled in the popup:

![image](https://github.com/user-attachments/assets/87ba8853-e255-4768-b8c0-e96cea51594a)

The Nomad operator, by default, would be able to change the command(as is the case now) before entering the container, however a second parameter 'exec_command_can_not_be_changed=yes' could be set that would make the parameter read-only. In other words, if this second parameter is set, the Nomad operator running 'exec' would have no choice but to execute the command exactly as provided by the Nomad job definition.

### Use-cases

1. Task uses docker without bash or sh, job writer wants to provide the executable path to the Nomad operator
2. Nomad Operator has limited access to Nomad and needs to be able to execute an interactive action. Since the action stanza doesn't allow for interactions, the job writer could set the 'default_exec_command' and 'exec_command_can_not_be_changed' parameters and give that operator the ability to gain access to the container in a limited fashion
3. Faster access to containers, often times when accessing a task I'll accept the default command forgetting that the container I am accessing might not have bash.

### Attempted Solutions

Not really any attempted solutions, it's just manual steps that humans have to do each time an allocation's task is access through the 'exec' command.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.