-
Notifications
You must be signed in to change notification settings - Fork 239
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
Support the partial observed state in ContainerCluster, ContainerNodePool and RedisInstance #1059
Support the partial observed state in ContainerCluster, ContainerNodePool and RedisInstance #1059
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maqiuyujoyce 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 |
96bc40f
to
5e07fdc
Compare
scripts/generate-google3-docs/resource-reference/generated/resource-docs/redis/redisinstance.md
Show resolved
Hide resolved
pkg/test/resourcefixture/testdata/basic/container/v1beta1/maqiuyu/create.yaml
Outdated
Show resolved
Hide resolved
32ec255
to
af2d237
Compare
@@ -1808,6 +1808,24 @@ spec: | |||
current reported status reflects the most recent desired state of | |||
the resource. | |||
type: integer | |||
observedState: |
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.
So given that e.g. masterVersion is status.masterVersion
, do we want to introduce status.observedState
? i.e. should it be status.observedState.masterAuth.clientCertificate
vs status.masterAuth.clientCertificate
?
The way I see it:
- If we introduce
status.observedState
we have to deal with thestatus.masterVersion
vsstatus.observedState.masterVersion
inconsistency at some time in the future - If we don't introduce
status.observedState
we (maybe) have a naming conflict if there's a status field in the API called "conditions"
Personally, I'd rather deal with the hypothetical work of (2) than the known work of (1), but that's just my intuition
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.
Thank you for the suggestions, @justinsb !
If we introduce status.observedState we have to deal with the
status.masterVersion
vsstatus.observedState.masterVersion
inconsistency at some time in the futureIf we don't introduce
status.observedState
we (maybe) have a naming conflict if there's a status field in the API called "conditions"
IMO, if we introduce status.observedState.masterVersion
one day, then status.masterVersion
and status.observedState.masterVersion
will always share the same value. I'd consider it a redundancy but not inconsistency. Or are you referring to some other scenarios?
If we need to deal with naming conflict, then it seems to be a true inconsistency: possibly we either need to rename the observed field (inconsistent with its original field name), or rename the existing status field (may impact all CRDs).
And in general I find redundancy safer to the users.
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.
My 2 cents. I think grouping the observed state has additional benefits in that we're grouping it. We can tell customers (and future devs) that all cloud response state can be found under .spec.observedState. More importantly I think we should insist that only cloud response state is allowed into .spec.observedState. That allows anyone looking at a value under .spec.observedState to trust its a value from the cloud provider and not say an artifact from the controller. I think it will make a docs easier and clearer. I think the fact that it essentially name spaces the response data and hence provides protection from future conflicts (either from new fields, newly cared about response fields or other non cloud response status fields which happen to have a name collision) is valuable but possibly not the most valuable.
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.
I agree with @cheftako, my view on a dedicated status.observedState
is it gives our users a new mental model on how to identify status changes caused by the external cloud provider, but not KCC.
if there's a status field in the API called "conditions"
Also I want to mention this is not a hypothetical scenario. We have already seen it in a few CRDs. See the following two examples in our servicemapping config. We had to ignore a bunch of fields because they have conflict naming with the reserved K8s status name fields.
Should customers require support for these ignored fields in the future, we have the flexibility to add them to status.observedState
.
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.
Thank you for the input, @cheftako and @diviner524 !
@justinsb I'll probably merge the implementation as is for now. If you think not having status.observedState
is important, then let's discuss offline about a revised design.
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.
I spoke to @cheftako , who persuaded me round to your collective point of view. My hope is that we can remove the duplicated fields in v1, so if we do that I think we should proceed with observedState
:-)
/lgtm |
761f1d8
into
GoogleCloudPlatform:master
Change description
Fixes b/315227901
Supported the following observed fields:
status.observedState.masterAuth.clientCertificate
in ContainerClusterstatus.observedState.version
in ContainerNodePoolstatus.authString
in RedisInstanceFixed the issue that when the parent of the observed field exists but the observed field itself doesn't, there is still an empty observed state. Added test cases to cover this scenario.
Tests you have done
make ready-pr
to ensure this PR is ready for review.Did local integration test using the following test cases.
ContainerCluster and ContainerNodePool
Applied the following YAML:
Verified that after the reconciliation completed, in the output of
kubectl describe
, the values understatus.observedState
in the CRs matched the corresponding fields underspec
.RedisInstance
Applied the following YAML:
Verified that after the reconciliation completed, in the output of
kubectl describe
,status.observedState.authString
can be found.Updated the resource with the following YAML:
Verified that after the reconciliation completed, in the output of
kubectl describe
, the entirestatus.observedState
struct is gone.