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

[JUJU-1559] Removes the requirement to disable v6 for lxd. #14424

Merged
merged 1 commit into from
Aug 4, 2022
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
39 changes: 1 addition & 38 deletions container/lxd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ func (s *Server) ensureDefaultNetworking(profile *api.Profile, eTag string) erro
if err != nil {
return errors.Trace(err)
}
} else {
if err := verifyNoIPv6(net); err != nil {
return errors.Trace(err)
}
}

s.localBridgeName = network.DefaultLXDBridge
Expand Down Expand Up @@ -190,7 +186,6 @@ func (s *Server) ensureDefaultNetworking(profile *api.Profile, eTag string) erro
// devices is suitable for LXD to work with Juju.
func (s *Server) verifyNICsWithAPI(nics map[string]device) error {
checked := make([]string, 0, len(nics))
var ipV6ErrMsg error
for name, nic := range nics {
checked = append(checked, name)

Expand All @@ -210,11 +205,6 @@ func (s *Server) verifyNICsWithAPI(nics map[string]device) error {
return errors.Annotatef(err, "retrieving network %q", netName)
}

if err := verifyNoIPv6(net); err != nil {
ipV6ErrMsg = err
continue
}

// Versions of the LXD profile prior to 3.22 have a "nictype" member
// under NIC entries in the "devices" list.
// Later versions were observed to have this member absent,
Expand All @@ -228,17 +218,11 @@ func (s *Server) verifyNICsWithAPI(nics map[string]device) error {
return nil
}

// A nic with valid type found, but the network configures IPv6.
if ipV6ErrMsg != nil {
return ipV6ErrMsg
}

// No nics with a nictype of nicTypeBridged, nicTypeMACVLAN was found.
return errors.Errorf(fmt.Sprintf(
"no network device found with nictype %q or %q"+
"\n\tthe following devices were checked: %s"+
"\nNote: juju does not support IPv6."+
"\nReconfigure lxd to use a network of type %q or %q, disabling IPv6.",
"\nReconfigure lxd to use a network of type %q or %q.",
nicTypeBridged, nicTypeMACVLAN, strings.Join(checked, ", "), nicTypeBridged, nicTypeMACVLAN))
}

Expand Down Expand Up @@ -305,27 +289,6 @@ func getProfileNICs(profile *api.Profile) map[string]device {
return nics
}

// verifyNoIPv6 checks that the input network has no IPv6 configuration.
// An error is returned when it does.
// TODO (manadart 2018-05-28) The intention is to support IPv6, so this
// restriction is temporary.
func verifyNoIPv6(net *api.Network) error {
if !net.Managed {
return nil
}
cfg, ok := net.Config["ipv6.address"]
if !ok {
return nil
}
if cfg == "none" {
return nil
}

return errors.Errorf("juju does not support IPv6. Disable IPv6 in LXD via:\n"+
"\tlxc network set %s ipv6.address none\n"+
"and run the command again", net.Name)
}

func isValidNICType(nic device) bool {
return nic["nictype"] == nicTypeBridged || nic["nictype"] == nicTypeMACVLAN
}
Expand Down
14 changes: 6 additions & 8 deletions container/lxd/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ func (s *networkSuite) TestVerifyNetworkDevicePresentBadNicType(c *gc.C) {
c.Assert(err, gc.ErrorMatches,
`profile "default": no network device found with nictype "bridged" or "macvlan"\n`+
`\tthe following devices were checked: eth0\n`+
`Note: juju does not support IPv6.\n`+
`Reconfigure lxd to use a network of type "bridged" or "macvlan", disabling IPv6.`)
`Reconfigure lxd to use a network of type "bridged" or "macvlan".`)
}

func (s *networkSuite) TestVerifyNetworkDeviceIPv6Present(c *gc.C) {
// Juju used to fail when IPv6 was enabled on the lxd network. This test now
// checks regression to make sure that we know longer fail.
func (s *networkSuite) TestVerifyNetworkDeviceIPv6PresentNoFail(c *gc.C) {
ctrl := gomock.NewController(c)
defer ctrl.Finish()
cSvr := s.NewMockServerWithExtensions(ctrl, "network")
Expand All @@ -230,7 +231,7 @@ func (s *networkSuite) TestVerifyNetworkDeviceIPv6Present(c *gc.C) {
Managed: true,
NetworkPut: lxdapi.NetworkPut{
Config: map[string]string{
"ipv6.address": "something-not-nothing",
"ipv6.address": "2001:DB8::1",
},
},
}
Expand All @@ -240,10 +241,7 @@ func (s *networkSuite) TestVerifyNetworkDeviceIPv6Present(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

err = jujuSvr.VerifyNetworkDevice(defaultLegacyProfileWithNIC(), "")
c.Assert(err, gc.ErrorMatches,
`profile "default": juju does not support IPv6. Disable IPv6 in LXD via:\n`+
`\tlxc network set lxdbr0 ipv6.address none\n`+
`and run the command again`)
c.Assert(err, jc.ErrorIsNil)
}

func (s *networkSuite) TestVerifyNetworkDeviceNotPresentCreated(c *gc.C) {
Expand Down