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

Bump net-attach to v1.7 #452

Merged
merged 2 commits into from
Apr 19, 2024
Merged
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
72 changes: 39 additions & 33 deletions cmd/whereabouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,46 @@ import (
"github.com/k8snetworkplumbingwg/whereabouts/pkg/version"
)

func main() {
skel.PluginMain(func(args *skel.CmdArgs) error {
ipamConf, confVersion, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("ADD - IPAM configuration successfully read: %+v", *ipamConf)
ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
func cmdAddFunc(args *skel.CmdArgs) error {
ipamConf, confVersion, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("ADD - IPAM configuration successfully read: %+v", *ipamConf)
ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("failed to create Kubernetes IPAM manager: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdAdd(args, ipam, confVersion)
},
cmdCheck,
func(args *skel.CmdArgs) error {
ipamConf, _, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", *ipamConf)

ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("IPAM client initialization error: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdDel(args, ipam)
},
cniversion.All,
fmt.Sprintf("whereabouts %s", version.GetFullVersionWithRuntimeInfo()),
)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdAdd(args, ipam, confVersion)
}

func cmdDelFunc(args *skel.CmdArgs) error {
ipamConf, _, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", *ipamConf)

ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("IPAM client initialization error: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdDel(args, ipam)
}


func main() {
skel.PluginMainFuncs(skel.CNIFuncs{
Add: cmdAddFunc,
Check: cmdCheck,
Del: cmdDelFunc,
},
cniversion.All,
fmt.Sprintf("whereabouts %s", version.GetFullVersionWithRuntimeInfo()))
}

func safeCloseKubernetesBackendConnection(ipam *kubernetes.KubernetesIPAM) {
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.21

require (
github.com/blang/semver v3.5.1+incompatible
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/cni v1.2.0-rc1
github.com/containernetworking/plugins v1.4.0
github.com/imdario/mergo v0.3.16
github.com/json-iterator/go v1.1.12 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1-0.20210510153419-66a699ae3b05
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.32.0
github.com/pkg/errors v0.9.1
Expand All @@ -27,6 +27,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
)
Expand Down
176 changes: 6 additions & 170 deletions go.sum

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions vendor/github.com/containernetworking/cni/pkg/ns/ns_linux.go

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

21 changes: 21 additions & 0 deletions vendor/github.com/containernetworking/cni/pkg/ns/ns_windows.go

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

Loading
Loading