rkt: better error messages when users don't give enough volumes

Example of output:
|  $ rkt --debug --insecure-skip-verify run docker://redis
|  Failed to generate nspawn args: no volume for mountpoint "volume-/data" in app "redis".
|  You can inspect the volumes with:
|  	sudo rkt image cat-manifest --pretty-print sha512-f95f15ce81345214328fdbe9407fdac3e46de0c11ceb69e8da5b0d1aa3158dfc
|  App "redis" requires the following volumes:
|  	--volume volume-/data,kind=host,source=/some/path

Fixes: https://github.com/coreos/rkt/issues/943
This commit is contained in:
Alban Crequy
2015-05-27 12:51:02 +02:00
parent db421dd865
commit ab9182d182
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -365,7 +365,7 @@ func stage1() int {
args, env, err := getArgsEnv(p, flavor, systemdVersion, debug)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get execution parameters: %v\n", err)
fmt.Fprintf(os.Stderr, "%v\n", err)
return 3
}
+11 -2
View File
@@ -327,7 +327,16 @@ func (p *Pod) appToNspawnArgs(ra *schema.RuntimeApp, am *schema.ImageManifest) (
key := mp.Name
vol, ok := vols[key]
if !ok {
return nil, fmt.Errorf("no volume for mountpoint %q in app %q", key, name)
catCmd := fmt.Sprintf("sudo rkt image cat-manifest --pretty-print %v", id)
volumeCmd := ""
for _, mp := range app.MountPoints {
volumeCmd += fmt.Sprintf("--volume %s,kind=host,source=/some/path ", mp.Name)
}
return nil, fmt.Errorf("no volume for mountpoint %q in app %q.\n"+
"You can inspect the volumes with:\n\t%v\n"+
"App %q requires the following volumes:\n\t%v",
key, name, catCmd, name, volumeCmd)
}
opt := make([]string, 4)
@@ -385,7 +394,7 @@ func (p *Pod) PodToNspawnArgs() ([]string, error) {
}
aa, err := p.appToNspawnArgs(ra, am)
if err != nil {
return nil, fmt.Errorf("failed to construct args for app %q: %v", am.Name, err)
return nil, err
}
args = append(args, aa...)
}