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

RHCLOUD-23119: Allow for on demand API discovery through hooks #217

Closed
wants to merge 2 commits into from

Conversation

florkbr
Copy link
Contributor

@florkbr florkbr commented Apr 10, 2023

Success case: demonstration showing fetch is only called once per model

on-demand-model-fetch-example.mp4

Failure case: demonstration showing fetch will be limited to only 3 calls for a given model

Screenshot 2023-04-11 at 6 09 28 PM

https://issues.redhat.com/browse/RHCLOUD-23119

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: florkbr

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2023
@florkbr florkbr force-pushed the on-demand-discovery branch 2 times, most recently from 77f8842 to 838c0fc Compare April 11, 2023 22:12
if (!k8sModel && !inFlight && !batchesInFlight && retries < 3) {
fetchModel(resource, dispatch);
setRetries(retries + 1);
}
return modelsLoaded && !k8sModel && !batchesInFlight
? [data, true, new NoModelError()]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We may need to prevent this return value from returning while we're still trying to fetch the model on demand above. While I was testing locally this didn't seem to be an issue, but I'll continue looking.

@florkbr
Copy link
Contributor Author

florkbr commented Apr 11, 2023

/assign @karelhala

@florkbr
Copy link
Contributor Author

florkbr commented Apr 12, 2023

@karelhala FWIW I was able to test this change by commenting out API discovery in hac-core:

diff --git a/frontend/src/sdk/InitializeSDK.tsx b/frontend/src/sdk/InitializeSDK.tsx
index 71860aa..a281f62 100644
--- a/frontend/src/sdk/InitializeSDK.tsx
+++ b/frontend/src/sdk/InitializeSDK.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
 import { AppInitSDK } from '@openshift/dynamic-plugin-sdk-utils';
 import Loader from '../Utils/Loader';
 import useAppConfiguration from './useAppConfiguration';
-import { initAPIDiscovery } from '../Utils/api-discovery';
+// import { initAPIDiscovery } from '../Utils/api-discovery';
 
 const InitializeSDK: React.FC = ({ children }) => {
   const appConfigurations = useAppConfiguration();
@@ -14,7 +14,7 @@ const InitializeSDK: React.FC = ({ children }) => {
   // TODO(SDK): Don't override children
   // TODO(SDK): AppInitSDK doesn't work with no redux
   // react_devtools_backend.js:4061 Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
-  return <AppInitSDK configurations={{ ...appConfigurations, apiDiscovery: initAPIDiscovery }}>{children as any}</AppInitSDK>;
+  return <AppInitSDK configurations={{ ...appConfigurations, apiDiscovery: () => {} }}>{children as any}</AppInitSDK>;
 };
 
 export default InitializeSDK;

@florkbr florkbr changed the title Allow for on demand API discovery through hooks RHCLOUD-23119: Allow for on demand API discovery through hooks Apr 12, 2023
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 12, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 12, 2023

@florkbr: This pull request references RHCLOUD-23119 which is a valid jira issue.

In response to this:

Success case: demonstration showing fetch is only called once per model

on-demand-model-fetch-example.mp4

Failure case: demonstration showing fetch will be limited to only 3 calls for a given model

Screenshot 2023-04-11 at 6 09 28 PM

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

openshift-ci-robot commented Apr 12, 2023

@florkbr: This pull request references RHCLOUD-23119 which is a valid jira issue.

In response to this:

Success case: demonstration showing fetch is only called once per model

on-demand-model-fetch-example.mp4

Failure case: demonstration showing fetch will be limited to only 3 calls for a given model

Screenshot 2023-04-11 at 6 09 28 PM

https://issues.redhat.com/browse/RHCLOUD-23119

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.

@@ -235,6 +236,35 @@ export const getGroupVersionKindForModel: GetGroupVersionKindForModel = ({
kind,
});

/**
* Provides the K8sResourceIdentifier for the given K8sGroupVersionKind or K8sResourceKindReference.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW this is not exposed to SDK consumers, just doc'ed internally for SDK devs.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 13, 2023

@florkbr: all tests passed!

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.

Copy link
Contributor

@karelhala karelhala left a comment

Choose a reason for hiding this comment

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

Looking good! I wouldn't include onlyPreferenceList in this PR. We should work on allowing plugins listing models to watch for and any other model can be on demand trough these new hooks.

@florkbr
Copy link
Contributor Author

florkbr commented Apr 17, 2023

@karelhala I'm not sure I follow. At some point won't we need to fallback on fetching the model if it's not in the list plugins provide?

@karelhala
Copy link
Contributor

Yes, that's the aim of this PR isn't it? The idea is that plugins will provide default models we'll watch for. If extension would want to watch for another model they'll use these new hooks.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 18, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 18, 2023
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

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-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 17, 2023
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Sep 17, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 17, 2023

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants