This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The clients used by reconciler runtime are now able to interact with duck typed resources, with some limitations. The support extends to working inside reconcilers, including with the ResourceReconciler. Duck typed resources are structured types that implement the client.Object interface but are not registered in the scheme for a GVK. The APIVersion and Kind fields must be set on the object. Using ResourceReconciler with a duck type is similar to using an unstructured type and then casting to the duck type, however, starting with a duck type will allow the resource to participate in common structured operations like setting the status observed generation, initializing conditions, and coalescing condition timestamps when the condition did not otherwise change. Known limitations include: - Create client methods are not supported. Resources always need to be created with a concrete type. - Update client methods are not supported. Use Patch methods instead. - ResourceReconciler will patch status if a mutation is detected instead of update. The bytes of the patch must be defined on the ReconcilerTestCase for tests that result in a patch request. Ephemeral values, like LastTransitionTime timestamps, need to be pinned to known values. Use ReconcilerTestCase#Now for timestamp values. To help solve the ephemeral nature of time, this change also introduces a mechanism to retrieve the current time off the context via rtime.RetrieveNow. Each root reconciler stashes the current time. Additionally, each test case can define the Now field with a custom timestamp that is stashed as the current time. The condition manager Manage method is deprecated in favor of ManageWithContext, which will use the stashed time when constructing conditions. The status InitializeConditions method should be updated to accept a context when it is defined, the no arg variant is deprecated. When using either deprecated method without a context, time.Now is used instead of the stashed time. Signed-off-by: Scott Andrews <[email protected]>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #402 +/- ##
==========================================
- Coverage 61.36% 60.62% -0.74%
==========================================
Files 24 24
Lines 2275 2334 +59
==========================================
+ Hits 1396 1415 +19
- Misses 796 835 +39
- Partials 83 84 +1
☔ View full report in Codecov by Sentry. |
Signed-off-by: Scott Andrews <[email protected]>
Signed-off-by: Scott Andrews <[email protected]>
squeedee
approved these changes
Aug 10, 2023
Signed-off-by: Scott Andrews <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The clients used by reconciler runtime are now able to interact with duck typed resources, with some limitations. The support extends to working inside reconcilers, including with the ResourceReconciler.
Duck typed resources are structured types that implement the client.Object interface but are not registered in the scheme for a GVK. The APIVersion and Kind fields must be set on the object.
Using ResourceReconciler with a duck type is similar to using an unstructured type and then casting to the duck type, however, starting with a duck type will allow the resource to participate in common structured operations like setting the status observed generation, initializing conditions, and coalescing condition timestamps when the condition did not otherwise change.
Known limitations include:
To help solve the ephemeral nature of time, this change also introduces a mechanism to retrieve the current time off the context via rtime.RetrieveNow. Each root reconciler stashes the current time. Additionally, each test case can define the Now field with a custom timestamp that is stashed as the current time.
The condition manager Manage method is deprecated in favor of ManageWithContext, which will use the stashed time when constructing conditions. The status InitializeConditions method should be updated to accept a context when it is defined, the no arg variant is deprecated. When using either deprecated method without a context, time.Now is used instead of the stashed time.
Resolves #53