Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from skel.PluginMain to skel.PluginMainWithError, as the log h… #451

Merged
merged 1 commit into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions plugins/routed-eni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"runtime"

"golang.org/x/net/context"
Expand Down Expand Up @@ -142,7 +143,7 @@ func add(args *skel.CmdArgs, cniTypes typeswrapper.CNITYPES, grpcClient grpcwrap
K8S_POD_NAME: string(k8sArgs.K8S_POD_NAME),
K8S_POD_NAMESPACE: string(k8sArgs.K8S_POD_NAMESPACE),
K8S_POD_INFRA_CONTAINER_ID: string(k8sArgs.K8S_POD_INFRA_CONTAINER_ID),
IfName: args.IfName})
IfName: args.IfName})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.


if err != nil {
log.Errorf("Error received from AddNetwork grpc call for pod %s namespace %s container %s: %v",
Expand Down Expand Up @@ -296,10 +297,20 @@ func del(args *skel.CmdArgs, cniTypes typeswrapper.CNITYPES, grpcClient grpcwrap
}

func main() {
defer log.Flush()
logger.SetupLogger(logger.GetLogFileLocation(defaultLogFilePath))

log.Infof("Starting CNI Plugin %s ...", version)

skel.PluginMain(cmdAdd, cmdDel, cniSpecVersion.All)
exitCode := 0

if e := skel.PluginMainWithError(cmdAdd, cmdDel, cniSpecVersion.All); e != nil {
exitCode = 1
log.Error("Failed CNI request: ", e)
if err := e.Print(); err != nil {
log.Error("Error writing error JSON to stdout: ", err)
}
}

log.Flush()
os.Exit(exitCode)
}