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

streamline #2213 #2218

Merged
merged 1 commit into from
Oct 4, 2024
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
3 changes: 1 addition & 2 deletions cmd/vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ var vxlanCreateCmd = &cobra.Command{
return fmt.Errorf("not a VxlanStitched link")
}

// deploy the vxlan with existing link. The first endpoint is the host endpoint
err = vxl.DeployWithExistingVeth(ctx, vxl.GetEndpoints()[0])
err = vxl.DeployWithExistingVeth(ctx)
if err != nil {
return err
}
Expand Down
27 changes: 7 additions & 20 deletions links/link_vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,10 @@ func (lr *LinkVxlanRaw) resolveStitchedVxlan(params *ResolveParams) (Link, error
return nil, err
}

var vethLink *LinkVEth
var stitchEp Endpoint

// if the endpoint is host, we don't need to create the veth link
// the stitch endpoint is just a host endpoint with the passed interface name
if lr.Endpoint.Node == "host" {
// a fake endpoint used only to print the host interface name in the outputs
// it is not deployed as it meant to exist
epHost := NewEndpointHost(NewEndpointGeneric(vxlanLink.localEndpoint.GetNode(), params.VxlanIfaceNameOverwrite, nil))
vethLink, stitchEp, err = nil, epHost, nil
} else {
// otherwise we need to create the veth link
vethLink, stitchEp, err = lr.resolveStitchedVEthComponent(params)
if err != nil {
return nil, err
}

// prepare the veth struct
vethLink, stitchEp, err := lr.resolveStitchedVEthComponent(params)
if err != nil {
return nil, err
}

// return the stitched vxlan link
Expand Down Expand Up @@ -241,7 +228,7 @@ func (l *LinkVxlan) deployVxlanInterface() error {
// retrieve the parent interface netlink handle
parentIface, err := netlink.LinkByName(l.remoteEndpoint.parentIface)
if err != nil {
return err
return fmt.Errorf("error looking up vxlan parent interface %s: %w", l.remoteEndpoint.parentIface, err)
}

// create the Vxlan struct
Expand Down Expand Up @@ -269,14 +256,14 @@ func (l *LinkVxlan) deployVxlanInterface() error {
// add the link
err = netlink.LinkAdd(&vxlanconf)
if err != nil {
return err
return fmt.Errorf("error adding vxlan link %s: %w", l.localEndpoint.String(), err)
}

// fetch the mtu from the actual state for templated config generation
if l.MTU == 0 {
interf, err := netlink.LinkByName(l.localEndpoint.GetRandIfaceName())
if err != nil {
return err
return fmt.Errorf("error looking up local vxlan endpoint of %s : %w", l.localEndpoint.String(), err)
}
l.MTU = interf.Attrs().MTU
}
Expand Down
4 changes: 2 additions & 2 deletions links/link_vxlan_stitched.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func NewVxlanStitched(vxlan *LinkVxlan, veth *LinkVEth, vethStitchEp Endpoint) *
// DeployWithExistingVeth provisions the stitched vxlan link whilst the
// veth interface does already exist, hence it is not created as part of this
// deployment.
func (l *VxlanStitched) DeployWithExistingVeth(ctx context.Context, ep Endpoint) error {
return l.internalDeploy(ctx, ep, true)
func (l *VxlanStitched) DeployWithExistingVeth(ctx context.Context) error {
return l.internalDeploy(ctx, nil, true)
}

// Deploy provisions the stitched vxlan link with all its underlying sub-links.
Expand Down
Loading