Skip to content

Conversation

@rawagner
Copy link
Contributor

Connect dashboard cards to K8s resources with Firehose.

detail

@openshift-ci-robot
Copy link
Contributor

Hi @rawagner. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 12, 2019
[RESULTS_TYPE.URL]: ImmutableMap<string, any>;
};

export type FirehoseResource = {
Copy link
Member

Choose a reason for hiding this comment

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

We should try to move this to a location where this type can be used in other contexts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to module/k8s/index.ts. Im not sure if there is more appropriate place.

Similar type was used in factory/details so I reused it there too.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm not sure the best place either. @alecmerdler ?

I would like to use this type in other places. We should eventually change firehose to use TypeScript. @alecmerdler has looked at that in the past.

Copy link
Contributor

Choose a reason for hiding this comment

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

Put it in utils/index.tsx until we have firehose.tsx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, moved to utils/index

return null;
};

const getKubernetesVersion = (kubernetesVersionResponse): string =>
Copy link
Member

Choose a reason for hiding this comment

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

We have this logic in the about dialog. We should try to write it once and use it everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted the logic into separate functions in about dialog and they are now reused in Details Card. Not sure if there is a better place to move them to ?

Copy link
Member

Choose a reason for hiding this comment

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

Extracted the logic into separate functions in about dialog and they are now reused in Details Card. Not sure if there is a better place to move them to ?

I'd suggest cluster-settings.ts

@rawagner
Copy link
Contributor Author

@spadgett please take a look

@spadgett spadgett added this to the v4.2 milestone Jun 14, 2019
@spadgett
Copy link
Member

/assign

Copy link
Member

Choose a reason for hiding this comment

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

We should make sure we have a consistent implementation with #1721. I'm in favor of using the API server host as-is for the moment since we don't have access to a real cluster name.

@christianvogt fyi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im good with using API server as-is. Extracted the getClusterName function to cluster-settings.ts so it can be reused by #1721

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 infrastructureData = _.get(resources, 'infrastructure.data', {});
const infrastructureData: K8sResourceKind = _.get(resources, 'infrastructure.data', {});

although TypeScript will yell since {} isn't a K8sResourceKind. We should fix that though so we have the type checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type added

Copy link
Member

Choose a reason for hiding this comment

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

I haven't seen how this looks, but I suspect having a loading icon for every detail item is too much animation.

Again we should consider skeleton while the widget is loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there is going to be quite a few loadings through the Overview Tab. We will be adding skeletons as a follow up.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a better type we can use? Is this a FirehoseResource[]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is actually what Firehose passes down - i've added better type but Im not sure if it is already created somewhere so I could reuse it.

Copy link
Member

Choose a reason for hiding this comment

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

This seems cleaner to me:

Suggested change
const clusterVersion = _.get(resources, 'cv');
const clusterVersion = _.get(resources, 'cv.data') as ClusterVersionKind;
// ...
const openshiftVersion = getOpenShiftVersion(clusterVersion);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typescript complains Conversion of type 'FirehoseResult' to type 'ClusterVersionKind' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. . It thinks that cv.data is FirehoseResult but in reality it is K8sResourceKind | K8sResourceKind[] :/ Splitting the expression in a way I do does not result in error. Seems like a bug in TS.

Copy link
Member

Choose a reason for hiding this comment

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

That seems weird. Is this a bug in the lodash typings? How does TypeScript know the type returned by _.get?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say that is an issue of @types/lodash-es but Im not very familiar with it. I tried updating to latest version (4.17.3, console is using 4.17.0) but it didnt help :/

Copy link
Member

Choose a reason for hiding this comment

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

We should update details.tsx to use this:

export type FirehoseResource = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

overview/index.tsx is now updated. I've changed FirehoseResult type definition a bit to fit overview/index.tsx better

@rawagner rawagner force-pushed the dashboard-k8s-simple branch 3 times, most recently from d5f67e8 to 7b38fb2 Compare June 18, 2019 17:35
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Thanks, please squash

Copy link
Member

Choose a reason for hiding this comment

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

How is id used for Tooltip? I don't see where it's referenced. If it's not required, we should leave it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Can this be {value} or if necessary <React.Fragment>{value}</React.Fragment> to avoid the unnecessary span?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no :/ using {value} results in error in runtime and <React.Fragment>{value}</React.Fragment> does not work either - no error, but tooltip does not appear when hovering over

Copy link
Member

Choose a reason for hiding this comment

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

That seems like a Patternfly bug :/

Copy link
Member

Choose a reason for hiding this comment

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

That seems weird. Is this a bug in the lodash typings? How does TypeScript know the type returned by _.get?

Copy link
Member

@spadgett spadgett 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 Jun 18, 2019
@spadgett
Copy link
Member

/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 Jun 18, 2019
@spadgett
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 18, 2019
Connect dashboard cards to K8s resources with Firehose
@rawagner rawagner force-pushed the dashboard-k8s-simple branch from 7b38fb2 to 414e422 Compare June 18, 2019 19:48
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2019
@spadgett
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rawagner, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 358505f into openshift:master Jun 19, 2019
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. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants