-
Notifications
You must be signed in to change notification settings - Fork 265
Allow RGD resources to reference instance status fields #787
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
base: main
Are you sure you want to change the base?
Allow RGD resources to reference instance status fields #787
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bschaatsbergen The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
|
|
Welcome @bschaatsbergen! |
|
Hi @bschaatsbergen. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
Removes restriction on `schema.status` field references in RGD CEL
expressions. Renames `getSchemaWithoutStatus` to `getInstanceSchema`
and includes status property alongside spec and metadata in the
validation schema.
Previously, the status field was explicitly deleted before CEL
validation, preventing references like `${schema.status.endpoint}`
or `${service.status.loadBalancer.ingress[0].hostname}` in dependent
resources.
Signed-off-by: Bruno Schaatsbergen <[email protected]>
70ebe3e to
4c718eb
Compare
jakobmoellerdev
left a comment
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.
Hey there! thanks for the contrib. Mainly the limitations we must consider are:
- Status Objects are always optional and may or may not be present. Referencing should only be possible with optional value reference closures IMHO.
- Status Objects were previously unstructured so to get a proper setup, you would also need to replace usage here
Line 572 in 548e4db
func buildStatusSchema(
I think if you manage to get rid of dynamic status value computation on top of your change, this will be more "complete". Otherwise your RGD creation will have the schema but your cluster based instance will still not use this
Thanks for the quick review, @jakobmoellerdev! Just to confirm my understanding; we should exclude status from required fields before type-checking the instance schema, so that CEL expressions in dependent resources can reference the instance’s status without validation errors when it’s still empty? Basically, clean up/unmark any status entry from the In b4128a9, I've ensured status fields remain optional before type-checking the instance schema. |
93def8f to
bdd37f7
Compare
…e-checking
Remove status from required fields before type-checking. This allows CEL expressions in dependent resources to reference instance status (e.g., `${schema.status.endpoint}`) without validation errors when the instance status hasn't been populated yet.
Signed-off-by: Bruno Schaatsbergen <[email protected]>
bdd37f7 to
b4128a9
Compare
|
Before I push you further into any direction and you potentially have a waste of time, I want to have a conceptual guidance of @a-hilaly here as he wrote the original status schemaless logic. Expect a bit of turnaround due to kubecon please. My understanding is that rgd resources should be able to FILL instance status fields, but not the other way around. an instance should aggregate status and we didnt have good cases yet in which the other way would have made sense. |
|
/ok-to-test |
|
/ok-to-test |
|
@bschaatsbergen: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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-sigs/prow repository. I understand the commands that are listed here. |
|
First, I agree that, conceptually, we must be able to bubble up the resources status to the RGD instance the same way we cascade parameters down. It is true that this brings a complexity when the status does not exist yet, but I think it is manageable and worth the effort |
| "region": "string", | ||
| }, | ||
| map[string]interface{}{ | ||
| "vpcID": "${vpc.status.vpcID}", |
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.
We also need tests to ensure that:
- when the status field can't be resolved (i.e.
vpc.status == nil) the instance can be reconciled without error - when the status field exists (i.e.
vpc.status.vpcID = "vpc-xzy"), after reconcile, the instance has statusstatus.vpcID: vpc-xyz`
| // Remove "status" from required fields if present | ||
| required := make([]string, 0, len(s.Required)) | ||
| for _, field := range s.Required { | ||
| if field != "status" { | ||
| required = append(required, field) | ||
| } | ||
| } | ||
| s.Required = required |
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.
Would we gain readability on the intent using slices.DeleteFunc
| // Remove "status" from required fields if present | |
| required := make([]string, 0, len(s.Required)) | |
| for _, field := range s.Required { | |
| if field != "status" { | |
| required = append(required, field) | |
| } | |
| } | |
| s.Required = required | |
| s.Required = slices.DeleteFunc(s.Required, func(e string){ | |
| return e == "status" | |
| }) |
Closes #762
Currently we explicitly exclude
schema.statusfields from being referenced in CEL expressions on RGD resources. The getSchemaWithoutStatus function deletes the status property before validation, preventingschema.status.*references, as previously intended.This does however block the ability to reference computed status values (like
status.endpoint: ${service.status.loadBalancer.ingress[0].hostname}) in dependent resources, forcing users to duplicate expressions instead of implementing a cleaner dependency pattern.This removes that restriction by renaming the function to
getInstanceSchemaand includingschema.statusalongsideschema.specandschema.metadata.Quick question for the maintainers; what was the reasoning behind initially excluding the status fields? Understanding the background here would help me add more appropriate safeguards around including
schema.status.