From da7e3f318b220192ea695a6e1ac3097006c98d8e 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 bafde051718..5e64cd8c689 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -370,7 +370,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 40908c20670..735ff20ae7a 100644 --- a/client/driver/rkt.go +++ b/client/driver/rkt.go @@ -21,7 +21,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" @@ -58,7 +57,6 @@ const ( // planned in the future type RktDriver struct { DriverContext - fingerprint.StaticFingerprinter } type RktDriverConfig struct { @@ -176,9 +174,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 @@ -248,8 +255,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 c82094baf7d..2056c76bcfa 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"] } ```