Skip to content

Commit

Permalink
Upgrade CNI to 0.6.0 in netplugin (#1100)
Browse files Browse the repository at this point in the history
This PR upgrades CNI to 0.6.0 in netplugin. It has the following changes:

Update ImportPath, version and Rev (git commit SHA) in Godeps.json for CNI 0.6.0.

Update CNI version to 0.6.0 in the following k8s YAML files:
  install/k8s/contiv/contiv.yaml
  install/k8s/contiv/contiv_aci.yaml
  install/k8s/contiv/contiv_devtest.yaml

Replace legacy import path appc/cni with the correct import path containernetworking/cni in k8s_cni.go and update required code to handle IPv4 and IPv6 addresses with CNI 0.6.0.

Removed legacy vendor dir netplugin/vendor/github.com/appc.

Added new vendor dir netplugin/vendor/github.com/containernetworking/cni needed for CNI 0.6.0.

Signed-off-by: Vikram Hosakote <vhosakot@cisco.com>
  • Loading branch information
Vikram Hosakote authored and chrisplo committed Dec 21, 2017
1 parent 0308c0f commit 80a1998
Show file tree
Hide file tree
Showing 22 changed files with 1,336 additions and 660 deletions.
12 changes: 6 additions & 6 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion install/k8s/contiv/contiv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data:
# The CNI network configuration to install on each node.
contiv_cni_config: |-
{
"cniVersion": "0.1.0",
"cniVersion": "0.6.0",
"name": "contiv-net",
"type": "contivk8s"
}
Expand Down
2 changes: 1 addition & 1 deletion install/k8s/contiv/contiv_aci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data:
# The CNI network configuration to install on each node.
contiv_cni_config: |-
{
"cniVersion": "0.1.0",
"cniVersion": "0.6.0",
"name": "contiv-net",
"type": "contivk8s"
}
Expand Down
2 changes: 1 addition & 1 deletion install/k8s/contiv/contiv_devtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data:
# The CNI network configuration to install on each node.
contiv_cni_config: |-
{
"cniVersion": "0.1.0",
"cniVersion": "0.6.0",
"name": "contiv-net",
"type": "contivk8s"
}
Expand Down
26 changes: 14 additions & 12 deletions mgmtfn/k8splugin/contivk8s/k8s_cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"github.com/contiv/netplugin/version"

logger "github.com/Sirupsen/logrus"
ip "github.com/appc/cni/pkg/ip"
cni "github.com/appc/cni/pkg/plugin"
ip "github.com/containernetworking/cni/pkg/types"
cni "github.com/containernetworking/cni/pkg/types/current"
)

// CNIResponse response format expected from CNI plugins(version 0.1.0)
// CNIResponse response format expected from CNI plugins(version 0.6.0)
type CNIResponse struct {
CNIVersion string `json:"cniVersion"`
cni.Result
Expand All @@ -41,7 +41,7 @@ type CNIResponse struct {
//CNIError : return format from CNI plugin
type CNIError struct {
CNIVersion string `json:"cniVersion"`
cni.Error
ip.Error
}

var log *logger.Entry
Expand Down Expand Up @@ -75,7 +75,7 @@ func addPodToContiv(nc *clients.NWClient, pInfo *cniapi.CNIPodAttr) {
log.Errorf("EP create failed for pod: %s/%s",
pInfo.K8sNameSpace, pInfo.Name)
cerr := CNIError{}
cerr.CNIVersion = "0.1.0"
cerr.CNIVersion = "0.6.0"

if result != nil {
cerr.Code = result.Result
Expand Down Expand Up @@ -107,12 +107,13 @@ func addPodToContiv(nc *clients.NWClient, pInfo *cniapi.CNIPodAttr) {
}

out := CNIResponse{
CNIVersion: "0.1.0",
CNIVersion: "0.6.0",
}

out.IP4 = &cni.IPConfig{
IP: net.IPNet{IP: ip4Net.IP, Mask: ip4Net.Mask},
}
out.IPs = append(out.IPs, &cni.IPConfig{
Version: "4",
Address: net.IPNet{IP: ip4Net.IP, Mask: ip4Net.Mask},
})

if result.IPv6Address != "" {
ip6Net, err := ip.ParseCIDR(result.IPv6Address)
Expand All @@ -121,9 +122,10 @@ func addPodToContiv(nc *clients.NWClient, pInfo *cniapi.CNIPodAttr) {
return
}

out.IP6 = &cni.IPConfig{
IP: net.IPNet{IP: ip6Net.IP, Mask: ip6Net.Mask},
}
out.IPs = append(out.IPs, &cni.IPConfig{
Version: "6",
Address: net.IPNet{IP: ip6Net.IP, Mask: ip6Net.Mask},
})
}

data, err := json.MarshalIndent(out, "", " ")
Expand Down
86 changes: 0 additions & 86 deletions vendor/github.com/appc/cni/pkg/ip/cidr.go

This file was deleted.

66 changes: 0 additions & 66 deletions vendor/github.com/appc/cni/pkg/ip/ipmasq.go

This file was deleted.

Loading

0 comments on commit 80a1998

Please sign in to comment.