From 8462a3f607e90948dcc3d2ff3c1e3fe54e1c5453 Mon Sep 17 00:00:00 2001 From: Neil Wilson Date: Mon, 7 Sep 2015 15:15:23 +0000 Subject: [PATCH 1/2] IPAM plugin: improve error messages Make it more clear that we failed to find an IPAM plugin. Check for a missing plugin name and issue a more helpful error. --- pkg/plugin/ipam.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/plugin/ipam.go b/pkg/plugin/ipam.go index 93a0d5c9..8690b895 100644 --- a/pkg/plugin/ipam.go +++ b/pkg/plugin/ipam.go @@ -63,10 +63,13 @@ func ExecAdd(plugin string, netconf []byte) (*Result, error) { if os.Getenv("CNI_COMMAND") != "ADD" { return nil, fmt.Errorf("CNI_COMMAND is not ADD") } + if plugin == "" { + return nil, fmt.Errorf(`Name of IPAM plugin is missing. Specify a "type" field in the "ipam" section`) + } pluginPath := Find(plugin) if pluginPath == "" { - return nil, fmt.Errorf("could not find %q plugin", plugin) + return nil, fmt.Errorf("could not find %q IPAM plugin", plugin) } stdout := &bytes.Buffer{} From 2d0d4b35e1edd37f66c72699f2a3703eb3ec3b01 Mon Sep 17 00:00:00 2001 From: Neil Wilson Date: Tue, 8 Sep 2015 03:20:11 +0000 Subject: [PATCH 2/2] plugin/ipam: correct formatting of error message --- pkg/plugin/ipam.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/plugin/ipam.go b/pkg/plugin/ipam.go index 8690b895..f304301f 100644 --- a/pkg/plugin/ipam.go +++ b/pkg/plugin/ipam.go @@ -64,8 +64,8 @@ func ExecAdd(plugin string, netconf []byte) (*Result, error) { return nil, fmt.Errorf("CNI_COMMAND is not ADD") } if plugin == "" { - return nil, fmt.Errorf(`Name of IPAM plugin is missing. Specify a "type" field in the "ipam" section`) - } + return nil, fmt.Errorf(`name of IPAM plugin is missing. Please specify a "type" field in the "ipam" section`) + } pluginPath := Find(plugin) if pluginPath == "" {