-
Notifications
You must be signed in to change notification settings - Fork 16
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
Enable static models when going trough available resources #134
Enable static models when going trough available resources #134
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: karelhala 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 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
==========================================
+ Coverage 30.52% 32.45% +1.93%
==========================================
Files 26 31 +5
Lines 462 487 +25
Branches 78 84 +6
==========================================
+ Hits 141 158 +17
- Misses 294 301 +7
- Partials 27 28 +1
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@@ -303,4 +302,10 @@ describe('batchResourcesRequest', () => { | |||
}, | |||
]); | |||
}); | |||
|
|||
test('should not call commonFetch for static model', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for tests!
@@ -0,0 +1,11 @@ | |||
import core from './core'; | |||
import apps from './apps'; | |||
import configOs from './config.openshift.io'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karelhala NIT - these names are a bit odd looking... it might help if we capitalize both O
and S
as it's an abbreviation for openshift
? Or perhaps just use the entire openshift
qualification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point.
@@ -35,7 +36,8 @@ export const defineModels = (list: APIResourceList): K8sModelCommon[] => { | |||
|
|||
export const batchResourcesRequest = (batch: string[]): Promise<DiscoveryResources>[] => { | |||
return batch.map<Promise<DiscoveryResources>>(async (p: string) => { | |||
const resourceList = await commonFetchJSON<APIResourceList>(p); | |||
const [, staticresourceList] = Object.entries(staticAPIModels).find(([key]) => key === p) || []; | |||
const resourceList = staticresourceList || (await commonFetchJSON<APIResourceList>(p)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karelhala so it looks like there is no way to override these static models correct? Even if what we get back from the server is different than what we have stored as static models?
I wonder if we should favor the static models initially, then replace the models later on? What are your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. I read the logic above incorrectly - I see we will only do this for exact matches for those static resources.
@@ -0,0 +1,354 @@ | |||
export default [ | |||
{ | |||
allResources: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karelhala could you shed some light on which server you collected this list from? I'm assuming the main devsandbox instance - but we should clarify for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@florkbr yeah, from the devsandbox from prod environment.
verbs: ['get', 'patch', 'update'], | ||
}, | ||
], | ||
} as APIResourceList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karelhala I know it's probably easier to use type assertions here, but could we update to use type annotations instead to avoid weakening our type checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
351d5c7
to
0872aac
Compare
/retest |
@karelhala I needed #138 to test this locally, otherwise I went through the flow of creating/viewing an app in stonesoup with this PR and everything works as expected (and I no longer see the requests for these core static models). Looks good to me 👍 |
/lgtm |
@karelhala: 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. |
Description
Since we have now full control over api discovery we can enhance it with static models. We've identified a couple of resources which won't change that often and we don't have to watch for their changes.
JIRA
RHCLOUD-23118