-
Notifications
You must be signed in to change notification settings - Fork 394
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
✨ make APIExportEndpointSlice consumer aware #3256
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
4bd9adf
to
f1b4a98
Compare
f1b4a98
to
4f51231
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
4f51231
to
84ba80d
Compare
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go
Outdated
Show resolved
Hide resolved
84ba80d
to
4371b8f
Compare
/retest |
e6ed986
to
9c6093a
Compare
pkg/indexers/apiexport.go
Outdated
|
||
path := logicalcluster.NewPath(apiExportEndpointSlice.Spec.APIExport.Path) | ||
if path.Empty() { | ||
path = logicalcluster.From(apiExportEndpointSlice).Path() |
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.
don't we need both ways to address it?
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.
Depends on how you look it up later in the code.
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.
Not sure I understand this comment.
I don't :D
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.
Now we only index exports as <lcluster>:export
or <path>:export
. Not both.
96c29f1
to
705e3bb
Compare
/retest |
705e3bb
to
cda4f26
Compare
@@ -1,5 +1,5 @@ | |||
/* | |||
Copyright 2022 The KCP Authors. | |||
Copyright 2025 The KCP Authors. |
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.
nit: we usually don't update when just changing files.
@@ -93,10 +102,16 @@ type APIExportEndpoint struct { | |||
} | |||
|
|||
func (in *APIExportEndpointSlice) GetConditions() conditionsv1alpha1.Conditions { | |||
if in == nil { | |||
return nil | |||
} |
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.
Not sure we want this. It encourages brittle code.
// EndpointSliceReadyForURLs is a condition for APIExportEndpointSlice that reflects the readiness of the slice to | ||
// provide URLs. It is set to True when the slice is ready to provide URLs which will be lifecycled based on existing consumers in the different | ||
// shards. | ||
APIExportEndpointSliceReadyForURLs conditionsv1alpha1.ConditionType = "EndpointReadyForURLs" |
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.
ReadyForEndpoints
.
Actually not clear why we need this. When is it not ready?
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.
Its more like handover/signal to secondary url controller. I used this a trigger. We could treat all conditions ready as signal too and just drop this all togheter.
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.
Was thinking about the label selector. It must be known, right?
} | ||
|
||
s := apiExportEndpointSlice.Status.ShardSelector | ||
if s == "" { // should never happen. |
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.
is this what the condition above is guarding?
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.
In theory yes, but I wanted to avoid cases where somebody patched status and now it might give false positive.
And I think now that maybe this be omitempty
pointer... Need to check if empty selector
is valid case.
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_reconcile.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_reconcile.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_controller_test.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_controller.go
Outdated
Show resolved
Hide resolved
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_controller.go
Outdated
Show resolved
Hide resolved
|
||
_, _ = globalShardClusterInformer.Informer().AddEventHandler(events.WithoutSyncs(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: func(obj interface{}) { | ||
c.enqueueAllAPIExportEndpointSlices(obj) |
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.
Why do we care about other shards?
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 was thinking about a case where a change in shards could impact APIExportSlices flow. But wrong assumptions
} | ||
|
||
// enqueueAPIExportEndpointSlicesForAPIExport enqueues APIExportEndpointSlices referencing a specific APIExport. | ||
func (c *controller) enqueueAPIExportEndpointSlicesForAPIExport(obj interface{}) { |
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.
why do we care about reconciling when an export changes? Won't APIBindings eventually change and that is enough for us to be 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.
It's one of those wrong assumptions, I think. WIll try
pkg/reconciler/apis/apiexportendpointsliceurls/apiexportendpointsliceurls_controller.go
Outdated
Show resolved
Hide resolved
return | ||
} | ||
|
||
{ // local to shard |
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.
why double code?
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.
readability. It isolates variables and makes it very clear to read two blocks. Its all about reading code and reducing mental overhead when reading the code.
// local to shard
// from cache
7ec0a3c
to
d28becd
Compare
/retest |
Signed-off-by: Mangirdas Judeikis <[email protected]> On-behalf-of: @SAP [email protected]
2b5c364
to
5546531
Compare
/retest |
@mjudeikis: The following test failed, say
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/test-infra repository. I understand the commands that are listed here. |
Summary
This part makes APIExportEndpointSlices consumers aware. Meaning it will add or remove URLs if consumers are present or goes away.
In this PR:
status
andurl
status
- status controller checks if API export is valid, partitions are set right, and it can be queried. Most of these objects operate in a single-shard context, so this reconciliation works only in a single-shard context. CAVITE: Based on the partition setup - the shards involved will be different. Hence we store the final computed selector into status for theURL
reconciler to pick up.url
- URL reconcile operates cross-shards setup. It takesAPIExportEndpointSlice
from the cache and local shard and observesAPIBindings
andAPIExports
and, based on consumers, will update URLs.In addition, it uses not a commuter but Server-Side Apply patch to update only its own field, which is owned by shard.
If we want to remove the selector from status - it would require an overload single reconciliation quite a lot. And filter when we can update statuses and when not. Overall, I tried, and the code readability was very poor.
Related issue(s)
Fixes # #3221
Release Notes