-
Notifications
You must be signed in to change notification settings - Fork 145
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
Prevent API groups from growing stale #264
Conversation
What is the difference between the existing refresh mechanism and the one resulting from this change? It's not obvious to me how the refresh is triggered. |
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.
Looks good, just one comment
openshift/dynamic/client.py
Outdated
if request_resources: | ||
resources = self.get_resources_for_api_version(DISCOVERY_PREFIX, group['name'], version, preferred) | ||
new_group[version] = ResourceGroup(preferred, resources=resources) | ||
groups[DISCOVERY_PREFIX][group['name']] = new_group | ||
self._cache['resources'] = groups | ||
self._cache['resources'].update(groups) |
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.
Wouldn't doing the dictionary update every iteration of the loop be slower than just setting self._cache['resources'] at the end?
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.
woops, typo, that was supposed to be one level out
This makes the api_groups refresh when accessed, so that it's always the most up to date list of resources available in the cluster. Before it would only refresh when you attempted to access a resource that did not exist in the cache. Since updating api_groups is just a single API call (with the lazy discoverer at least), I thought this behavior would be more useful than requiring you to manually refresh the cache or miss a resource to get the new groups to show up. We hit this in one of our operators, where it created a CRD and later verified that the API group existed- because api_groups didn't refresh, the check failed. |
I think I tested this correctly:
Then I create my CRD
|
And I can show it failing on
|
@willthames did that clear up your reservations? Any opposition to merge? |
* Make api_groups a property * Prevent api_groups from growing stale by re-requesting resources every time * Add back v1.List * Typo
@willthames @asetty if you'd like to take a look