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

Update Go #316

Merged
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
115 changes: 21 additions & 94 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,12 @@ on:
pull_request:
jobs:
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: yaml-lint
uses: ibiqlik/action-yamllint@v1
with:
config_file: .yamllint.yml
strict: true
uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main
with:
config_file: "./.yamllint.yml"

shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: shellcheck
uses: fkautz/shell-linter@v1.0.1
uses: networkservicemesh/.github/.github/workflows/shellcheck.yaml@main

build:
name: build
Expand All @@ -39,106 +27,45 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.18.2
go-version: 1.20.5
- name: Build
run: go build -race ./...

golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.18.2
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.1
uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main

excludeFmtErrorf:
name: exclude fmt.Errorf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exclude fmt.Errorf
run: |
if grep -r --include=*.go --exclude=*.pb.go fmt.Errorf . ; then
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
exit 1
fi
uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main

restrictNSMDeps:
name: Restrict dependencies on github.com/networkservicemesh/*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restrict dependencies on github.com/networkservicemesh/*
env:
ALLOWED_REPOSITORIES: "sdk, api, sdk-vpp, sdk-sriov"
run: |
for i in $(grep github.com/networkservicemesh/ go.mod | grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[^ ]*\).*;\1;g');do
if ! [ "$(echo ${ALLOWED_REPOSITORIES} | grep ${i#github.com/networkservicemesh/})" ]; then
echo Dependency on "${i}" is forbidden
exit 1
fi;
done
uses: networkservicemesh/.github/.github/workflows/restrict-nsm-deps.yaml@main
with:
allowed_repositories: "sdk, api, sdk-vpp, sdk-sriov, govpp"

checkgomod:
name: Check go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18.2
- run: go mod tidy
- name: Check for changes
run: |
git diff --name-only --exit-code || ( echo "Run go mod tidy" && false )
uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main

gogenerate:
name: Check generated files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18.2
- run: go generate ./...
- name: Check for changes
run: |
git diff --name-only --exit-code || ( echo "Rerun go generate ./... locally and resubmit" && false )
uses: networkservicemesh/.github/.github/workflows/cmd-gogenerate.yaml@main

excludereplace:
name: Exclude Replace in go.mod
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Exclude replace in go.mod
run: |
grep ^replace go.mod || exit 0
exit 1
uses: networkservicemesh/.github/.github/workflows/exclude-replace.yaml@main

docker-build-and-test:
if: github.repository != 'networkservicemesh/cmd-template'
uses: networkservicemesh/.github/.github/workflows/docker-build-and-test.yaml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

docker:
docker-publish:
name: Docker Build & Test
runs-on: ubuntu-latest
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18.2
- name: Build container
run: docker build .
- name: Run tests
run: docker run --privileged --rm $(docker build -q . --target test)
go-version: 1.20.5
- name: Find merged PR
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: jwalton/gh-find-current-pr@v1
Expand Down
22 changes: 10 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
run:
# concurrency: 6
go: "1.19"
go: "1.20"
timeout: 2m
issues-exit-code: 1
tests: true
Expand Down Expand Up @@ -42,13 +42,11 @@ linters-settings:
min-len: 2
min-occurrences: 2
depguard:
list-type: blacklist
include-go-root: false
packages:
- errors
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- errors: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
rules:
main:
deny:
- pkg: errors
desc: Please use github.com/pkg/errors instead of errors in go imports
misspell:
locale: US
unparam:
Expand Down Expand Up @@ -110,7 +108,6 @@ linters-settings:
- regexpPattern
- singleCaseSwitch
- sloppyLen
# - sloppyReassign
- stringXbytes
- switchTrue
- typeAssertChain
Expand All @@ -129,7 +126,6 @@ linters-settings:
linters:
disable-all: true
enable:
# - rowserrcheck
- goheader
- bodyclose
- deadcode
Expand All @@ -149,7 +145,6 @@ linters:
- gosimple
- govet
- ineffassign
# - lll
- misspell
- nakedret
- revive
Expand All @@ -159,7 +154,6 @@ linters:
- typecheck
- unconvert
- unparam
# - unused
- varcheck
- whitespace
issues:
Expand All @@ -171,3 +165,7 @@ issues:
linters:
- revive
text: 'package-comments: should have a package comment'
- path: 'pkg/networkservice/ifconfig/server.go'
linters:
- revive
text: 'Function "closeLinkSubscribe"'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG VPP_VERSION=v23.02-rc0-189-g0359d19f2
FROM ghcr.io/edwarnicke/govpp/vpp:${VPP_VERSION} as go
COPY --from=golang:1.18.2-buster /usr/local/go/ /go
COPY --from=golang:1.20.5-buster /usr/local/go/ /go
ENV PATH ${PATH}:/go/bin
ENV GO111MODULE=on
ENV CGO_ENABLED=0
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module github.com/networkservicemesh/cmd-nse-vlan-vpp

go 1.18
go 1.20

require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/edwarnicke/govpp v0.0.0-20230130211138-14ef5d20b1d0
github.com/edwarnicke/grpcfd v1.1.2
github.com/edwarnicke/vpphelper v0.2.0
github.com/golang/protobuf v1.5.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.7.2-0.20230123083145-4a6c3ec589e1
github.com/networkservicemesh/govpp v0.0.0-20230626092821-fc47696d971b
github.com/networkservicemesh/sdk v0.5.1-0.20230620142740-a8c394e69c4e
github.com/networkservicemesh/sdk-sriov v0.0.0-20230629162853-517dec7cabb0
github.com/networkservicemesh/sdk-vpp v0.0.0-20230626101316-8199d4b43295
github.com/networkservicemesh/sdk-vpp v0.0.0-20230629190822-0b5241ae37a2
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
github.com/spiffe/go-spiffe/v2 v2.0.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL
github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs=
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29 h1:4/2wgileNvQB4HfJbq7u4FFLKIfc38a6P0S/51ZGgX8=
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29/go.mod h1:3m+ZfVq+z0pTLW798jmqnifMsalrVLIKmfXaMFvqSuc=
github.com/edwarnicke/govpp v0.0.0-20230130211138-14ef5d20b1d0 h1:3qXBk0lN7PhPrS/2TVJE30TZA/Ecd6LwkFW4rBxxb2w=
github.com/edwarnicke/govpp v0.0.0-20230130211138-14ef5d20b1d0/go.mod h1:kHDnxA+SSNFeMEHz7xvhub1zvx4mOTRlWWRCay2n5NM=
github.com/edwarnicke/grpcfd v1.1.2 h1:2b8kCABQ1+JjSKGDoHadqSW7whCeTXMqtyo6jmB5B8k=
github.com/edwarnicke/grpcfd v1.1.2/go.mod h1:rHihB9YvNMixz8rS+ZbwosI2kj65VLkeyYAI2M+/cGA=
github.com/edwarnicke/log v1.0.0 h1:T6uRNCmR99GTt/CpRr2Gz8eGW8fm0HMThDNGdNxPaGk=
Expand Down Expand Up @@ -219,12 +217,14 @@ github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
github.com/networkservicemesh/api v1.7.2-0.20230123083145-4a6c3ec589e1 h1:RxNKksXsXsnDsEo+Cfn43pdPfML024ad//QcdKfgXK4=
github.com/networkservicemesh/api v1.7.2-0.20230123083145-4a6c3ec589e1/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/govpp v0.0.0-20230626092821-fc47696d971b h1:5no/Hfw/UaLGDWN8deavInPomlzkWwxbGXoXNdeY0sc=
github.com/networkservicemesh/govpp v0.0.0-20230626092821-fc47696d971b/go.mod h1:akUChTiTQ93H2iVixGfUS3x0UMKuu1pzmcECwdwj6Rk=
github.com/networkservicemesh/sdk v0.5.1-0.20230620142740-a8c394e69c4e h1:Gd9eqXL8E7Pb+wHjdy96/b7goBH52g5uVLQy8kgdxmI=
github.com/networkservicemesh/sdk v0.5.1-0.20230620142740-a8c394e69c4e/go.mod h1:hmu0t7IxKa1v7Mj7Y3dQrcpRD0YtEyFE5vJorXRQT2A=
github.com/networkservicemesh/sdk-sriov v0.0.0-20230629162853-517dec7cabb0 h1:cJO3sll/o7+Btszr2HwD58aA0wM+KtxpePA6y8FifN0=
github.com/networkservicemesh/sdk-sriov v0.0.0-20230629162853-517dec7cabb0/go.mod h1:05zMTOIle9N096LdS9G1Pet8aubYQc5jBlm+kixcT78=
github.com/networkservicemesh/sdk-vpp v0.0.0-20230626101316-8199d4b43295 h1:QSDPB+9RgcfXk4vb4Y8gqhXeH6eXfrbyiUqFMaSGlsg=
github.com/networkservicemesh/sdk-vpp v0.0.0-20230626101316-8199d4b43295/go.mod h1:5P4pS7qAR0r4KiIX/zusAI7iMyAZqGiKYUJ2in+wA24=
github.com/networkservicemesh/sdk-vpp v0.0.0-20230629190822-0b5241ae37a2 h1:fz9tfaDo0Rjl4r0tgkyZPtYhReGSIo5Aa1j2HhY3QRs=
github.com/networkservicemesh/sdk-vpp v0.0.0-20230629190822-0b5241ae37a2/go.mod h1:/A0p5N2WKM/eOu0vjhxoxVHDRtIl5t4rhnfaWu9afh4=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.1.0 h1:e3YP4dN/HYPpGh29X1ZkcxcEICsOls9huyVCRBaxjq8=
github.com/onsi/gomega v1.1.0/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) 2021-2022 Nordix Foundation.
// Copyright (c) 2021-2023 Nordix Foundation.
//
// Copyright (c) 2023 Cisco Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -27,7 +29,6 @@ import (
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -335,7 +336,7 @@ func main() {
// ********************************************************************************

server := registerGRPCServer(tlsServerConfig, &responderEndpoint)
tmpDir, err := ioutil.TempDir("", config.Name)
tmpDir, err := os.MkdirTemp("", config.Name)
if err != nil {
logrus.Fatalf("error creating tmpDir %+v", err)
}
Expand Down
22 changes: 12 additions & 10 deletions pkg/networkservice/ifconfig/server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2021-2022 Nordix Foundation.
//
// Copyright (c) 2023 Cisco Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,17 +27,18 @@ import (
"net"
"sync"

"github.com/edwarnicke/govpp/binapi/af_packet"
"github.com/edwarnicke/govpp/binapi/fib_types"
interfaces "github.com/edwarnicke/govpp/binapi/interface"
"github.com/edwarnicke/govpp/binapi/interface_types"
"github.com/edwarnicke/govpp/binapi/ip"
"github.com/edwarnicke/govpp/binapi/rdma"
"github.com/edwarnicke/vpphelper"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"

"github.com/networkservicemesh/govpp/binapi/af_packet"
"github.com/networkservicemesh/govpp/binapi/fib_types"
interfaces "github.com/networkservicemesh/govpp/binapi/interface"
"github.com/networkservicemesh/govpp/binapi/interface_types"
"github.com/networkservicemesh/govpp/binapi/ip"
"github.com/networkservicemesh/govpp/binapi/rdma"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk-vpp/pkg/tools/types"
Expand Down Expand Up @@ -425,11 +428,10 @@ func (i *ifConfigServer) makeIfOpUp(ctx context.Context, swIfIndex interface_typ
return nil
}

// nolint: revive
func (i *ifConfigServer) closeLinkSubscribe(done chan struct{}, linkUpdateCh chan netlink.LinkUpdate) {
close(done)
// `linkUpdateCh` should be fully read after the `done` close to prevent goroutine leak in `netlink.LinkSubscribe`
go func() {
for range linkUpdateCh {
}
}()
for range linkUpdateCh {
}
}