hashicorp / hashicorp/nomad

Java driver should not fingerprint if java not found in exec chroot

Open
#10,751 5 comments 1 reaction 0 assignees View on GitHub
stage/accepted theme/driver/java type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
1.1.1

### Operating system and Environment details
Red Hat Linux 8.3

### Issue
When trying to deploy a Java workload, the job is being allocated to one of the Nomad clients with the Java driver activated, but it fails to run, and throws the below error. Please note that `app` is the name of my task.
```
failed to launch command with executor: rpc error: code = Unknown desc = file /var/openjdk/bin/java not found under path /opt/nomad/alloc/49280540-a500-55bd-f437-fdd497467ddc/app
```
### Reproduction steps
Extract a binary distribution of JDK into `/var/openjdk`
Run a Nomad client with the below configuration
```hcl
# Excerpt from config.hcl
client {
enabled = true

server_join {
retry_join = [ "provider=aws tag_key=Name tag_value=nomad-server" ]
retry_max = 0
retry_interval = "15s"
}

options = {
"driver.allowlist" = "podman,java"
}
}

plugin "podman" {

}

plugin "java" {

}
```
Below is the systemd unit file
```unit
[Unit]
Description=Nomad
Documentation=https://www.nomadproject.io/docs/
Wants=network-online.target
After=network-online.target

[Service]
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/nomad agent -config /etc/nomad.d
KillMode=process
KillSignal=SIGINT
LimitNOFILE=65536
LimitNPROC=infinity
Restart=on-failure
RestartSec=2

# Removing this line starts nomad, but doesn't activate java driver
Environment="PATH=$PATH:/var/openjdk/bin"

TasksMax=infinity
OOMScoreAdjust=-1000

[Install]
WantedBy=multi-user.target
```
#### Expected Result
1. Job is allocated to a Nomad client with Java driver activated
2. Job is scheduled and runs normally
#### Actual Result
Job is allocated, but cannot start. The below error is thrown
```
failed to launch command with executor: rpc error: code = Unknown desc = file /var/openjdk/bin/java not found under path /opt/nomad/alloc/49280540-a500-55bd-f437-fdd497467ddc/app
```
#### :interrobang: :interrobang: Update
Add `/var` to the client's chroot with the below configuration, gives me a new error
```hcl
chroot_env {
"/bin" = "/bin"
"/etc" = "/etc"
"/lib" = "/lib"
"/lib32" = "/lib32"
"/lib64" = "/lib64"
"/run/resolvconf" = "/run/resolvconf"
"/sbin" = "/sbin"
"/usr" = "/usr"
"/var" = "/var"
}

```
```
[ERROR] client.alloc_runner.task_runner: running driver failed: alloc_id=f5911e98-0101-f597-c79f-d573594b7ea4 task=app error="failed to launch command with executor: rpc error: code = Unknown desc = container_linux.go:367: starting container process caused: exec: "/var/openjdk/bin/java": stat /var/openjdk/bin/java: permission denied"
```

### Job file (if appropriate)
A typical [example Java job](https://www.nomadproject.io/docs/drivers/java)

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.