-
Notifications
You must be signed in to change notification settings - Fork 8
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
status-monitor: Filter out interface with no name #46
Conversation
@@ -54,7 +54,9 @@ func (r *VirtualMachineInstanceReconciler) Reconcile(ctx context.Context, reques | |||
// Error reading the object - requeue the request. | |||
return ctrl.Result{}, err | |||
} | |||
err = r.ZoneManager.UpdateZone(request.NamespacedName, FilterMultusNonDefaultInterfaces(vmi.Status.Interfaces, vmi.Spec.Networks)) | |||
filteredInterfaces := FilterMultusNonDefaultInterfaces(vmi.Status.Interfaces, vmi.Spec.Networks) | |||
filteredInterfaces = FilterInterfacesWithNoName(vmi.Status.Interfaces) // The interface/network name is used to build the FQDN, therefore, interfaces reported without a name are filtered out |
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.
Aint you overriding the list that was created in the previous line ?
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! Good catch:) The linter cached it as well.
83bd2be
to
9fe933d
Compare
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.
Thanks
Please add example on PR desc about SRIOV that for example a SRIOV interface without mac wouldn't have a network name
Might even worth release notes ? not crucial as we don't collect it yet
Please consider adding that it was filtered, but you refactor it to be in the right place
so it will be easier to understand why the ZM is changed
Please consider prefixing PR desc with status-monitor:. ...
pkg/controllers/interface_filter.go
Outdated
@@ -30,3 +30,13 @@ func getDefaultNetwork(networks []v1.Network) *v1.Network { | |||
func isDefaultNetwork(net v1.Network) bool { | |||
return net.Pod != nil || (net.Multus != nil && net.Multus.Default) | |||
} | |||
|
|||
func FilterInterfacesWithNoName(ifaces []v1.VirtualMachineInstanceNetworkInterface) []v1.VirtualMachineInstanceNetworkInterface { |
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 think filter functions need to be named according what they do keep
FilterNamedInterfaces
And then the logic might be something like
if iface.Name == "" {
continue
}
if desirable - "return early"
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.
Changed the name.
@@ -54,7 +54,9 @@ func (r *VirtualMachineInstanceReconciler) Reconcile(ctx context.Context, reques | |||
// Error reading the object - requeue the request. | |||
return ctrl.Result{}, err | |||
} | |||
err = r.ZoneManager.UpdateZone(request.NamespacedName, FilterMultusNonDefaultInterfaces(vmi.Status.Interfaces, vmi.Spec.Networks)) | |||
filteredInterfaces := FilterMultusNonDefaultInterfaces(vmi.Status.Interfaces, vmi.Spec.Networks) | |||
filteredInterfaces = FilterInterfacesWithNoName(filteredInterfaces) // The interface/network name is used to build the FQDN, therefore, interfaces reported without a name are filtered out |
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.
Lets remove please the comment, it is pretty trivial here
also comment should be line above the code usually imo
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 find the comment useful and not trivial.
Moved it to be above the code.
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.
Imo it is very trivial and the comment is redundant
code should be (and it is) self explanatory
Moreover since name is part of the FQDN of course its needed
pkg/controllers/interface_filter.go
Outdated
@@ -30,3 +30,13 @@ func getDefaultNetwork(networks []v1.Network) *v1.Network { | |||
func isDefaultNetwork(net v1.Network) bool { | |||
return net.Pod != nil || (net.Multus != nil && net.Multus.Default) | |||
} | |||
|
|||
func FilterInterfacesWithNoName(ifaces []v1.VirtualMachineInstanceNetworkInterface) []v1.VirtualMachineInstanceNetworkInterface { |
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.
btw since it is used in the same package, maybe it can be lower cased first character ?
If so same for function on line 7
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 find it much more readable and safe to have public API to the interface_filter
file.
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.
but it is used internally only, we don't expose stuff that is not need to be exposed
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.
The public method are the methods that the interace_file exposes. I want it to be clear.
It is even considered a good practice to have the unit tests in a separate package, so it will be clear what is the API of the tested file.
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.
But we don't have it on a separate package atm.
also API is for stuff that is used outside of the module, not inside.
else i would suggest for example that once we move unit tests to their own package
then we can expose it
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.
moved the filter tests to a separate package.
Added the prefix and explanation why the code was removed form the zone manager. I don't think the sriov example it relevant here. The reported interface may not have a name from multiple reasons. e.g the interface was added manually in the guest, the interface MAC address was change manually in the guest and also the SRIOV case. I think that for kubesecondarydns it is irrelevant why there is no name, the only relevant part is that if there is no name, there is no FQDN. |
I understand, what about expressing all those examples in the PR description ? |
The interface/network name is used to build the FQDN. Therefore, interfaces reported without a name are filtered out. Signed-off-by: Alona Paz <alkaplan@redhat.com>
9fe933d
to
658c274
Compare
To allow writing the tests as though they were a real user of the package. Signed-off-by: Alona Paz <alkaplan@redhat.com>
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.
Thanks
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlonaKaplan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
The interface/network name is used to build the FQDN. Therefore, interfaces reported without a name are filtered out.
The reported interface may not have a name from multiple reasons. e.g the interface was added manually in the guest, the interface MAC address was change manually, the interface is SRIOV.
Special notes for your reviewer:
This PR is removing the empty name filtering from the zonemanger and moves it to a dedicated filter.
Release note: