-
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 <[email protected]>
@@ -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 <[email protected]>
Signed-off-by: Jian Wang <[email protected]>
fd2db83
to
560c8b7
Compare
Signed-off-by: Jian Wang <[email protected]>
Few points |
Signed-off-by: Jian Wang <[email protected]>
f06a019
to
13ff7ae
Compare
67653b5
to
668c495
Compare
51f8140
to
9d587ea
Compare
With a lot of enhancements on ClusterNetwork, VlanConfig, NAD and StorageNetwork, a detailed test plan is listed.
|
Enforce the validator webhook Add test code for all cases with a couple of fake clients Differentiate mgmt network as it has no VlanConfig Add processing of StorageNetwork Fix some minor bugs
Signed-off-by: Jian Wang <[email protected]>
@ibrokethecloud @ihcsim @mschiu77 @starbops @rrajendran17 This PR is ready for final review, thanks. This commit ef611ee excludes the vendor bump. With a lot of enhancements on ClusterNetwork, VlanConfig, NAD, StorageNetwork, a detailed test plan is listed #149 (comment). cc @bk201 |
@@ -83,16 +83,49 @@ func (h Handler) SetClusterNetworkUnready(_ string, vs *networkv1.VlanStatus) (* | |||
return vs, nil | |||
} | |||
|
|||
func (h Handler) ensureClusterNetwork(name string) error { | |||
if _, err := h.cnCache.Get(name); err != nil && !apierrors.IsNotFound(err) { | |||
func (h Handler) ensureClusterNetwork(vc *networkv1.VlanConfig) error { |
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.
we sync the MTU from the vlanconfig to the clusternetwork. due to additional logic in the validationg webhook we only allow the MTU set on the clusternetwork to be applied to subsequent vlansconfigs. does this mean the only way to change the MTU is remove all vlanconfigs / cluster network and recreate the objects again?
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.
Yes, this is described in PR description:
2. Change the MTU of a clusternetwork
2.1 Stop all VMs attached to a specific clusternetwork
2.2 Delete/Migrate 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 2.3
This will forcely ensure it, to avoid user changes some of them accidentally and spend a big effort to finally figure things out.
return nil | ||
} | ||
|
||
// for none-mgmt cluster network, this annotation can only be operated by controller |
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.
minor typo
// for none-mgmt cluster network, this annotation can only be operated by controller | |
// for non-mgmt cluster network, this annotation can only be operated by controller |
|
||
// Get the vm name list who uses a group of nads, | ||
// note: duplicated names are removed | ||
func (v *VMGetter) VMNamesWhoUseNads(nads []*nadv1.NetworkAttachmentDefinition) ([]string, error) { |
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.
I could not find this method used anywhere
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.
It is prepared for func (c *CnValidator) Delete(_ *admission.Request, oldObj runtime.Object) error {
at beginning, and not used per
// no need to check vmi, vm, both of them need to be stopped &/ removed related interfaces/networks when deleting nads
It is still kept to let vm.go is in same fashion with vmi.go
if cnt == 1 { | ||
return generateVmiNameList(vmis), nil | ||
} | ||
|
||
// use mapset to remove duplicated names | ||
return mapset.NewSet[string](generateVmiNameList(vmis)...).ToSlice(), nil |
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.
is there a specific reason to check cnt == 1
? we could just return the mapset here
if cnt == 1 { | |
return generateVmiNameList(vmis), nil | |
} | |
// use mapset to remove duplicated names | |
return mapset.NewSet[string](generateVmiNameList(vmis)...).ToSlice(), nil | |
return mapset.NewSet[string](generateVmiNameList(vmis)...).ToSlice(), nil |
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.
When there is only 1 element, surely it has no duplicated names. The mapset.NewSet...
is a heavy object & operation. The code tries to call it when necessary.
On the other hand, I am still thinking if we should only return the first e.g. 10 names, some cluster runs 300+ VMs, expand all the names may overflow the warning window.
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/Migrate 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
Change the MTU of a mgmt network
3.1 The mgmt network has no vlanconfig instances. You may edit the MTU annotation manually, be sure this really matchs the NICs' MTU, there is no strong check at the moment.
3.2 If there are VMIs or storagenetwork on mgmt network, the change is denied.
More detailed tests about network related enhancements:
#149 (comment)