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

Sync MTU and check MTU valid values #149

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

Conversation

w13915984028
Copy link
Member

@w13915984028 w13915984028 commented Jan 30, 2025

Problem:

Change of MTU on VlanConfig uplink is not updated to NAD.

Solution:

  1. Check the input MTU on VlanConfig
  2. Update the MTU to labels of ClusterNetwork when change happens
  3. Sync NAD's MTU with the lables of ClusterNetwork when change happens

This solution does not change the APIs and UI, instead it propagates MTU from VlanConfig to ClusterNetwork when change happens; and makes sure all the VlanConfigs under the same ClusterNetwork will have the same MTU.

Related Issue:
harvester/harvester#4355
harvester/harvester#4752

HEP: harvester/harvester#6385
Doc PR: harvester/docs#640

Test plan:

  1. MTU propogation
    1.1 Create a clusternetwork
    1.2 create a vlanconfig, the MTU from vlanconfig is synced to clusternetwork
    1.3 create another vlanconfig, if MTU is different, it is denied by webhook
    1.4 create nad, the MTU is inherited from clusternetwork/vlanconfig

  2. Change the MTU of a clusternetwork
    2.1 Stop all VMs attached to a specific clusternetwork
    2.2 Delete all vlanconfigs until there is a last one; otherwise change MTU from any will be denied per 1.3
    2.3 Change the last vlanconfig's MTU, then it is synced to clusternetwork; if there are any NADs attached to this clusternetwork, their MTU is changed automatically
    2.4 Add more vlanconfig, each needs to fill the same MTU per 1.3

This way, if user plans to change the MTU of an existing clusternetwork, follow steps 2.

If VM is attached to clusternetwork, it is not allowed to change/delete vlannetwork:
image
image

MTU value validation:
image

Note: network-controller-harvester lacks many test code, need additional effort to add them, will add later.

@w13915984028
Copy link
Member Author

@mergify backport v0.5.x v0.6.x

Copy link

mergify bot commented Jan 30, 2025

backport v0.5.x v0.6.x

🟠 Waiting for conditions to match

  • merged [📌 backport requirement]

Signed-off-by: Jian Wang <jian.wang@suse.com>
@@ -264,8 +270,8 @@ func (v *Validator) validateMTU(current *networkv1.VlanConfig) error {
if vc.Name == current.Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make sense to change it to just fetch the related cluster object crd and check the MTU from there?

Copy link
Member Author

Choose a reason for hiding this comment

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

A few considerations:

  1. The current code has assumption that the clusternetwork may be created behind the vlanconfig, for logacy or other reasons

    func (h Handler) ensureClusterNetwork(name string) error {

  2. The MTU is synced to clusternetwork as a label, in extreme cases, if user hack it with an invalid value, the check may miss.

@w13915984028 w13915984028 force-pushed the enh4355 branch 2 times, most recently from 5b393ff to dd757ea Compare January 31, 2025 08:26
Signed-off-by: Jian Wang <jian.wang@suse.com>
Signed-off-by: Jian Wang <jian.wang@suse.com>
@w13915984028 w13915984028 force-pushed the enh4355 branch 2 times, most recently from fd2db83 to 560c8b7 Compare January 31, 2025 08:55
Signed-off-by: Jian Wang <jian.wang@suse.com>
@rrajendran17
Copy link
Contributor

Few points
1.Similar to vms,if MTU is updated after storage network configuration, it will be propagated to storage network nad, but LH pods interfaces will not have updated the new MTU.
A webhook check in needed to prevent updating the MTU when storage network is configured. The user has to disable storage network config before MTU change and enable storage network configuration after a new MTU change.
2.In case of storage network, the vlan network under the vlan config also has to be deleted if vlan config has to be deleted for any mismatch in MTU cases.Just a point to be noted while adding test cases.
3.Good to include a manual traffic test after MTU change in the test plan(either between VMs or LH pods with jumbo frames)

Signed-off-by: Jian Wang <jian.wang@suse.com>
@w13915984028
Copy link
Member Author

@rrajendran17 Thanks, the storagenetwork related cases need some additional processing, I will add.

return nil
}

// Sync cluster network MTU value to all attached NADs
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not including this change during cluster network change inside pkg/controller/manager/clusternetwork/controller.go ?

const (
DefaultMTU = 1500
MaxMTU = 9000
MinMTU = 1280 // IPv4 does not define this; IPv6 defines 1280; Harvester adopts it for both
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, IPv4 defines 576 bytes as minimum MTU.

}
if mtu != oldMtu {
return fmt.Errorf(updateErr, newCn.Name, fmt.Errorf("label %v can't be updated", utils.KeyUplinkMTU))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Above two checks could be combined.

},
{
name: "user can't add the MTU label",
returnErr: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

since it will return error, returnErr should be true and errKey has error value.

},
},
{
name: "ClusterNetwork is allowed to be deleted",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you enhance the description ?


})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible, can you also add unit tests for checking running vms and storage network nad configured when updating/deleting vlanconfigs ?

@rrajendran17
Copy link
Contributor

rrajendran17 commented Feb 3, 2025

I also noticed,currently we do not have min-max MTU check in UI, we need to create a GH issue to add those changes to UI as well.

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.

3 participants