diff --git a/clab/clab.go b/clab/clab.go index 6f72b271c..47b346a53 100644 --- a/clab/clab.go +++ b/clab/clab.go @@ -587,7 +587,7 @@ func (c *CLab) ListNodesContainers(ctx context.Context) ([]runtime.GenericContai return containers, nil } -// ListNodesContainersIgnoreNotFound lists all containers based on the nodes stored in clab instance, ignoring errors for non found containers +// ListNodesContainersIgnoreNotFound lists all containers based on the nodes stored in clab instance, ignoring errors for non found containers. func (c *CLab) ListNodesContainersIgnoreNotFound(ctx context.Context) ([]runtime.GenericContainer, error) { var containers []runtime.GenericContainer diff --git a/clab/config.go b/clab/config.go index 491325d00..2f8d7bffc 100644 --- a/clab/config.go +++ b/clab/config.go @@ -355,7 +355,8 @@ func (c *CLab) verifyRootNetNSLinks() error { // if so, add their ep names to the list of rootEpNames for _, e := range n.GetEndpoints() { if val, exists := rootEpNames[e.GetIfaceName()]; exists { - return fmt.Errorf("root network namespace endpoint %q defined by multiple nodes [%s, %s]", e.GetIfaceName(), val, e.GetNode().GetShortName()) + return fmt.Errorf("root network namespace endpoint %q defined by multiple nodes [%s, %s]", + e.GetIfaceName(), val, e.GetNode().GetShortName()) } rootEpNames[e.GetIfaceName()] = e.GetNode().GetShortName() } @@ -367,7 +368,8 @@ func (c *CLab) verifyRootNetNSLinks() error { // if so, add their ep names to the list of rootEpNames for _, e := range n.GetEndpoints() { if val, exists := rootEpNames[e.GetIfaceName()]; exists { - return fmt.Errorf("root network namespace endpoint %q defined by multiple nodes [%s, %s]", e.GetIfaceName(), val, e.GetNode().GetShortName()) + return fmt.Errorf("root network namespace endpoint %q defined by multiple nodes [%s, %s]", + e.GetIfaceName(), val, e.GetNode().GetShortName()) } rootEpNames[e.GetIfaceName()] = e.GetNode().GetShortName() } @@ -529,7 +531,7 @@ func (c *CLab) resolveBindPaths(binds []string, nodedir string) error { } // setClabIntfsEnvVar sets CLAB_INTFS env var for each node -// which holds the number of interfaces a node expects to have (without mgmt interfaces) +// which holds the number of interfaces a node expects to have (without mgmt interfaces). func (c *CLab) SetClabIntfsEnvVar() { for _, n := range c.Nodes { // Injecting the env var with expected number of links diff --git a/clab/config_test.go b/clab/config_test.go index 43dcef238..bbf7a9b05 100644 --- a/clab/config_test.go +++ b/clab/config_test.go @@ -483,7 +483,6 @@ func TestLabelsInit(t *testing.T) { } func TestVerifyRootNetNSLinks(t *testing.T) { - tests := map[string]struct { topo string wantError bool diff --git a/cmd/generate.go b/cmd/generate.go index 0a3421ef8..2cee80dda 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -219,8 +219,10 @@ func generateTopologyConfig(name, network, ipv4range, ipv6range string, // create a raw veth link l := &links.LinkVEthRaw{ Endpoints: []*links.EndpointRaw{ - links.NewEndpointRaw(node1, fmt.Sprintf(interfaceFormat[nodes[i].kind], k+1+interfaceOffset), ""), - links.NewEndpointRaw(node2, fmt.Sprintf(interfaceFormat[nodes[i+1].kind], j+1), ""), + links.NewEndpointRaw(node1, fmt.Sprintf( + interfaceFormat[nodes[i].kind], k+1+interfaceOffset), ""), + links.NewEndpointRaw(node2, fmt.Sprintf( + interfaceFormat[nodes[i+1].kind], j+1), ""), }, } diff --git a/docs/rn/0.44.md b/docs/rn/0.44.md index 7983e35fd..5d1216818 100644 --- a/docs/rn/0.44.md +++ b/docs/rn/0.44.md @@ -50,3 +50,4 @@ Read more about this feature in the [Certificates Management](../manual/cert.md# * fixing CLAB_INTFS env var #1547 * fixing node filtering functionality #1549 * fixing ovs bridges and openflow 1.3 #1539 +* remove ovs ports when the lab is destroyed #1545 diff --git a/internal/tc/tc.go b/internal/tc/tc.go index 05f39d57e..0f776ad58 100644 --- a/internal/tc/tc.go +++ b/internal/tc/tc.go @@ -81,7 +81,6 @@ func SetImpairments(tcnl *tc.Tc, nodeName string, link *net.Interface, delay, ji // setDelay sets delay and jitter to the qdisc. func setDelay(qdisc *tc.Object, delay, jitter time.Duration) error { - delayTcTime, err := core.Duration2TcTime(delay) if err != nil { return err diff --git a/links/endpoint_macvlan.go b/links/endpoint_macvlan.go index 6b6f75298..d3853f87c 100644 --- a/links/endpoint_macvlan.go +++ b/links/endpoint_macvlan.go @@ -4,7 +4,7 @@ type EndpointMacVlan struct { EndpointGeneric } -// Verify verifies the veth based deployment pre-conditions +// Verify verifies the veth based deployment pre-conditions. func (e *EndpointMacVlan) Verify(_ *VerifyLinkParams) error { return CheckEndpointExists(e) } diff --git a/links/endpoint_veth.go b/links/endpoint_veth.go index 0531a48d7..b715966a8 100644 --- a/links/endpoint_veth.go +++ b/links/endpoint_veth.go @@ -4,7 +4,7 @@ type EndpointVeth struct { EndpointGeneric } -// Verify verifies the veth based deployment pre-conditions +// Verify verifies the veth based deployment pre-conditions. func (e *EndpointVeth) Verify(_ *VerifyLinkParams) error { return CheckEndpointUniqueness(e) } diff --git a/links/link.go b/links/link.go index e9cdc5319..5fa57e617 100644 --- a/links/link.go +++ b/links/link.go @@ -296,7 +296,7 @@ const ( ) // SetNameMACAndUpInterface is a helper function that will bind interface name and Mac -// and return a function that can run in the netns.Do() call for execution in a network namespace +// and return a function that can run in the netns.Do() call for execution in a network namespace. func SetNameMACAndUpInterface(l netlink.Link, endpt Endpoint) func(ns.NetNS) error { return func(_ ns.NetNS) error { // rename the given link diff --git a/links/link_host.go b/links/link_host.go index 2078a8a09..e6e2512ab 100644 --- a/links/link_host.go +++ b/links/link_host.go @@ -109,7 +109,8 @@ func GetHostLinkNode() Node { nspath := currns.Path() _hostLinkNodeInstance = &hostLinkNode{ - GenericLinkNode: GenericLinkNode{shortname: "host", + GenericLinkNode: GenericLinkNode{ + shortname: "host", endpoints: []Endpoint{}, nspath: nspath, }, diff --git a/links/link_macvlan.go b/links/link_macvlan.go index bae13e5f5..6b1498814 100644 --- a/links/link_macvlan.go +++ b/links/link_macvlan.go @@ -189,7 +189,8 @@ func (l *LinkMacVlan) Deploy(ctx context.Context) error { } // add the link to the Node Namespace - err = l.NodeEndpoint.GetNode().AddLinkToContainer(ctx, mvInterface, SetNameMACAndUpInterface(mvInterface, l.NodeEndpoint)) + err = l.NodeEndpoint.GetNode().AddLinkToContainer(ctx, mvInterface, + SetNameMACAndUpInterface(mvInterface, l.NodeEndpoint)) return err } diff --git a/links/link_veth.go b/links/link_veth.go index 571f7d49a..4b1ffa323 100644 --- a/links/link_veth.go +++ b/links/link_veth.go @@ -101,7 +101,6 @@ func (*LinkVEth) GetType() LinkType { } func (*LinkVEth) Verify() { - } func (l *LinkVEth) Deploy(ctx context.Context) error { @@ -158,7 +157,8 @@ func (l *LinkVEth) Deploy(ctx context.Context) error { for idx, link := range []netlink.Link{linkA, linkB} { // if the node is a regular namespace node // add link to node, rename, set mac and Up - err = l.Endpoints[idx].GetNode().AddLinkToContainer(ctx, link, SetNameMACAndUpInterface(link, l.Endpoints[idx])) + err = l.Endpoints[idx].GetNode().AddLinkToContainer(ctx, link, + SetNameMACAndUpInterface(link, l.Endpoints[idx])) if err != nil { return err } diff --git a/links/link_veth_test.go b/links/link_veth_test.go index 34db44265..7aaa3ee66 100644 --- a/links/link_veth_test.go +++ b/links/link_veth_test.go @@ -185,11 +185,13 @@ func TestLinkVEthRaw_Resolve(t *testing.T) { for i, e := range l.Endpoints { if e.(*EndpointVeth).IfaceName != tt.want.Endpoints[i].(*EndpointVeth).IfaceName { - t.Errorf("LinkVEthRaw.Resolve() EndpointVeth got %s, want %s", e.(*EndpointVeth).IfaceName, tt.want.Endpoints[i].(*EndpointVeth).IfaceName) + t.Errorf("LinkVEthRaw.Resolve() EndpointVeth got %s, want %s", + e.(*EndpointVeth).IfaceName, tt.want.Endpoints[i].(*EndpointVeth).IfaceName) } if e.(*EndpointVeth).Node != tt.want.Endpoints[i].(*EndpointVeth).Node { - t.Errorf("LinkVEthRaw.Resolve() EndpointVeth got %s, want %s", e.(*EndpointVeth).Node, tt.want.Endpoints[i].(*EndpointVeth).Node) + t.Errorf("LinkVEthRaw.Resolve() EndpointVeth got %s, want %s", + e.(*EndpointVeth).Node, tt.want.Endpoints[i].(*EndpointVeth).Node) } } }) @@ -216,7 +218,7 @@ func (f *fakeNode) AddLink(l Link) { f.Links = append(f.Links, l) } -// AddEndpoint adds the Endpoint to the node +// AddEndpoint adds the Endpoint to the node. func (f *fakeNode) AddEndpoint(e Endpoint) { f.Endpoints = append(f.Endpoints, e) } diff --git a/nodes/default_node.go b/nodes/default_node.go index 59dbd2d36..b38c9b401 100644 --- a/nodes/default_node.go +++ b/nodes/default_node.go @@ -429,7 +429,7 @@ func (d *DefaultNode) AddLinkToContainer(_ context.Context, link netlink.Link, f return netns.Do(f) } -// ExecFunction executes the given function in the nodes network namespace +// ExecFunction executes the given function in the nodes network namespace. func (d *DefaultNode) ExecFunction(f func(ns.NetNS) error) error { nspath := d.Cfg.NSPath diff --git a/nodes/host/host.go b/nodes/host/host.go index eba099115..131c8c87e 100644 --- a/nodes/host/host.go +++ b/nodes/host/host.go @@ -45,6 +45,7 @@ func (n *host) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error { n.Cfg.IsRootNamespaceBased = true return nil } + func (n *host) Deploy(_ context.Context, _ *nodes.DeployParams) error { n.SetState(state.Deployed) return nil diff --git a/nodes/srl/srl.go b/nodes/srl/srl.go index 76f821810..1f9a67cb5 100644 --- a/nodes/srl/srl.go +++ b/nodes/srl/srl.go @@ -522,7 +522,7 @@ func generateSRLTopologyFile(cfg *types.NodeConfig) error { return f.Close() } -// srlTemplateData top level data struct +// srlTemplateData top level data struct. type srlTemplateData struct { TLSKey string TLSCert string @@ -532,7 +532,7 @@ type srlTemplateData struct { SSHPubKeys string } -// tplIFace template interface struct +// tplIFace template interface struct. type tplIFace struct { Slot string Port string diff --git a/nodes/state/state.go b/nodes/state/state.go index e38da2d8b..650734bbe 100644 --- a/nodes/state/state.go +++ b/nodes/state/state.go @@ -4,6 +4,6 @@ type NodeState uint const ( Unknown NodeState = iota - // Deployed means the underlying container has been started and deploy function succeeded + // Deployed means the underlying container has been started and deploy function succeeded. Deployed )