Skip to content

Commit b1794e7

Browse files
authored
Merge pull request k8snetworkplumbingwg#70 from e0ne/go1.19
Housekeeping: Bump golang to 1.19 and some cleanup
2 parents 848e3b4 + 2716501 commit b1794e7

File tree

31 files changed

+82
-313
lines changed

31 files changed

+82
-313
lines changed

.github/workflows/buildtest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
build:
1010
strategy:
1111
matrix:
12-
go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x]
13-
os: [ubuntu-20.04]
12+
go-version: [1.19.x]
13+
os: [ubuntu-22.04]
1414
runs-on: ${{ matrix.os }}
1515
env:
1616
GO111MODULE: on

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:alpine as builder
1+
FROM golang:1.19-alpine as builder
22

33
COPY . /usr/src/ib-sriov-cni
44

Dockerfile.ppc64le

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ppc64le/golang:alpine as builder
1+
FROM ppc64le/golang:1.19-alpine as builder
22

33
COPY . /usr/src/ib-sriov-cni
44

Dockerfile.rhel7

Lines changed: 0 additions & 17 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Package related
22
BINARY_NAME=ib-sriov
33
PACKAGE=ib-sriov-cni
4-
ORG_PATH=github.com/Mellanox
4+
ORG_PATH=github.com/k8snetworkplumbingwg
55
REPO_PATH=$(ORG_PATH)/$(PACKAGE)
66
GOPATH=$(CURDIR)/.gopath
77
GOBIN =$(CURDIR)/bin
@@ -24,7 +24,7 @@ LDFLAGS="-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE
2424
IMAGE_BUILDER?=@docker
2525
IMAGEDIR=$(BASE)/images
2626
DOCKERFILE?=$(CURDIR)/Dockerfile
27-
TAG?=mellanox/ib-sriov-cni
27+
TAG?=k8snetworkplumbingwg/ib-sriov-cni
2828
IMAGE_BUILD_OPTS?=
2929
# Accept proxy settings for docker
3030
# To pass proxy for Docker invoke it as 'make image HTTP_POXY=http://192.168.0.1:8080'
@@ -43,7 +43,7 @@ GOLANGCI_LINT = $(GOBIN)/golangci-lint
4343
# golangci-lint version should be updated periodically
4444
# we keep it fixed to avoid it from unexpectedly failing on the project
4545
# in case of a version bump
46-
GOLANGCI_LINT_VER = v1.23.8
46+
GOLANGCI_LINT_VER = v1.46.2
4747
TIMEOUT = 15
4848
Q = $(if $(filter 1,$V),,@)
4949

@@ -67,22 +67,19 @@ $(BUILDDIR)/$(BINARY_NAME): $(GOFILES) | $(BUILDDIR)
6767
@cd $(BASE)/cmd/$(PACKAGE) && CGO_ENABLED=0 $(GO) build -o $(BUILDDIR)/$(BINARY_NAME) -tags no_openssl -ldflags $(LDFLAGS) -v
6868

6969
# Tools
70-
$(GOLANGCI_LINT): | $(BASE) ; $(info building golangci-lint...)
71-
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $(GOLANGCI_LINT_VER)
70+
$(GOLANGCI_LINT): ; $(info installing golangci-lint...)
71+
$Q go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VER)
72+
7273

7374
GOVERALLS = $(GOBIN)/goveralls
7475
$(GOBIN)/goveralls: | $(BASE) ; $(info building goveralls...)
75-
$Q go get github.com/mattn/goveralls
76+
$Q go install github.com/mattn/goveralls
7677

7778
# Tests
7879

7980
.PHONY: lint
80-
lint: | $(BASE) $(GOLANGCI_LINT) ; $(info running golangci-lint...) @ ## Run golangci-lint
81-
$Q mkdir -p $(BASE)/test
82-
$Q cd $(BASE) && ret=0 && \
83-
test -z "$$($(GOLANGCI_LINT) run | tee $(BASE)/test/lint.out)" || ret=1 ; \
84-
cat $(BASE)/test/lint.out ; rm -rf $(BASE)/test ; \
85-
exit $$ret
81+
lint: | $(GOLANGCI_LINT) ; $(info running golangci-lint...) @ ## Run golangci-lint
82+
$Q $(GOLANGCI_LINT) run --timeout=5m
8683

8784
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
8885
.PHONY: $(TEST_TARGETS) test-xml check test tests

