Propagate json error object to the caller

When plugin errors out, it prints out a JSON object to stdout
describing the failure. This object needs to be propagated out
through the plugins and to the container runtime. This change
also adds Print method to both the result and error structs
for easy serialization to stdout.
This commit is contained in:
Eugene Yakubovich
2015-06-01 17:34:00 -07:00
parent 54dfc9ef5d
commit 33a575f49d
10 changed files with 79 additions and 37 deletions

View File

@ -16,9 +16,14 @@ function exec_plugins() {
plugin=$(jq -r '.type' <$netconf)
export CNI_IFNAME=$(printf eth%d $i)
$plugin <$netconf >/dev/null
res=$($plugin <$netconf)
if [ $? -ne 0 ]; then
echo "${name} : error executing $CNI_COMMAND"
errmsg=$(echo $res | jq -r '.msg')
if [ -z "$errmsg" ]; then
errmsg=$res
fi
echo "${name} : error executing $CNI_COMMAND: $errmsg"
exit 1
fi