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

Topology, fetch build config data when necessary #7162

Conversation

jeff-phillips-18
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 commented Nov 9, 2020

Fixes:
https://issues.redhat.com/browse/ODC-5114

Solution Description:
Remove build configs from OverviewItem type. Add hook to retrieve build configs for a given resource. Update instances to use hooks rather than fields in the OverviewItem type.

The alerts field for OverviewItem type is also removed as it is not being used anywhere (but required loading buildConfig resources).

Non-Functional Change

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

/kind cleanup

@openshift-ci-robot openshift-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. component/core Related to console core functionality labels Nov 9, 2020
@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared labels Nov 9, 2020
Comment on lines 33 to 37
const errorKey = Object.keys(resources).find((key) => resources[key].loadError);
if (errorKey) {
setLoadError(resources[errorKey].loadError);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Small detail, but can simplified with Object.values:

Suggested change
const errorKey = Object.keys(resources).find((key) => resources[key].loadError);
if (errorKey) {
setLoadError(resources[errorKey].loadError);
return;
}
const resourceWithLoadError = Object.values(resources).find((r) => r.loadError);
if (resourceWithLoadError) {
setLoadError(resourceWithLoadError.loadError);
return;
}

For me both is fine, doesn't block this PR for me.

resource: K8sResourceKind,
): { loaded: boolean; loadError: string; buildConfigs: BuildConfigOverviewItem[] } => {
const [loaded, setLoaded] = React.useState<boolean>(false);
const [loadError, setLoadError] = React.useState<string>('');
Copy link
Member

Choose a reason for hiding this comment

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

Please default with null. The useEffect also sets setLoadError to null if there is new resources available without any error. In this case we can save us from one re-rendering

Comment on lines 268 to 271
const resourceBuildConfigs =
resource.kind === 'CronJob'
? getBuildConfigsForCronJob(resource as CronJobKind, resources)
: getBuildConfigsForResource(resource, resources);
Copy link
Member

Choose a reason for hiding this comment

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

Just an idea: We can move this check also into getBuildConfigsForResource ? So that it starts with

export const getBuildConfigsForResource = (
  resource: K8sResourceKind,
  resources: any,
): BuildConfigOverviewItem[] => {
  if (resource.kind === 'CronJob') {
    return getBuildConfigsForCronJob(resource as CronJobKind, resources);
  }
  // ....

Makes this sense? Not required to get a lgtm :)

Copy link
Member

@jerolimov jerolimov left a comment

Choose a reason for hiding this comment

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

Finished review, small change requested and added two ideas.

Tested the topology graph and sidebar locally with some git deployment which works fine.

@jeff-phillips-18
Copy link
Member Author

/test kubevirt-plugin

Copy link
Member

@jerolimov jerolimov left a comment

Choose a reason for hiding this comment

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

Tested locally, Topology shows BuildConfigs

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 11, 2020
@jeff-phillips-18
Copy link
Member Author

/test kubevirt-plugin

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

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

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jeff-phillips-18, jerolimov, rohitkrai03

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 12, 2020
@openshift-merge-robot openshift-merge-robot merged commit 444e75c into openshift:master Nov 12, 2020
@spadgett spadgett added this to the v4.7 milestone Nov 16, 2020
@jeff-phillips-18 jeff-phillips-18 deleted the topology-load-build-configs branch December 2, 2020 13:33
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. component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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

6 participants