cmd/ib-sriov-cni/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func lockCNIExecution() (*flock.Flock, error) {
6565
// As the mapping of RDMA resources is done in Device plugin prior to CNI invocation, it must not change here.
6666
// We serialize the CNI's operation causing kernel to allocate the VF's RDMA resources under the same name.
6767
// In the future, Systems should use udev PCI based RDMA device names, ensuring consistent RDMA resources names.
68-
err := os.MkdirAll(config.CniFileLockDir, 0700)
68+
err := os.MkdirAll(config.CniFileLockDir, utils.OwnerReadWriteExecuteAttrs)
6969
if err != nil {
7070
return nil, fmt.Errorf("failed to create ib-sriov-cni lock file directory(%q): %v", config.CniFileLockDir, err)
7171
}
@@ -300,7 +300,8 @@ func cmdDel(args *skel.CmdArgs) error {
300300
if err != nil {
301301
// According to the CNI spec, a DEL action should complete without errors
302302
// even if there are some resources missing. For more details, see
303-
// https://github.com/containernetworking/cni/blob/main/SPEC.md#del-remove-container-from-network-or-un-apply-modifications
303+
//nolint
304+
// https://github.com/containernetworking/cni/blob/main/SPEC.md#del-remove-container-from-network-or-un-apply-modifications
304305
return nil
305306
}
306307

go.mod

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
module github.com/Mellanox/ib-sriov-cni
22

3-
go 1.13
3+
go 1.19
44

55
require (
66
github.com/Mellanox/rdma-cni v1.0.1
77
github.com/Mellanox/sriovnet v1.0.2
88
github.com/containernetworking/cni v0.8.1
99
github.com/containernetworking/plugins v0.8.5
10-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1110
github.com/gofrs/flock v0.7.1
1211
github.com/onsi/ginkgo v1.12.0
1312
github.com/onsi/gomega v1.9.0
14-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
15-
github.com/stretchr/objx v0.2.1-0.20190415111823-35313a95ee26 // indirect
1613
github.com/stretchr/testify v1.5.1
1714
github.com/vishvananda/netlink v1.1.0
15+
)
16+
17+
require (
18+
github.com/Mellanox/rdmamap v1.0.0 // indirect
19+
github.com/coreos/go-iptables v0.4.5 // indirect
20+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
21+
github.com/google/uuid v1.1.1 // indirect
22+
github.com/hpcloud/tail v1.0.0 // indirect
23+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
24+
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 // indirect
25+
github.com/spf13/afero v1.4.1 // indirect
26+
github.com/stretchr/objx v0.2.1-0.20190415111823-35313a95ee26 // indirect
27+
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
28+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 // indirect
29+
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775 // indirect
1830
golang.org/x/text v0.3.7 // indirect
31+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 // indirect
32+
gopkg.in/fsnotify.v1 v1.4.7 // indirect
33+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
1934
gopkg.in/yaml.v2 v2.2.8 // indirect
2035
)

pkg/utils/testing.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
package utils
88

99
import (
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
)
1413

14+
const (
15+
OwnerReadWriteExecuteOthersReadExecuteAttrs = 0755
16+
OwnerReadWriteOthersReadAttrs = 0644
17+
)
18+
1519
func check(e error) {
1620
if e != nil {
1721
panic(e)
@@ -75,20 +79,20 @@ func CreateTmpSysFs() error {
7579
originalRoot, _ := os.Open("/")
7680
ts.originalRoot = originalRoot
7781

78-
tmpdir, ioErr := ioutil.TempDir("/tmp", "ib-sriov-cni-plugin-testfiles-")
82+
tmpdir, ioErr := os.MkdirTemp("/tmp", "ib-sriov-cni-plugin-testfiles-")
7983
if ioErr != nil {
8084
return ioErr
8185
}
8286

8387
ts.dirRoot = tmpdir
8488

8589
for _, dir := range ts.dirList {
86-
if err := os.MkdirAll(filepath.Join(ts.dirRoot, dir), 0755); err != nil {
90+
if err := os.MkdirAll(filepath.Join(ts.dirRoot, dir), OwnerReadWriteExecuteOthersReadExecuteAttrs); err != nil {
8791
return err
8892
}
8993
}
9094
for filename, body := range ts.fileList {
91-
if err := ioutil.WriteFile(filepath.Join(ts.dirRoot, filename), body, 0644); err != nil {
95+
if err := os.WriteFile(filepath.Join(ts.dirRoot, filename), body, OwnerReadWriteOthersReadAttrs); err != nil {
9296
return err
9397
}
9498
}
@@ -117,7 +121,7 @@ func CreateTmpSysFs() error {
117121
}
118122

119123
func createSymlinks(link, target string) error {
120-
if err := os.MkdirAll(target, 0755); err != nil {
124+
if err := os.MkdirAll(target, OwnerReadWriteExecuteOthersReadExecuteAttrs); err != nil {
121125
return err
122126
}
123127
if err := os.Symlink(target, link); err != nil {

pkg/utils/utils.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package utils
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
76
"net"
87
"os"
98
"path/filepath"
@@ -20,7 +19,11 @@ var (
2019
SysBusPci = "/sys/bus/pci/devices"
2120
)
2221

23-
const IPoIBAddrLengthBytes = 20
22+
const (
23+
IPoIBAddrLengthBytes = 20
24+
OwnerReadWriteExecuteAttrs = 0700
25+
OwnerReadWriteAttrs = 0600
26+
)
2427

2528
// GetSriovNumVfs takes in a PF name(ifName) as string and returns number of VF configured as int
2629
func GetSriovNumVfs(ifName string) (int, error) {
@@ -31,7 +34,7 @@ func GetSriovNumVfs(ifName string) (int, error) {
3134
return vfTotal, fmt.Errorf("failed to open the sriov_numfs of device %q: %v", ifName, err)
3235
}
3336

34-
data, err := ioutil.ReadFile(sriovFile)
37+
data, err := os.ReadFile(sriovFile)
3538
if err != nil {
3639
return vfTotal, fmt.Errorf("failed to read the sriov_numfs of device %q: %v", ifName, err)
3740
}
@@ -82,7 +85,7 @@ func GetPfName(vf string) (string, error) {
8285
return "", err
8386
}
8487

85-
files, err := ioutil.ReadDir(pfSymLink)
88+
files, err := os.ReadDir(pfSymLink)
8689
if err != nil {
8790
return "", err
8891
}
@@ -123,7 +126,7 @@ func GetVFLinkNames(pciAddr string) (string, error) {
123126
return "", err
124127
}
125128

126-
fInfos, err := ioutil.ReadDir(vfDir)
129+
fInfos, err := os.ReadDir(vfDir)
127130
if err != nil {
128131
return "", fmt.Errorf("failed to read net dir of the device %s: %v", pciAddr, err)
129132
}
@@ -147,7 +150,7 @@ func GetVFLinkNamesFromVFID(pfName string, vfID int) ([]string, error) {
147150
return nil, err
148151
}
149152

150-
fInfos, err := ioutil.ReadDir(vfDir)
153+
fInfos, err := os.ReadDir(vfDir)
151154
if err != nil {
152155
return nil, fmt.Errorf("failed to read the virtfn%d dir of the device %q: %v", vfID, pfName, err)
153156
}
@@ -181,13 +184,13 @@ func SaveNetConf(cid, dataDir, podIfName string, conf interface{}) error {
181184
}
182185

183186
func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {
184-
if err := os.MkdirAll(dataDir, 0700); err != nil {
187+
if err := os.MkdirAll(dataDir, OwnerReadWriteExecuteAttrs); err != nil {
185188
return fmt.Errorf("failed to create the sriov data directory(%q): %v", dataDir, err)
186189
}
187190

188191
path := filepath.Join(dataDir, containerID)
189192

190-
err := ioutil.WriteFile(path, netconf, 0600)
193+
err := os.WriteFile(path, netconf, OwnerReadWriteAttrs)
191194
if err != nil {
192195
return fmt.Errorf("failed to write container data in the path(%q): %v", path, err)
193196
}
@@ -197,7 +200,7 @@ func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {
197200

198201
// ReadScratchNetConf takes in container ID, Pod interface name and data dir as string and returns a pointer to Conf
199202
func ReadScratchNetConf(cRefPath string) ([]byte, error) {
200-
data, err := ioutil.ReadFile(cRefPath)
203+
data, err := os.ReadFile(cRefPath)
201204
if err != nil {
202205
return nil, fmt.Errorf("failed to read container data in the path(%q): %v", cRefPath, err)
203206
}

scripts/deploy.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

vendor/github.com/Mellanox/rdmamap/go.mod

Lines changed: 0 additions & 8 deletions
This file was deleted.

vendor/github.com/Mellanox/rdmamap/go.sum

Lines changed: 0 additions & 6 deletions
This file was deleted.

vendor/github.com/Mellanox/sriovnet/go.mod

Lines changed: 0 additions & 10 deletions
This file was deleted.

vendor/github.com/Mellanox/sriovnet/go.sum

Lines changed: 0 additions & 35 deletions
This file was deleted.

vendor/github.com/google/uuid/go.mod

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)