Skip to content

Commit

Permalink
Update to CNI & Plugins 1.0.1 with stable 1.0 spec
Browse files Browse the repository at this point in the history
The `flannel` plugin is now part of a different repository, so is not
built as part of a singularityce install.

Plugins `sbr` and `vrf` that were previously not built, but are part
of plugins v1.0.1, have been added to the build.

Fixes sylabs#336
  • Loading branch information
dtrudg committed Sep 28, 2021
1 parent df1dbe7 commit 961c1fc
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
arguments.
- An invalid remote build source (bootstrap) will be identified before
attempting to submit the build.
- The bundled reference CNI plugins are updated to v1.0.1. The `flannel` plugin
is no longer included, as it is maintained as a separate plugin at:
<https://github.com/flannel-io/cni-plugin>. If you use the flannel CNI plugin
you should install it from this repository.

### New features / functionalities

Expand Down
2 changes: 1 addition & 1 deletion etc/network/00_bridge.conflist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "bridge",
"plugins": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/network/10_ptp.conflist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "ptp",
"plugins": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/network/20_ipvlan.conflist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "ipvlan",
"plugins": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/network/30_macvlan.conflist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "macvlan",
"plugins": [
{
Expand Down
2 changes: 1 addition & 1 deletion etc/network/40_fakeroot.conflist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "fakeroot",
"plugins": [
{
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ require (
github.com/Netflix/go-expect v0.0.0-20190729225929-0e00d9168667
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7
github.com/adigunhammedolalekan/registry-auth v0.0.0-20200730122110-8cde180a3a60
github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f // indirect
github.com/apex/log v1.9.0
github.com/blang/semver/v4 v4.0.0
github.com/buger/jsonparser v1.1.1
github.com/bugsnag/bugsnag-go v1.5.1 // indirect
github.com/bugsnag/panicwrap v1.2.0 // indirect
github.com/containerd/cgroups v1.0.1
github.com/containerd/containerd v1.5.5
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/plugins v0.9.1
github.com/containernetworking/cni v1.0.1
github.com/containernetworking/plugins v1.0.1
github.com/containers/image/v5 v5.16.0
github.com/cyphar/filepath-securejoin v0.2.3
github.com/docker/docker v20.10.8+incompatible
github.com/fatih/color v1.13.0
github.com/garyburd/redigo v1.6.0 // indirect
github.com/go-log/log v0.2.0
github.com/godbus/dbus v4.1.0+incompatible // indirect
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.3.0
Expand Down
46 changes: 32 additions & 14 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion internal/pkg/runtime/engine/singularity/plugins_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import (
_ "github.com/containernetworking/plugins/plugins/main/vlan"
_ "github.com/containernetworking/plugins/plugins/meta/bandwidth"
_ "github.com/containernetworking/plugins/plugins/meta/firewall"
_ "github.com/containernetworking/plugins/plugins/meta/flannel"
_ "github.com/containernetworking/plugins/plugins/meta/portmap"
_ "github.com/containernetworking/plugins/plugins/meta/sbr"
_ "github.com/containernetworking/plugins/plugins/meta/tuning"
_ "github.com/containernetworking/plugins/plugins/meta/vrf"
)
15 changes: 12 additions & 3 deletions pkg/network/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
cnitypes "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
"github.com/sylabs/singularity/internal/pkg/util/env"
)
Expand Down Expand Up @@ -233,6 +233,14 @@ func (m *Setup) SetArgs(args []string) error {
return fmt.Errorf("there is no configured network in list")
}

// Force plugins to ignore extra CNI_ARGS that they don't consume.
// If we don't do this we get an error when e.g. passing IP= to a
// bridge+ipam config, as bridge now handles args from v1.0.1, but
// doesn't consume IP.
for i := range m.networks {
m.runtimeConf[i].Args = append(m.runtimeConf[i].Args, [2]string{"IgnoreUnknown", "1"})
}

for _, arg := range args {
var splitted []string
networkName := ""
Expand Down Expand Up @@ -338,12 +346,13 @@ func (m *Setup) GetNetworkIP(network string, version string) (net.IP, error) {

for i := 0; i < len(m.networkConfList); i++ {
if m.networkConfList[i].Name == n {
res, err := current.NewResultFromResult(m.result[i])
res, err := cnitypes.NewResultFromResult(m.result[i])
if err != nil {
return nil, fmt.Errorf("could not convert result: %v", err)
}
for _, ipResult := range res.IPs {
if ipResult.Version == version {
is4 := ipResult.Address.IP.To4() != nil
if (is4 && version == "4") || version == "6" {
return ipResult.Address.IP, nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/network_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var confFiles = []struct {
name: "test-bridge",
file: "00_test-bridge.conflist",
content: `{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "test-bridge",
"plugins": [
{
Expand Down Expand Up @@ -67,7 +67,7 @@ var confFiles = []struct {
name: "test-badbridge",
file: "10_badbridge.conflist",
content: `{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "test-badbridge",
"plugins": [
{
Expand All @@ -81,7 +81,7 @@ var confFiles = []struct {
name: "test-bridge-iprange",
file: "20_bridge_iprange.conflist",
content: `{
"cniVersion": "0.4.0",
"cniVersion": "1.0.0",
"name": "test-bridge-iprange",
"plugins": [
{
Expand Down Expand Up @@ -480,7 +480,7 @@ func testHTTPPortmap(nsPath string, cniPath *CNIPath, stdin io.WriteCloser, stdo
if eth != "eth0" {
return fmt.Errorf("unexpected interface %s", eth)
}
conn, err := net.Dial("tcp", ":31080")
conn, err := net.Dial("tcp", "127.0.0.1:31080")
if err != nil {
return err
}
Expand Down

0 comments on commit 961c1fc

Please sign in to comment.