From ab9182d18294ac730bf25ca2978e77f3fb4b464c Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 27 May 2015 11:57:39 +0200 Subject: [PATCH] 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 --- stage1/init/init.go | 2 +- stage1/init/pod.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index decd961..6f3c3b0 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -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 } diff --git a/stage1/init/pod.go b/stage1/init/pod.go index cdda134..40f4c59 100644 --- a/stage1/init/pod.go +++ b/stage1/init/pod.go @@ -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...) }