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 1780392: Fix hasModel check for CRD models #3690

Merged
merged 1 commit into from Dec 7, 2019

Conversation

spadgett
Copy link
Member

@spadgett spadgett commented Dec 5, 2019

@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 Dec 5, 2019
@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 5, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 5, 2019
Copy link
Member

@TheRealJon TheRealJon 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 Dec 5, 2019
@andrewballantyne
Copy link
Contributor

You're fast :) But this will fail the e2e test as it did for me back in Oct.

image

@andrewballantyne
Copy link
Contributor

/hold

I could be wrong, but I'll add the hold for now to prevent auto-merge.

@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 Dec 5, 2019
@TheRealJon TheRealJon self-requested a review December 5, 2019 16:45
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2019
@andrewballantyne
Copy link
Contributor

/hold cancel

Didn't see the WIP :)

@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 Dec 5, 2019
@@ -27,7 +27,7 @@ export const modelsToMap = (models: K8sKind[]): ImmutableMap<K8sResourceKindRefe
let k8sModels = modelsToMap(_.values(staticModels));

const hasModel = (model: K8sKind) =>
k8sModels.has(referenceForModel(model)) || k8sModels.has(model.kind);
k8sModels.has(referenceForModel(model)) || (!model.crd && k8sModels.has(model.kind));
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that you got it to work where I failed... I would recommend going with my first implementation and making hasModel and modelsToMap use the same logic to figure out the key to store it under.

From Slack:

https://github.com/spadgett/console/blob/586f68d0eaa32defc34df2554b39c5fc226a7d79/frontend/public/module/k8s/k8s-models.ts#L13-L18
I think we need to de-duplicate and reuse this logic. The hasModel should lookup in the same order/reference as the storage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change:

const modelKey = (model) => {
  // TODO: Use `referenceForModel` even for known API objects
  return model.crd ? referenceForModel(model) : model.kind;
};

export const modelsToMap = (models: K8sKind[]): ImmutableMap<K8sResourceKindReference, K8sKind> => {
  return ImmutableMap<K8sResourceKindReference, K8sKind>().withMutations((map) => {
    models.forEach((model) => map.set(modelKey(model), model));
  });
};
...
const hasModel = (model: K8sKind) => k8sModels.has(modelKey(model));

That way they are both based off the same value, it looks it up in the same fashion it stores it. No way for it to be confused on reverse lookups.

@spadgett spadgett force-pushed the crd-models branch 2 times, most recently from 2b32de0 to ad3e1ce Compare December 5, 2019 20:10
@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 5, 2019
@christianvogt
Copy link
Contributor

Such familiar code :)
we were sooo close lol

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

I can find nothing broken. This solved all of the issues I ran into last time when I was in this area. This appears to have unlocked the ability to properly style Knative Services and Knative Routes.

cc @jeff-phillips-18

@andrewballantyne
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2019
@spadgett spadgett changed the title [WIP] Fix hasModel check for CRD models Fix hasModel check for CRD models Dec 5, 2019
@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 Dec 5, 2019
@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 Dec 6, 2019
@spadgett
Copy link
Member Author

spadgett commented Dec 6, 2019

The OLM pages work fine clicking through the UI, but this breaks legacy URLs that used clusterserviceversions in the URL. Since the model is crd: true, connectToPlural doesn't find the model.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/olm Related to OLM and removed lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 6, 2019
@spadgett
Copy link
Member Author

spadgett commented Dec 6, 2019

/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 Dec 6, 2019
@spadgett
Copy link
Member Author

spadgett commented Dec 6, 2019

/retest

2 similar comments
@spadgett
Copy link
Member Author

spadgett commented Dec 6, 2019

/retest

@jeff-phillips-18
Copy link
Member

/retest

@spadgett
Copy link
Member Author

spadgett commented Dec 6, 2019

/retest

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

/lgtm
/retest

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, jeff-phillips-18, spadgett, 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-bot
Copy link
Contributor

/retest

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

5 similar comments
@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@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 1288239 into openshift:master Dec 7, 2019
@openshift-ci-robot
Copy link
Contributor

@spadgett: All pull requests linked via external trackers have merged. Bugzilla bug 1780392 has been moved to the MODIFIED state.

In response to this:

Bug 1780392: Fix hasModel check for CRD models

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-cherrypick-robot

@spadgett: new pull request created: #3718

In response to this:

/cherrypick release-4.3

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.

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/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/olm Related to OLM lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants