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

Allow cni runtime capabilities to be configuratble from CNIConfiguration #349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ steps:
# To use ${FC_TEST_DATA_PATH} as testdata/, all files in the original directory must be
# copied to the new directory.
- cp -r testdata/* ${FC_TEST_DATA_PATH}
# Install tc-redirect-tap.
- 'go get github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap'
# Install tc-redirect-tap and portmap
- go get github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap
- go get github.com/containernetworking/plugins/plugins/meta/portmap
Copy link
Author

Choose a reason for hiding this comment

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

added portmap due to buildkite complained about

failed to find plugin "portmap" in path [/opt/cni/bin /tmp/buildkite_build_1885_testdata/bin]

# Copy vmlinux and root-drive.img.
- ln -s /var/lib/fc-ci/vmlinux.bin ${FC_TEST_DATA_PATH}/vmlinux
- ln -s /var/lib/fc-ci/rootfs.ext4 ${FC_TEST_DATA_PATH}/root-drive.img
Expand Down
16 changes: 12 additions & 4 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ type CNIConfiguration struct {
// configuration directory.
NetworkConfig *libcni.NetworkConfigList

// CapabilityArgs (optional) is a dictionary of capability-specific
// data passed by the runtime to plugins as top-level keys in the
// 'runtimeConfig' dictionary of the plugin's stdin data. libcni
// will ensure that only keys in this map which match the capabilities
// of the plugin are passed to the plugin.
CapabilityArgs map[string]interface{}

// IfName (optional) corresponds to the CNI_IFNAME parameter as specified
// in the CNI spec. It generally specifies the name of the interface to be
// created by a CNI plugin being invoked.
Expand Down Expand Up @@ -316,10 +323,11 @@ func (cniConf *CNIConfiguration) setDefaults() {

func (cniConf CNIConfiguration) asCNIRuntimeConf() *libcni.RuntimeConf {
return &libcni.RuntimeConf{
ContainerID: cniConf.containerID,
NetNS: cniConf.netNSPath,
IfName: cniConf.IfName,
Args: cniConf.Args,
ContainerID: cniConf.containerID,
NetNS: cniConf.netNSPath,
IfName: cniConf.IfName,
Args: cniConf.Args,
CapabilityArgs: cniConf.CapabilityArgs,
}
}

Expand Down
13 changes: 13 additions & 0 deletions network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) {
},
{
"type": "tc-redirect-tap"
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
}
]
}`, networkName)
Expand Down Expand Up @@ -424,6 +428,15 @@ func newCNIMachine(t *testing.T,
NetworkConfig: networkConf,
IfName: ifName,
VMIfName: "eth0",
CapabilityArgs: map[string]interface{}{
"portMappings": []interface{}{
map[string]interface{}{
"hostPort": 8080,
"containerPort": 80,
"protocol": "tcp",
},
},
},
},
}},
VMID: vmID,
Expand Down