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

Bug 1856351: Fix build details page charts #6879

Merged
merged 1 commit into from Oct 28, 2020

Conversation

TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented Oct 8, 2020

Update build details page charts to only show utilization data from when the build ran.

  • Create new global time related constants
  • Update build details page area charts to only show data from build start to completion
  • Minimum queried timepan to one minute
  • Show seconds on build charts if timespan is less than 5 minutes
  • Force x domain on build charts to match the queried timespan so that chart will not show less than
    one minute on the x-axis.
  • Add new xMutator callback arg to graph util mapLimitsRequests function to allow for post-processing of
    utilization chart x values
  • Add new xMutator and yMutator callback args to graph util getRangeVectorStats function to allow
    for post-processing of prometheus response data x and y values
  • Remove logic from getRangeVectorStats function that removed second and millisecond data from all x
    values
  • Update PrometheusMultilineUtilizationItem to use new xMutator argument to trim seconds and
    milliseconds off of multiline area chart data points.
  • Create new global constants for prometheus query default samples and timespan
  • Update Area and AreaChart components to use new global prometheus constants and accept domain prop
  • Update twentyFourHourTime util function to accept showSeconds arg and get rid of
    twentyFourHourTimeWithSeconds function.
  • Update usage of twentyFourHourTime/twentyFourHourTimeWithSeconds function where needed

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Oct 8, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1856351: Fix build details page charts

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.

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1856351: Fix build details page charts

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.

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/analyze 7d4e944 link /test analyze

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@TheRealJon
Copy link
Member Author

This is likely failing the the analyze test because I am importing moment into the datetime helper file. I did this to simplify the implementation, but it's probably overkill. I'll update to remove this import.

@TheRealJon TheRealJon changed the title Bug 1856351: Fix build details page charts [WIP] Bug 1856351: Fix build details page charts Oct 9, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 9, 2020
@openshift-ci-robot openshift-ci-robot added component/dashboard Related to dashboard component/shared Related to console-shared labels Oct 14, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1856351, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

[WIP] Bug 1856351: Fix build details page charts

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.

@TheRealJon TheRealJon changed the title [WIP] Bug 1856351: Fix build details page charts Bug 1856351: Fix build details page charts Oct 14, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 14, 2020
@TheRealJon
Copy link
Member Author

I think this is ready for review.

/assign @rohitkrai03

cc @spadgett

@spadgett
Copy link
Member

/cc @kyoto

@TheRealJon
Copy link
Member Author

/hold

need to fix some unit tests

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 14, 2020
@TheRealJon
Copy link
Member Author

cc @rawagner

@TheRealJon
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 14, 2020
Copy link
Member

@kyoto kyoto left a comment

Choose a reason for hiding this comment

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

Thanks @TheRealJon!

A few comments on the smaller details, but generally LGTM 👍

Comment on lines 6 to 7
export const ONE_MONTH = 30 * ONE_DAY;
export const ONE_YEAR = 365.25 * ONE_DAY;
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest removing ONE_MONTH and ONE_YEAR since they're not currently used and obviously both 30 days and 325.25 days are not technically accurate. In practice, I think the definition of month and year will depend on the context they're used in.


const xTickFormat = span < 5 * 60 * 1000 ? twentyFourHourTimeWithSeconds : twentyFourHourTime;

const xTickFormat = (d) => twentyFourHourTime(d, span < 5 * 60 * 1000);
Copy link
Member

Choose a reason for hiding this comment

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

I guess we use ONE_MINUTE here 😄

