Skip to content

Commit 7161a3e

Browse files
author
Steve Jenson
authored
use the cni test image that we've just built for our tests (#177)
* use the cni test image that we've just built for our tests * `nsenter` requires an equal sign for an argument * remove unneeded log statement. Signed-off-by: Steve Jenson <[email protected]>
1 parent d643705 commit 7161a3e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

cni-plugin/integration/manifests/linkerd-cni.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ spec:
127127
# script copies the files into place and then sleeps so
128128
# that Kubernetes doesn't keep trying to restart it.
129129
- name: install-cni
130-
#image: test.l5d.io/linkerd/cni-plugin:test
131-
image: cr.l5d.io/linkerd/cni-plugin:edge-22.12.1
130+
image: test.l5d.io/linkerd/cni-plugin:test
131+
#image: cr.l5d.io/linkerd/cni-plugin:edge-22.12.1
132132
env:
133133
- name: DEST_CNI_NET_DIR
134134
valueFrom:

cni-plugin/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ type PluginConf struct {
8282
}
8383

8484
func main() {
85+
// Must log to Stderr because the CNI runtime uses Stdout as its state
86+
logrus.SetOutput(os.Stderr)
8587
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, "")
8688
}
8789

88-
func configureLogging(logLevel string) {
90+
func configureLoggingLevel(logLevel string) {
8991
switch strings.ToLower(logLevel) {
9092
case "debug":
9193
logrus.SetLevel(logrus.DebugLevel)
@@ -94,9 +96,6 @@ func configureLogging(logLevel string) {
9496
default:
9597
logrus.SetLevel(logrus.WarnLevel)
9698
}
97-
98-
// Must log to Stderr because the CNI runtime uses Stdout as its state
99-
logrus.SetOutput(os.Stderr)
10099
}
101100

102101
// parseConfig parses the supplied configuration (and prevResult) from stdin.
@@ -131,12 +130,12 @@ func parseConfig(stdin []byte) (*PluginConf, error) {
131130

132131
// cmdAdd is called by the CNI runtime for ADD requests
133132
func cmdAdd(args *skel.CmdArgs) error {
134-
logrus.Debug("linkerd-cni: cmdAdd, parsing config")
135133
conf, err := parseConfig(args.StdinData)
136134
if err != nil {
135+
logrus.Errorf("error parsing config: %e", err)
137136
return err
138137
}
139-
configureLogging(conf.LogLevel)
138+
configureLoggingLevel(conf.LogLevel)
140139

141140
if conf.PrevResult != nil {
142141
logrus.WithFields(logrus.Fields{
@@ -154,6 +153,7 @@ func cmdAdd(args *skel.CmdArgs) error {
154153
args.Args = strings.Replace(args.Args, "K8S_POD_NAMESPACE", "K8sPodNamespace", 1)
155154
args.Args = strings.Replace(args.Args, "K8S_POD_NAME", "K8sPodName", 1)
156155
if err := types.LoadArgs(args.Args, &k8sArgs); err != nil {
156+
logrus.Errorf("error loading args %e", err)
157157
return err
158158
}
159159

@@ -173,16 +173,19 @@ func cmdAdd(args *skel.CmdArgs) error {
173173

174174
config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(configLoadingRules, configOverrides).ClientConfig()
175175
if err != nil {
176+
logrus.Errorf("linkerd-cni client err with NewNonInteractiveDeferredLoadingClientConfig: %e", err)
176177
return err
177178
}
178179

179180
client, err := kubernetes.NewForConfig(config)
180181
if err != nil {
182+
logrus.Errorf("linkerd-cni client err with NewForConfig: %e", err)
181183
return err
182184
}
183185

184186
pod, err := client.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})
185187
if err != nil {
188+
logrus.Errorf("linkerd-cni client err in client.Pods().Get(): %e", err)
186189
return err
187190
}
188191

internal/iptables/iptables.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ func executeCommand(firewallConfiguration FirewallConfiguration, cmd *exec.Cmd)
234234
// command.
235235
//
236236
// See https://github.com/rancher/k3s/issues/1434#issuecomment-629315909
237-
args := append([]string{"--net", firewallConfiguration.NetNs, "--"}, cmd.Args...)
237+
nsArgs := fmt.Sprintf("--net=%s", firewallConfiguration.NetNs)
238+
args := append([]string{nsArgs, "--"}, cmd.Args...)
238239
cmd = exec.Command("nsenter", args...)
239240
}
240241
log.Info(cmd.String())

0 commit comments

Comments
 (0)