-
Notifications
You must be signed in to change notification settings - Fork 271
Description
The intent of this issue is to outline some of the challenges faced in determining the latest state of a resource and when/how it should be updated. Many of these items have already been addressed and have working solutions, but others still require input from other service teams and support at an ACK framework level.
Summary/TL;DR: What still needs to be addressed?
- Should
latest.Specbe populated from scratch in ReadOne/sdkFind? - How do we make the latest observed state in
latest.Specvisible to the user? - When should a
Specdifference actually be added to the delta?- Nil difference in one direction/default fields: in progress in ability to deal with server side defaults/initializers #812
- Nil difference in the other direction (e.g. k8s secrets fields): Issue opened (Support for SecretKeyReference updates #700), no discussion has occurred
- No nil difference, server returns different value than requested: workaround possible, but no framework-level solution yet
- No nil difference, but diff present because fields are immutable: a solution has been merged in, but there are still remaining questions
- Handle "update-only" fields (support update code paths for opensearchservice #816), issue opened
- How do we only add meaningful
Specdifferences to the delta? - Should an Update payload only include the resource identifier along with diffs present in the delta, as opposed to everything currently in
desired.Spec?
Dependent issues can be created as needed to discuss each of these items. The rest of the sections in the description provide some common context:
Definitions (descriptive, not prescriptive)
Spec - the fields corresponding to inputs of the Create API for a resource
Status - a collection of server responses from Create, Read, and Modify calls, including fields both related and unrelated to Spec fields. Can also contain additional state-keeping fields (e.g. conditions)
desired.Spec: the user-provided configuration of the resource
desired.Status: essentially a copy of latest.Status (after patching occurs)
latest.Spec: ideally, the currently observed state of all Spec fields resulting from a ReadOne call. In practice, some fields get updated with the observed state and others are copied over from desired.Spec
latest.Status: the aggregation of information returned by the API response, combined with previously observed state (latest is copied from desired, then modified, then patched back into desired) + other state-keeping fields.
More info on k8s conventions here
Given that updates are triggered upon Spec differences, latest.Spec must reliably represent the latest observed state. How do we populate each Spec field with the latest observed state?
There are a number of possible cases:
- Field in API response has same name as Spec field: generated code populates this field directly. Example
- API response contains information to populate the corresponding Spec field, but it may require some processing: the
SetOutputmethods or thepost_set_outputhooks allow service teams to manually populate the relevant Spec field. Example - Additional API calls are required to obtain the information to populate the Spec field: service teams can also use the
SetOutputmethods orpost_set_outputhooks to handle this. Example 1 , Example 2 - The latest observed state of the field cannot be retrieved in the API response. This is the case with k8s secrets-enabled fields. (e.g. ElastiCache Replication Group has
AuthTokenEnabledbut you obviously can't retrieve the valueAuthTokenfrom the server). The update behavior of such fields may require some ACK framework-level input or support. Example
This discussion raises the first question below: