Skip to content

Commit

Permalink
cleanup + fix go linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik committed Sep 9, 2024
1 parent 0aa5689 commit eb079f8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 38 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require (
github.com/networkservicemesh/sdk v0.5.1-0.20240820090035-6fad31a9f0aa
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
github.com/vishvananda/netlink v1.2.1-beta.2.0.20220630165224-c591ada0fb2b
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74
github.com/vishvananda/netlink v1.3.0
github.com/vishvananda/netns v0.0.4
go.uber.org/goleak v1.3.0
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.60.1
Expand Down
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20220630165224-c591ada0fb2b h1:CyMWBGvc1ZOvUBxW51DVTSIIAeJWWJJs+Ko3ouM/AVI=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20220630165224-c591ada0fb2b/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk=
github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc=
go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.43.0 h1:tFUz2BE6ucxU9PuPCwzbfDeQjMznIySJ4/73a3FSPUs=
Expand Down Expand Up @@ -101,10 +100,10 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// Copyright (c) 2021-2023 Nordix Foundation.

Check failure on line 3 in pkg/kernel/networkservice/connectioncontextkernel/client.go

View workflow job for this annotation

GitHub Actions / golangci-lint / golangci-lint

Actual: Copyright (c) 2021-2023 Nordix Foundation.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2021-2022 Nordix Foundation.
//
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -103,10 +103,7 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
}

// Add new IP addresses
if err := addNewIPAddrs(ctx, netlinkHandle, l, toAdd); err != nil {
return err
}
return nil
return addNewIPAddrs(ctx, netlinkHandle, l, toAdd)
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,18 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
toCheck := make([]*net.IPNet, len(ipNets))
copy(toCheck, ipNets)

log.FromContext(ctx).Infof("mechanism.GetNetNSURL: %v", mechanism.GetNetNSURL())
netlinkHandle, err := link.GetNetlinkHandle(mechanism.GetNetNSURL())
if err != nil {
return err
}
defer netlinkHandle.Close()

log.FromContext(ctx).Infof("mechanism.GetInterfaceName: %v", mechanism.GetInterfaceName())
ifName := mechanism.GetInterfaceName()
l, err := netlinkHandle.LinkByName(ifName)
if err != nil {
return errors.Wrapf(err, "failed to find link %s", ifName)
}

log.FromContext(ctx).Infof("ifaceName: %v", ifName)

return checkIPNets(ctx, netlinkHandle, l, toCheck)
}
return nil
Expand All @@ -70,33 +66,26 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)
func checkIPNets(ctx context.Context, netlinkHandle *netlink.Handle, l netlink.Link, ipNets []*net.IPNet) error {
now := time.Now()

log.FromContext(ctx).Infof("current")
current := make(map[string]struct{})
for _, ipNet := range ipNets {
current[ipNet.String()] = struct{}{}
}

for {
time.Sleep(time.Millisecond * 500)
log.FromContext(ctx).Infof("current len: %v", len(current))
if len(current) == 0 {
return nil
}
select {
case <-ctx.Done():
return errors.Wrapf(ctx.Err(), "timeout waiting for update to add ip addresses %s to %s (type: %s)", ipNets, l.Attrs().Name, l.Type())
default:
log.FromContext(ctx).Infof("addrlist")
addrs, err := netlinkHandle.AddrList(l, netlink.FAMILY_ALL)
if err != nil {
return errors.Wrapf(err, "failed to get ip addresses for %s", l.Attrs().Name)
}
log.FromContext(ctx).Infof("got addrs: %v", addrs)
for _, addr := range addrs {
log.FromContext(ctx).Infof("checking addr: %v", addr)
log.FromContext(ctx).Infof("current: %v", current)
addrString := addr.IPNet.String()
log.FromContext(ctx).Infof("addrString: %v", addrString)
if _, ok := current[addrString]; ok {
delete(current, addrString)
log.FromContext(ctx).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright (c) 2020-2022 Cisco and/or its affiliates.
//
// Copyright (c) 2021-2022 Nordix Foundation.
// Copyright (c) 2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// Copyright (c) 2020-2022 Cisco and/or its affiliates.
//
// Copyright (c) 2021-2022 Nordix Foundation.
//
// Copyright (c) 2021-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -32,7 +28,6 @@ import (
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/postpone"
)

Expand Down Expand Up @@ -72,8 +67,6 @@ func (i *ipaddressCheckServer) Request(ctx context.Context, request *networkserv
return nil, err
}

log.FromContext(ctx).Infof("BACK")

if err := create(ctx, conn, metadata.IsClient(i)); err != nil {
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// Copyright (c) 2021-2023 Nordix Foundation.

Check failure on line 3 in pkg/kernel/networkservice/connectioncontextkernel/server.go

View workflow job for this annotation

GitHub Actions / golangci-lint / golangci-lint

Actual: Copyright (c) 2021-2023 Nordix Foundation.
//
Expand Down

0 comments on commit eb079f8

Please sign in to comment.