From dc1dabe6b3eb7b90fa03877d068509f63031f2a2 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Mon, 24 Oct 2016 16:00:19 -0700 Subject: [PATCH] Fingerprint rkt volume support and make periodic Fix rkt docs and custom volume mounting --- client/driver/docker.go | 2 +- client/driver/rkt.go | 15 +++++++++++---- website/source/docs/drivers/rkt.html.md | 12 ++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index d99e6e08c425..c1b33d843313 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -369,7 +369,7 @@ func (d *DockerDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool node.Attributes[dockerDriverAttr] = "1" node.Attributes["driver.docker.version"] = env.Get("Version") - // Advertise if this node supports Docker volumes (by default we do not) + // Advertise if this node supports Docker volumes if d.config.ReadBoolDefault(dockerVolumesConfigOption, dockerVolumesConfigDefault) { node.Attributes["driver."+dockerVolumesConfigOption] = "1" } diff --git a/client/driver/rkt.go b/client/driver/rkt.go index 333d1efb70f9..14f3b6087b1c 100644 --- a/client/driver/rkt.go +++ b/client/driver/rkt.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/driver/executor" dstructs "github.com/hashicorp/nomad/client/driver/structs" - "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/helper/fields" @@ -57,7 +56,6 @@ const ( // planned in the future type RktDriver struct { DriverContext - fingerprint.StaticFingerprinter } type RktDriverConfig struct { @@ -175,9 +173,18 @@ func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, e d.logger.Printf("[WARN] driver.rkt: please upgrade rkt to a version >= %s", minVersion) node.Attributes[rktDriverAttr] = "0" } + + // Advertise if this node supports rkt volumes + if d.config.ReadBoolDefault(rktVolumesConfigOption, rktVolumesConfigDefault) { + node.Attributes["driver."+rktVolumesConfigOption] = "1" + } return true, nil } +func (d *RktDriver) Periodic() (bool, time.Duration) { + return true, 15 * time.Second +} + // Run an existing Rkt image. func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) { var driverConfig RktDriverConfig @@ -247,8 +254,8 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e return nil, fmt.Errorf("invalid rkt volume: %q", rawvol) } volName := fmt.Sprintf("%s-%s-%d", ctx.AllocID, task.Name, i) - cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", volName, i, parts[0])) - cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", volName, i, parts[1])) + cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", volName, parts[0])) + cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", volName, parts[1])) } } diff --git a/website/source/docs/drivers/rkt.html.md b/website/source/docs/drivers/rkt.html.md index c82094baf7da..2056c76bcfa2 100644 --- a/website/source/docs/drivers/rkt.html.md +++ b/website/source/docs/drivers/rkt.html.md @@ -76,19 +76,11 @@ The `rkt` driver supports the following configuration in the job spec: * `debug` - (Optional) Enable rkt command debug option. * `volumes` - (Optional) A list of `host_path:container_path` strings to bind - host paths to container paths. Mounting host paths outside of the alloc - directory tasks normally have access to can be disabled on clients by setting - the `rkt.volumes.enabled` option set to false. + host paths to container paths. ```hcl config { - volumes = [ - # Use absolute paths to mount arbitrary paths on the host - "/path/on/host:/path/in/container", - - # Use relative paths to rebind paths already in the allocation dir - "relative/to/alloc:/also/in/container" - ] + volumes = ["/path/on/host:/path/in/container"] } ```