Skip to content

Commit

Permalink
Fingerprint rkt volume support and make periodic
Browse files Browse the repository at this point in the history
Fix rkt docs and custom volume mounting
  • Loading branch information
schmichael committed Oct 24, 2016
1 parent 31a8149 commit dc1dabe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
15 changes: 11 additions & 4 deletions client/driver/rkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -57,7 +56,6 @@ const (
// planned in the future
type RktDriver struct {
DriverContext
fingerprint.StaticFingerprinter
}

type RktDriverConfig struct {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]))
}
}

Expand Down
12 changes: 2 additions & 10 deletions website/source/docs/drivers/rkt.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
```

Expand Down

0 comments on commit dc1dabe

Please sign in to comment.