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 jobs for cronjobs when necessary #7164

Merged

Conversation

jeff-phillips-18
Copy link
Member

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

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

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/shared Related to console-shared labels Nov 9, 2020
): { loaded: boolean; loadError: string; jobs: JobKind[] } => {
const { namespace, uid } = cronJob.metadata;
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.

Suggested change
const [loadError, setLoadError] = React.useState<string>('');
const [loadError, setLoadError] = React.useState<string>(null);

@jerolimov
Copy link
Member

jerolimov commented Nov 11, 2020

@jeff-phillips-18 Tested this with the CronJob example below and got an error in pods-overview.tsx#L254-L257 because PodsOverviewMultiple prop podResources is undefined.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: example
  namespace: christoph-test
spec:
  schedule: '@daily'
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox
              args:
                - /bin/sh
                - '-c'
                - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

So you need to return jobs state in useJobsForCronJobWatcher with default [] or ensure that PodsOverviewMultiple handles this case.

edit: I see the benefit of using a default as well as an check in PodsOverviewMultiple. If you prefer the default we can use also the benefit of the "" default for loadError, in that case let us use setLoadError("") if there is no error.

@jeff-phillips-18
Copy link
Member Author

Thanks @jerolimov, updated.

Copy link
Contributor

@dtaylor113 dtaylor113 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 11, 2020
Comment on lines +254 to +259
let updatedPods = podResources?.length
? podResources.reduce((acc, resource) => {
acc.push(...getPodsForResource(resource, resources));
return acc;
}, [])
: [];
Copy link
Member

Choose a reason for hiding this comment

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

I personally would go with this, but its okay 😏

Suggested change
let updatedPods = podResources?.length
? podResources.reduce((acc, resource) => {
acc.push(...getPodsForResource(resource, resources));
return acc;
}, [])
: [];
let updatedPods = podResources?.reduce((acc, resource) => {
acc.push(...getPodsForResource(resource, resources));
return acc;
}, []) ?? [];

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.

Verified locally that it did not crash anymore, changed to setLoadError(""), has already lgtm, and I would give it as well 👍

/lgtm

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 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-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2020
@jeff-phillips-18
Copy link
Member Author

Rebased

@jeff-phillips-18
Copy link
Member Author

rebased again

@andrewballantyne
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, dtaylor113, 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-merge-robot openshift-merge-robot merged commit abfa22e into openshift:master Nov 13, 2020
@spadgett spadgett added this to the v4.7 milestone Nov 16, 2020
@jeff-phillips-18 jeff-phillips-18 deleted the topology-load-jobs 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/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

8 participants