-
Notifications
You must be signed in to change notification settings - Fork 24
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
CNV-16653: Statistics of secondary network interfaces #1033
CNV-16653: Statistics of secondary network interfaces #1033
Conversation
@DanaOrr: This pull request references CNV-16653 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
3fc5233
to
2914a27
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.
Left some comments and questions, PTAL. Otherwise great work, Dana! :)
const totalTransferred = xbytes(networkInData + networkOutData || 0, { | ||
iec: true, | ||
fixed: 0, | ||
}); | ||
|
||
const networkInterfacesLength = interfacesNames?.length; |
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 you can use interfacesNames?.length
directly in the line 92. No need to create a new variable for this, as this is very short and not used in any other places within this file :)
const tickValues = Array.from({ length: Ymax + 1 }, (_, index) => { | ||
if (index === 0) return '1 Bps'; | ||
if (index === Math.round(Ymax)) return `${Math.round(Ymax + 1)} Bps`; | ||
return `${index.toString()} Bps`; |
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.
Hmm, do we really need to use toString
for the index
in here, if we are using a template literal (with backticks `) ?
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.
you right👍
const legendData = | ||
!isEmpty(chartData) && | ||
chartData?.map((newChartdata, index) => { | ||
return { childName: newChartdata?.[index]?.name, name: newChartdata?.[index]?.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.
Here the values for childName
and name
seem to be identical. is this intentional?
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 childName is used to synchronize the data series associated with the given chart name so it is better to have the same name I think...
[vmi], | ||
const { t } = useKubevirtTranslation(); | ||
const interfacesNames = useMemo(() => { | ||
const interfaces = vmi?.spec?.domain?.devices?.interfaces.map((nic) => nic?.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.
Maybe better ...vmi?.spec?.domain?.devices?.interfaces?.map((nic) => ...
to make sure some interfaces are present :)
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.
const interfaces = vmi?.spec?.domain?.devices?.interfaces.map((nic) => nic?.name); | |
const interfaces = vmi?.spec?.domain?.devices?.interfaces?.map((nic) => nic?.name); |
@@ -1,12 +1,17 @@ | |||
import React from 'react'; | |||
/* eslint-disable react-hooks/rules-of-hooks */ |
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.
Do we really have to use this here? Feels like we are going to disrespect some rules... IMO we should avoid doing this as much as possible.
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.
👍
to={`${getResourceUrl({ | ||
model: VirtualMachineModel, | ||
resource: vmi, | ||
})}/metrics?network=All networks`} |
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.
This looks kinda weird, I mean the space in the link, between All
and networks
. Are you sure this is working as expected?
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, it works as expected, but I deleted "all networks" and it will move to the same place I wanted,
so it's better to delete, thank you :)
a19b372
to
b77f4b3
Compare
}); | ||
const isReady = !isEmpty(chartData); | ||
|
||
const findChartMaxYAxis = (chartData1: { x: Date; y: number; name: string }[][]) => { |
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 be exported to util file?
return maxY; | ||
}; | ||
const Ymax = findChartMaxYAxis(chartData); | ||
const tickValues = Array.from({ length: Ymax + 1 }, (_, index) => { |
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 be exported to util 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.
@DanaOrr maybe it worth to move it to src/utils/components/Charts/utils/utils.ts ?
}); | ||
|
||
const isReady = !isEmpty(chartData); | ||
const newTickFormat = (tick: any, index: number, ticks: any[]) => { |
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 be exported to util file?
please consider changing the name to something more informative
/> | ||
{isReady && | ||
chartData?.map((newChartdata) => ( | ||
// eslint-disable-next-line react/jsx-key |
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?
return [ | ||
{ | ||
...response?.data?.result?.[0], | ||
metric: { ...response?.data?.result?.[0]?.metric, interface: 'all-networks' }, |
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.
consider transforming all-network string to a const
@@ -28,40 +34,80 @@ const useNetworkData: UseNetworkData = (vmi, nic) => { | |||
[vmi, duration, nic], | |||
); | |||
|
|||
const isAllNetwork = nic === 'All networks'; |
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.
consider using a const for all networks
resource: vmi, | ||
})}/metrics?network=${networkInterface.name}`} | ||
> | ||
{networkInterface.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.
please add ?.
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.
all over the file where needed
3df6d74
to
8121b3a
Compare
8121b3a
to
c4481ce
Compare
/retest |
c4481ce
to
2e60c6b
Compare
/retest |
/lgtm |
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.
Some more little changes and we are good to go! ;)
return singleNic ? [singleNic] : response?.data?.result; | ||
}; | ||
|
||
export const allNetworks = 'All networks'; |
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.
Please, use THIS_FORMAT for constants like that, and place constants into constants.ts file, under utils dir (if there isn't such a file, feel free to create it). It is better to have constants in a separate file :)
Additionally, don't be afraid to use the constant where needed. For example, I can see in NetworkCharts.tsx in this PR 'All networks' string instead of a constant.
|
||
const interfacesNames = useMemo(() => { | ||
const interfaces = vmi?.spec?.domain?.devices?.interfaces?.map((nic) => nic?.name); | ||
interfaces?.unshift('All networks'); |
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.
You could use the constant in here, for 'All networks' ;)
const query = useQuery(); | ||
const [isDropdownOpen, setIsDropdownOpen] = React.useState<boolean>(false); | ||
const [selectedNetwork, setSelectedNetwork] = React.useState<string>( | ||
query?.get('network') || 'All networks', |
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.
You could use the constant in here, for 'All networks', too ;)
PrometheusResponse, | ||
PrometheusResult, | ||
PrometheusValue, | ||
} from '@openshift-console/dynamic-plugin-sdk'; | ||
|
||
export const SINGLE_VM_DURATION = 'SINGLE_VM_DURATION'; | ||
export const TICKS_COUNT = 100; |
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'd move those constants into a separate constants.ts file ;) WDYT?
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's a good idea but it requires me to change the import to many more files and it creates a load on this PR..
so maybe in another PR? :)
2e60c6b
to
9629f7c
Compare
/approve |
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.
Some more little things, otherwise great work! :)
return maxY; | ||
}; | ||
const Ymax = findChartMaxYAxis(chartData); | ||
const tickValues = Array.from({ length: Ymax + 1 }, (_, index) => { |
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.
@DanaOrr maybe it worth to move it to src/utils/components/Charts/utils/utils.ts ?
.network-poppver { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
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.
.network-poppver {
display: flex;
justify-content: space-between;
}
plus maybe it is nicer also to use "popover" instead of "poppver" to have this class more self-explanatory :)
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 for making this nicer, Dana! :) 👍🏽
5c99632
to
cb5e5f6
Compare
/retest |
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've added another little comment for even better code ;) ...
position="bottom" | ||
> | ||
<div> | ||
<Button variant="link" isInline> |
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's better to use variant={ButtonVariant.link}
:)
(Sorry, I didn't see that earlier)
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.
Thank you Hilda ! :)
.network-poppver { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
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 for making this nicer, Dana! :) 👍🏽
Signed-off-by: Dana Orr <dorr@redhat.com>
cb5e5f6
to
bb33bb4
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DanaOrr, hstastna, metalice, upalatucci 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 |
Signed-off-by: Dana Orr dorr@redhat.com
📝 Description
Adding the option to see in a popover on the overview page the network interfaces that the machine has.
And I added on the metrics page the possibility to see the network in, out and bandwidth graphs for each NIC and for all of them together.
🎥 Demo
Before:
On the overview page:
On the metrics page:
After: