-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: master
Are you sure you want to change the base?
Conversation
3e4beb5
to
dd3a7dc
Compare
a76ad1e
to
db70af5
Compare
@mergify backport v0.5.x v0.6.x |
🟠 Waiting for conditions to match
|
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few considerations:
-
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 { -
The MTU is synced to clusternetwork as a label, in extreme cases, if user hack it with an invalid value, the check may miss.
5b393ff
to
dd757ea
Compare
Signed-off-by: Jian Wang <jian.wang@suse.com>
Signed-off-by: Jian Wang <jian.wang@suse.com>
fd2db83
to
560c8b7
Compare
Signed-off-by: Jian Wang <jian.wang@suse.com>
Few points |
Signed-off-by: Jian Wang <jian.wang@suse.com>
@rrajendran17 Thanks, the storagenetwork related cases need some additional processing, I will add. |
return nil | ||
} | ||
|
||
// Sync cluster network MTU value to all attached NADs |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) | ||
} |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 ?
|
||
}) | ||
} | ||
} |
There was a problem hiding this comment.
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 ?
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. |
Problem:
Change of MTU on VlanConfig uplink is not updated to NAD.
Solution:
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:
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
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:


MTU value validation:

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