client: Fail startup if host volumes do not exist
Some drivers will automatically create directories when trying to mount a path into a container, but some will not. To unify this behaviour, this commit requires that host volumes already exist, and can be stat'd by the Nomad Agent during client startup.
This commit is contained in:
parent
e4e50abb02
commit
e3796e9d60
|
@ -1279,11 +1279,13 @@ func (c *Client) setupNode() error {
|
|||
if node.Name == "" {
|
||||
node.Name, _ = os.Hostname()
|
||||
}
|
||||
// TODO(dani): Fingerprint these to handle volumes that don't exist/have bad perms.
|
||||
if node.HostVolumes == nil {
|
||||
if l := len(c.config.HostVolumes); l != 0 {
|
||||
node.HostVolumes = make(map[string]*structs.ClientHostVolumeConfig, l)
|
||||
for k, v := range c.config.HostVolumes {
|
||||
if _, err := os.Stat(v.Path); err != nil {
|
||||
return fmt.Errorf("failed to validate volume %s, err: %v", v.Name, err)
|
||||
}
|
||||
node.HostVolumes[k] = v.Copy()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue