@@ -82,10 +82,12 @@ type PluginConf struct {
82
82
}
83
83
84
84
func main () {
85
+ // Must log to Stderr because the CNI runtime uses Stdout as its state
86
+ logrus .SetOutput (os .Stderr )
85
87
skel .PluginMain (cmdAdd , cmdCheck , cmdDel , version .All , "" )
86
88
}
87
89
88
- func configureLogging (logLevel string ) {
90
+ func configureLoggingLevel (logLevel string ) {
89
91
switch strings .ToLower (logLevel ) {
90
92
case "debug" :
91
93
logrus .SetLevel (logrus .DebugLevel )
@@ -94,9 +96,6 @@ func configureLogging(logLevel string) {
94
96
default :
95
97
logrus .SetLevel (logrus .WarnLevel )
96
98
}
97
-
98
- // Must log to Stderr because the CNI runtime uses Stdout as its state
99
- logrus .SetOutput (os .Stderr )
100
99
}
101
100
102
101
// parseConfig parses the supplied configuration (and prevResult) from stdin.
@@ -131,12 +130,12 @@ func parseConfig(stdin []byte) (*PluginConf, error) {
131
130
132
131
// cmdAdd is called by the CNI runtime for ADD requests
133
132
func cmdAdd (args * skel.CmdArgs ) error {
134
- logrus .Debug ("linkerd-cni: cmdAdd, parsing config" )
135
133
conf , err := parseConfig (args .StdinData )
136
134
if err != nil {
135
+ logrus .Errorf ("error parsing config: %e" , err )
137
136
return err
138
137
}
139
- configureLogging (conf .LogLevel )
138
+ configureLoggingLevel (conf .LogLevel )
140
139
141
140
if conf .PrevResult != nil {
142
141
logrus .WithFields (logrus.Fields {
@@ -154,6 +153,7 @@ func cmdAdd(args *skel.CmdArgs) error {
154
153
args .Args = strings .Replace (args .Args , "K8S_POD_NAMESPACE" , "K8sPodNamespace" , 1 )
155
154
args .Args = strings .Replace (args .Args , "K8S_POD_NAME" , "K8sPodName" , 1 )
156
155
if err := types .LoadArgs (args .Args , & k8sArgs ); err != nil {
156
+ logrus .Errorf ("error loading args %e" , err )
157
157
return err
158
158
}
159
159
@@ -173,16 +173,19 @@ func cmdAdd(args *skel.CmdArgs) error {
173
173
174
174
config , err := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (configLoadingRules , configOverrides ).ClientConfig ()
175
175
if err != nil {
176
+ logrus .Errorf ("linkerd-cni client err with NewNonInteractiveDeferredLoadingClientConfig: %e" , err )
176
177
return err
177
178
}
178
179
179
180
client , err := kubernetes .NewForConfig (config )
180
181
if err != nil {
182
+ logrus .Errorf ("linkerd-cni client err with NewForConfig: %e" , err )
181
183
return err
182
184
}
183
185
184
186
pod , err := client .CoreV1 ().Pods (namespace ).Get (ctx , podName , metav1.GetOptions {})
185
187
if err != nil {
188
+ logrus .Errorf ("linkerd-cni client err in client.Pods().Get(): %e" , err )
186
189
return err
187
190
}
188
191
0 commit comments