Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Backport of Nomad install DB directory fix into release/0.8.x #3326

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3261.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
install/nomad: Fix DB directory for Nomad install
```
21 changes: 19 additions & 2 deletions internal/serverinstall/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
json "encoding/json"
"fmt"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -35,6 +36,7 @@ type nomadConfig struct {
consulServiceBackendTags []string `hcl:"consul_service_backend_tags:optional"`
consulDatacenter string `hcl:"consul_datacenter,optional"`
consulDomain string `hcl:"consul_datacenter,optional"`
consulToken string `hcl:"consul_token,optional"`

// If set along with consul, will use this hostname instead of
// making a consul DNS hostname for the server address in its context
Expand Down Expand Up @@ -856,6 +858,13 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job {
// Include services to be registered in Consul. Currently configured to happen by default
// One service added for Waypoint UI, and one for Waypoint backend port
if c.consulService {
token := ""
if c.consulToken == "" {
token = os.Getenv("CONSUL_HTTP_TOKEN")
} else {
token = c.consulToken
}
job.ConsulToken = &token
tg.Services = []*api.Service{
{
Name: waypointConsulUIName,
Expand Down Expand Up @@ -929,7 +938,7 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job {
// Doing this because this is the only way https://github.com/hashicorp/nomad/issues/8892
"image": "busybox:latest",
"command": "sh",
"args": []string{"-c", fmt.Sprintf("chown -R %d:%d /data/", waypointUserID, waypointGroupID)},
"args": []string{"-c", fmt.Sprintf("chown -R %d:%d /data", waypointUserID, waypointGroupID)},
}
preTask.VolumeMounts = volumeMounts
preTask.Resources = &api.Resources{
Expand All @@ -943,7 +952,7 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job {

tg.AddTask(preTask)

ras := []string{"server", "run", "-accept-tos", "-vv", "-db=/alloc/data/data.db", fmt.Sprintf("-listen-grpc=0.0.0.0:%s", defaultGrpcPort), fmt.Sprintf("-listen-http=0.0.0.0:%s", defaultHttpPort)}
ras := []string{"server", "run", "-accept-tos", "-vv", "-db=/data/data.db", fmt.Sprintf("-listen-grpc=0.0.0.0:%s", defaultGrpcPort), fmt.Sprintf("-listen-http=0.0.0.0:%s", defaultHttpPort)}
ras = append(ras, rawRunFlags...)
task := api.NewTask("server", "docker")
task.Config = map[string]interface{}{
Expand Down Expand Up @@ -1249,6 +1258,14 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) {
Default: defaultConsulDomain,
})

set.StringVar(&flag.StringVar{
Name: "nomad-consul-token",
Target: &i.config.consulToken,
Usage: "If set, the passed Consul token is stored in the job " +
"before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN " +
"environment variable if set.",
})

set.StringVar(&flag.StringVar{
Name: "nomad-host-volume",
Target: &i.config.hostVolume,
Expand Down
1 change: 1 addition & 0 deletions website/content/commands/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ and disable the UI, the command would be:
- `-nomad-consul-service-backend-tags=<string>` - Tags for the Waypoint backend service generated in Consul. The 'first' tag will be used when crafting the Consul DNS hostname for accessing Waypoint.
- `-nomad-consul-datacenter=<string>` - The datacenter where Consul is located.
- `-nomad-consul-domain=<string>` - The domain where Consul is located.
- `-nomad-consul-token=<string>` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set.
- `-nomad-host-volume=<string>` - Nomad host volume name, required for volume type 'host'.
- `-nomad-csi-volume-provider=<string>` - Nomad CSI volume provider, required for volume type 'csi'.
- `-nomad-csi-volume-capacity-min=<int>` - Nomad CSI volume capacity minimum, in bytes.
Expand Down
1 change: 1 addition & 0 deletions website/content/commands/server-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ and disable the UI, the command would be:
- `-nomad-consul-service-backend-tags=<string>` - Tags for the Waypoint backend service generated in Consul. The 'first' tag will be used when crafting the Consul DNS hostname for accessing Waypoint.
- `-nomad-consul-datacenter=<string>` - The datacenter where Consul is located.
- `-nomad-consul-domain=<string>` - The domain where Consul is located.
- `-nomad-consul-token=<string>` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set.
- `-nomad-host-volume=<string>` - Nomad host volume name, required for volume type 'host'.
- `-nomad-csi-volume-provider=<string>` - Nomad CSI volume provider, required for volume type 'csi'.
- `-nomad-csi-volume-capacity-min=<int>` - Nomad CSI volume capacity minimum, in bytes.
Expand Down