return `${hours}:${minutes}:${seconds}`;
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => {
const hours = zeroPad(date?.getHours() ?? 0);
const minutes = `:${zeroPad(date?.getMinutes() ?? 0)}`;
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think including the : in the return statement as before is a little easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

To keep it consistent with seconds, I think we should keep the colon as part of minutes.

const seconds = zeroPad(date.getSeconds());
return `${hours}:${minutes}:${seconds}`;
export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => {
const hours = zeroPad(date?.getHours() ?? 0);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to handle the case where date is not set? Since it's not an optional parameter and we use type checking, can we assume that it is indeed a Date and lose the ?. checks?

export const twentyFourHourTime = (date: Date, showSeconds?: boolean): string => {
const hours = zeroPad(date?.getHours() ?? 0);
const minutes = `:${zeroPad(date?.getMinutes() ?? 0)}`;
const seconds = `:${zeroPad(date?.getSeconds() ?? 0)}`;
Copy link
Member

Choose a reason for hiding this comment

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

Probably not significant in practice, but I notice the computation for seconds is done just to be thrown away unless showSeconds is true.

How about this?

const seconds = showSeconds ? `:${zeroPad(date?.getSeconds() ?? 0)}` : '';

...rest
}) => {
const [utilization, , utilizationLoading] = usePrometheusPoll({
const prometheusPollProps = {
Copy link
Member

Choose a reason for hiding this comment

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

💯

if (!podName) {
return null;
}

const endTime = build?.status?.completionTimestamp
Copy link
Member

Choose a reason for hiding this comment

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

We're assuming that build is set elsewhere in this function, so I guess we can use build. instead of build.? everywhere.

Comment on lines 147 to 148
formatDate: (d) => twentyFourHourTime(d, timespan < 5 * ONE_MINUTE),
domain: { x: [endTime - timespan, endTime] }, // force domain to match queried timespan
Copy link
Member

Choose a reason for hiding this comment

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

I think we're OK in this case, but in general I've had trouble with triggering unnecessary graph re-renders by having function / object / array props that are recreated in the render function like this.

If the graph does not seem to be re-rendering too frequently, I think this is fine, but in general I'm trying to avoid these situations. For example, passing startTime and endTime integer props instead of a domain object might avoid some re-renders, depending on how BuildGraphs is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll pull out domain into a separate declaration and memoize it so it will only get re-initialized if timespan or endTime change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll also memoize areaProps so that it won't cause unnecessary re-renders.

Comment on lines 138 to 141
domain={{
...(allZero && { y: [0, 1] }),
...domain,
}}
Copy link
Member

Choose a reason for hiding this comment

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

The could be triggering unnecessary re-renders. If so, domain could be memoized.

>
{xAxis && <ChartAxis tickCount={tickCount} tickFormat={formatDate} />}
{xAxis && <ChartAxis tickCount={tickCount} tickFormat={(tick) => formatDate(tick)} />}
Copy link
Member

Choose a reason for hiding this comment

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

Using (tick) => formatDate(tick) instead of just formatDate might cause ChartAxis to re-render unnecessarily too. An easy solution to avoid that possibility would be to define const xAxisTickFormat = (tick) => formatDate(tick); outside the component.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't define this outside the component since formatDate is a prop. I'll use the React callback hook to make sure the function definition only changes when necessary.

@TheRealJon TheRealJon force-pushed the 1856351-bz branch 2 times, most recently from 498788a to c9c0d12 Compare October 22, 2020 20:50
@TheRealJon
Copy link
Member Author

/retest

@TheRealJon TheRealJon requested a review from kyoto October 23, 2020 14:08
@TheRealJon
Copy link
Member Author

@kyoto Addressed your feedback

- Create new global time related constants
- Update build details page area charts to only from build start to completion
- Minimum queried timepan to one minute
- Show seconds on build charts if timespan is less than 5 minutes
- Force x domain on build charts to match the queried timespan so that chart will not show less than
  one minute on the x-axis.
- Add new xMutator callback arg to graph util `mapLimitsRequests` function to allow for post-processing of
  utilization chart x values
- Add new xMutator and yMutator callback args to graph util `getRangeVectorStats` function to allow
  for post-processing of prometheus response data x and y values
- Remove logic from getRangeVectorStats function that removed second and millisecond data from all x
  values
- Update PrometheusMultilineUtilizationItem to use new xMutator argument to trim seconds and
  milliseconds off of multiline area chart data points.
- Create new global constants for prometheus query default samples and timespan
- Update Area and AreaChart components to use new global prometheus constants and accept domain prop
- Update twentyFourHourTime util function to accept `showSeconds` arg and get rid of
  twentyFourHourTimeWithSeconds function.
- Update usage of twentyFourHourTime/twentyFourHourTimeWithSeconds function where needed
@kyoto
Copy link
Member

kyoto commented Oct 28, 2020

Thanks @TheRealJon!

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kyoto, TheRealJon

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 28, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 984dbf4 into openshift:master Oct 28, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: All pull requests linked via external trackers have merged:

Bugzilla bug 1856351 has been moved to the MODIFIED state.

In response to this:

Bug 1856351: Fix build details page charts

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.

@spadgett spadgett added this to the v4.7 milestone Oct 29, 2020
@TheRealJon TheRealJon deleted the 1856351-bz branch January 22, 2021 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/dashboard Related to dashboard component/kubevirt Related to kubevirt-plugin component/monitoring Related to monitoring component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants