Skip to content

Commit

Permalink
Rn 0.44.3 (#1550)
Browse files Browse the repository at this point in the history
* rn added

* added formatting
  • Loading branch information
hellt committed Aug 22, 2023
1 parent d96ed77 commit 8d103f1
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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()
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion clab/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ func TestLabelsInit(t *testing.T) {
}

func TestVerifyRootNetNSLinks(t *testing.T) {

tests := map[string]struct {
topo string
wantError bool
Expand Down
6 changes: 4 additions & 2 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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), ""),
},
}

Expand Down
1 change: 1 addition & 0 deletions docs/rn/0.44.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion internal/tc/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion links/endpoint_macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion links/endpoint_veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion links/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion links/link_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func GetHostLinkNode() Node {
nspath := currns.Path()

_hostLinkNodeInstance = &hostLinkNode{
GenericLinkNode: GenericLinkNode{shortname: "host",
GenericLinkNode: GenericLinkNode{
shortname: "host",
endpoints: []Endpoint{},
nspath: nspath,
},
Expand Down
3 changes: 2 additions & 1 deletion links/link_macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions links/link_veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (*LinkVEth) GetType() LinkType {
}

func (*LinkVEth) Verify() {

}

func (l *LinkVEth) Deploy(ctx context.Context) error {
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions links/link_veth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
})
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion nodes/default_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions nodes/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nodes/srl/srl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -532,7 +532,7 @@ type srlTemplateData struct {
SSHPubKeys string
}

// tplIFace template interface struct
// tplIFace template interface struct.
type tplIFace struct {
Slot string
Port string
Expand Down
2 changes: 1 addition & 1 deletion nodes/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 8d103f1

Please sign in to comment.