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

microcloud: Subnet sharing warning should check interfaces not IPs #522

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

gabrielmougard
Copy link
Contributor

closes #516

@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch 5 times, most recently from 8e01972 to 3c0887c Compare December 2, 2024 18:36
Copy link
Contributor

@roosterfish roosterfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving the existing check from IPs to interfaces. Please have a look at my last comment, I think we should check the other two remaining ifaces as well.

service/lxd_config.go Outdated Show resolved Hide resolved
service/lxd_config.go Outdated Show resolved Hide resolved
service/lxd_config.go Outdated Show resolved Hide resolved
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
if subnet.Contains(underlayIP) {
fmt.Printf("Warning: OVN underlay IP (%s) is shared with the Ceph cluster network (%s)\n", underlayIP.String(), subnet.String())
if sys.OVNGeneveIface == sys.MicroCephInternalNetworkIface {
fmt.Printf("Warning: OVN underlay (IP: %s) is shared on the same network interface %q with the Ceph cluster network (IP: %s)\n", underlayIP.String(), sys.OVNGeneveIface, subnet.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subnet above seems to be redundant now as you can just use sys.MicroCephInternalNetworkSubnet instead of subnet.String().

cmd/microcloud/main_init.go Outdated Show resolved Hide resolved
@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch 2 times, most recently from 9cec54a to eb8c057 Compare December 3, 2024 11:49
@roosterfish
Copy link
Contributor

Not related to the PR but since we have switched the runners to the free ones this error seems to become peristent. It's probably caused by this so I am wondering if the test bed reset is just failing here.

Copy link
Contributor

@masnax masnax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one suggestion to reduce complexity & prevent having lots of extra fields & types.

Comment on lines 917 to 929
// ipWithIface is a helper struct to store an IP address and
// its corresponding network interface.
type ipWithIface struct {
ip net.IP
ifaceName string
}

Copy link
Contributor

@masnax masnax Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of maintaining both this and several fields for each interface on InitSystem, why not just introduce a new type Network with 3 fields: Interface, IP, Subnet which are populated by the corresponding values from net.Interface.

Then each of OVNGeneveAddr MicroCephInternalSubnet, and MicroCephPublicSubnet can be changed to OVNGeneveNetwork, CephInternalNetwork, CephPublicNetwork respectively.

And finally validateSystems you can check per-cluster member if any local interface names clash, and then across all cluster members if the subnets clash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch from eb8c057 to a9f6ca7 Compare December 5, 2024 10:48
@gabrielmougard
Copy link
Contributor Author

@masnax @roosterfish I reworked the approach based on #522 (comment)

Copy link
Contributor

@roosterfish roosterfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, just saw I never submitted the review. Please have a look when you find time.

cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
c.systems[sh.Name] = bootstrapSystem

// This is to avoid the situation where the internal network for Ceph has been skipped, but the public network has been set.
// Ceph will automatically set the internal network to the public Ceph network if the internal network is not set, which is not what we want.
// Instead, we still want to keep the internal Ceph network to use the MicroCloud internal network as a default.
if internalCephSubnet == microCloudInternalNetworkAddrCIDR {
bootstrapSystem.MicroCephInternalNetworkSubnet = microCloudInternalNetworkAddrCIDR
microcloudNetworkInterface, err := lxd.FindInterfaceForSubnet(microCloudInternalNetworkAddrCIDR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if InitSystem should grow another MicroCloudInternalNetwork *Network where we can store this information after the user has selected the internal address for MicroCloud?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I had the same thinking I remember... For now, it seems that we don't need it for the current state of things but it might be needed in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was if we now check for collisions in between the OVN and Ceph networks, wouldn't it be worth also including the MicroCloud internal network into those checks?

cmd/microcloud/preseed.go Outdated Show resolved Hide resolved
// If there are multiple subnet types on the same subnet, we have a collision.
if len(subnetTypeToPeers) > 1 {
var sb strings.Builder
sb.WriteString("WARNING: Subnet collision detected:\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this PR will probably land after the "look & feel" I'll add a link here for reference on the note box #505 (comment)

@roosterfish
Copy link
Contributor

Also requires a rebase now due to the recent CLI changes.

@gabrielmougard
Copy link
Contributor Author

Thanks for the feedback!

@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch from a9f6ca7 to e93d076 Compare January 7, 2025 09:39
@gabrielmougard
Copy link
Contributor Author

@roosterfish updated

cmd/microcloud/main_init.go Show resolved Hide resolved
cmd/microcloud/main_init.go Outdated Show resolved Hide resolved
c.systems[sh.Name] = bootstrapSystem

// This is to avoid the situation where the internal network for Ceph has been skipped, but the public network has been set.
// Ceph will automatically set the internal network to the public Ceph network if the internal network is not set, which is not what we want.
// Instead, we still want to keep the internal Ceph network to use the MicroCloud internal network as a default.
if internalCephSubnet == microCloudInternalNetworkAddrCIDR {
bootstrapSystem.MicroCephInternalNetworkSubnet = microCloudInternalNetworkAddrCIDR
microcloudNetworkInterface, err := lxd.FindInterfaceForSubnet(microCloudInternalNetworkAddrCIDR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was if we now check for collisions in between the OVN and Ceph networks, wouldn't it be worth also including the MicroCloud internal network into those checks?

@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch 3 times, most recently from 9f57467 to 1a8b231 Compare January 9, 2025 15:10
@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch from 1a8b231 to 94488b6 Compare January 27, 2025 15:55
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/main_init.go Outdated Show resolved Hide resolved
@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch from 94488b6 to a3b5fb2 Compare January 29, 2025 15:07
Copy link
Contributor

@roosterfish roosterfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test cases!
The validation still seems to be outputting something else in case of single node MicroCloud. Please have a look at my comments.

cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/ask.go Outdated Show resolved Hide resolved
cmd/microcloud/main_init.go Outdated Show resolved Hide resolved
cmd/microcloud/main_init.go Outdated Show resolved Hide resolved
name: "single system interface collision",
systems: map[string]InitSystem{
"system1": {
MicroCephInternalNetwork: newNetwork("eth0", "10.0.1.0/24"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for this test!
Because when you try to deploy a single node MicroCloud and select the same network for all MicroCloud internal, Ceph internal/public and OVN geneve you only get this:

- MicroCloud internal network, OVN underlay sharing network interface "enp5s0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it proves detectCollisions does the right thing it's only that in the actual code it's presumably called with the wrong inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't think I understand what you mean.. What do you think I should change in this test?

This type will be used to store a variety of subnet informations and which local network interface
they will use. This will be used both for configuring MicroCloud but for running validation as well (e.g, interface collisions within a member, subnet collisions between members of a cluster)

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
This will be needed to get a network interface info from a CIDR subnet notation (e.g, mostly in the case of configuring MicroCloud internal and public networks)

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
…MicroCephPublicNetwork` and `MicroCephInternalNetwork` instead of `OVNGeneveAddr`, `MicroCephPublicNetworkSubnet` and `MicroCephInternalNetworkSubnet`

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
This function detect the local network interface collisions and the global subet collisions

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
@gabrielmougard gabrielmougard force-pushed the fix/subnet-sharing-warning branch from a3b5fb2 to c6ab1d7 Compare January 31, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subnet sharing warning should check interfaces not IPs
3 participants