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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user