[WIP] Rebase to Kubernetes 1.35.1#185
[WIP] Rebase to Kubernetes 1.35.1#185xmudrii wants to merge 60 commits intokcp-dev:kcp-1.35.1-baselinefrom
Conversation
Previous PRs: 113151 117301 Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Co-authored-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
… pods Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Co-authored-by: Robert Vasek <rvasek01@gmail.com> Signed-off-by: Robert Vasek <robert.vasek@clyso.com>
…gin and policy plugin framework Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
…rge patch Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
…ss identities Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
…card partial metadata requests Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
… storage paths Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Co-authored-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
… control plane Signed-off-by: Marvin Beckers <marvin@kubermatic.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
…dler patch Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com> Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
02a3801 to
ec6856f
Compare
| } | ||
| err := s.decoder.Decode(value, objPtr, rev) | ||
| if err != nil { | ||
| spew.Dump(err) |
mjudeikis-bot
left a comment
There was a problem hiding this comment.
Review: kcp patches forward-port to 1.35.1
Overall the rebase approach is sound. Found three forward-port artifacts that need addressing before this merges, ranging from trivial to potential showstopper.
🔴 Blocking
1. Debug panic guards in registry/store.go
CompleteWithOptions now has two issues:
- A condition that's always true:
if e.KeyFunc != nil || e.KeyFunc != nil(same field checked twice) with an error message literally containing "DEBUG:" - Unconditional panics on
KeyFunc != nil/KeyRootFunc != nilthat will blow up startup for any resource still using custom key functions
This is almost certainly a conflict-resolution mistake. kcp's intent is to force all resources onto cluster-aware key functions — but panicking unconditionally means any resource not yet migrated will crash the server at startup. Either remove the panics and add a TODO comment, or verify 100% of resources have been migrated and document that explicitly.
2. BuildHandlerChainWithStorageVersionPrecondition missing outer chain
Changed from:
return DefaultBuildHandlerChain(handler, c) // full 3-part chainto:
return DefaultBuildHandlerChainFromAuthzToCompletion(handler, c) // inner part onlyThis skips FromStartToBeforeImpersonation where kcp's logical cluster context middleware is injected. Any server using this function as its handler chain builder will silently process requests without cluster context set. Needs to either call the full chain or explicitly document why only the inner part is needed here.
🟡 Non-blocking (but fix before GA)
3. Managed fields trim removed
Previous code used WithTransform(trim) to strip managed fields from the informer cache. The new kcpinformers.NewSharedInformerFactory call doesn't pass this transform. With kcp's per-cluster informer caches, this is a meaningful memory regression. Intentional? If so, add a comment explaining why.
4. Protobuf loopback removed without comment
genericConfig.LoopbackClientConfig.ContentConfig.ContentType = "application/vnd.kubernetes.protobuf" removed silently. Likely intentional (protobuf doesn't carry kcp cluster context headers the way JSON requests do) but should be documented.
| return err | ||
| } | ||
| // being unable to set the version does not prevent the object from being extracted | ||
| if err := versioner.UpdateObject(objPtr, uint64(rev)); err != nil { |
There was a problem hiding this comment.
Debug artifact — spew.Dump(err) should not be in production code. Remove this line (and the "github.com/davecgh/go-spew/spew" import if it's only used here).
| klog.Errorf("No cluster defined in GuaranteedUpdate action for key %s : %s", key, err.Error()) | ||
| } | ||
| shardName := endpointsrequest.ShardFrom(ctx) | ||
|
|
There was a problem hiding this comment.
This panic will crash the server at startup for any resource that still has a custom KeyFunc. There's also a condition a few lines above that checks e.KeyFunc != nil || e.KeyFunc != nil (same field twice — always true) with an error message literally containing "DEBUG:".
Two options:
- If every resource has been migrated to cluster-aware key functions: remove the duplicate-field condition, drop the "DEBUG:" string, and add a comment confirming the migration is complete.
- If migration is still in progress: remove the panics, replace with a TODO.
There was a problem hiding this comment.
comment code is wrong but issue is real
There was a problem hiding this comment.
@mjudeikis @mjudeikis-bot This file doesn't have KeyFunc and I don't see any panic. Can you please clarify what exactly should be solved here?
There was a problem hiding this comment.
Withdrawing the earlier comment about KeyFunc and panic — that was incorrect. xmudrii is right, the file doesn't have KeyFunc or any panic at this location. Nothing to fix here.
| //var _ = initializer.WantsExternalKubeInformerFactory(&Lifecycle{}) | ||
| //var _ = initializer.WantsExternalKubeClientSet(&Lifecycle{}) |
There was a problem hiding this comment.
@mjudeikis It has been there even before rebase:
|
Re: my comment on Checked against |
|
Re the This looks incorrect — changing
Should revert to calling the full chain: func BuildHandlerChainWithStorageVersionPrecondition(apiHandler http.Handler, c *Config) http.Handler {
// WithStorageVersionPrecondition needs the WithRequestInfo to run first
handler := genericapifilters.WithStorageVersionPrecondition(apiHandler, c.StorageVersionManager, c.Serializer)
return DefaultBuildHandlerChain(handler, c) // full chain — same as before the split
}The split into 3 sub-functions is a good refactor for kcp-specific chain injection between segments, but |
|
Follow-up on Checked where this function is actually used: it is only assigned to My original concern stands as a theoretical correctness issue (if those gates were ever enabled, the chain would be incomplete), but it is not a real problem for kcp today. Consistent with kcp-1.34.2 where the same pattern exists. |
|
Suggesting a code comment on func BuildHandlerChainWithStorageVersionPrecondition(apiHandler http.Handler, c *Config) http.Handler {
// WithStorageVersionPrecondition needs the WithRequestInfo to run first.
//
// NOTE (kcp): This function is intentionally limited to DefaultBuildHandlerChainFromAuthzToCompletion
// (inner chain segment only). In kcp, BuildHandlerChainFunc is fully replaced by a custom function in
// pkg/server/config.go that manually assembles all three chain segments with kcp-specific middleware
// injected between them. As a result, this function is never actually used as the BuildHandlerChainFunc
// in kcp — if StorageVersionAPI + APIServerIdentity feature gates are ever enabled in kcp,
// WithStorageVersionPrecondition must be added explicitly inside kcp's BuildHandlerChainFunc.
handler := genericapifilters.WithStorageVersionPrecondition(apiHandler, c.StorageVersionManager, c.Serializer)
return DefaultBuildHandlerChainFromAuthzToCompletion(handler, c)
} |
…condition kcp fully replaces GenericConfig.BuildHandlerChainFunc with its own implementation that manually assembles all three handler chain segments with kcp-specific middleware injected between them. As a result, any BuildHandlerChainFunc customization applied earlier in the setup pipeline (such as the BuildHandlerChainWithStorageVersionPrecondition assignment in CreateAggregatorConfig when StorageVersionAPI + APIServerIdentity feature gates are enabled) is silently overwritten and never called. Add a comment to make this explicit so that if kcp ever enables those feature gates, WithStorageVersionPrecondition is added directly inside the custom BuildHandlerChainFunc rather than relying on the replaced one. Ref: kcp-dev/kubernetes#185 Signed-off-by: mjudeikis-bot <mjudeikis-bot@faros.sh> Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Co-authored-by: Hex (AI) <hex@faros.sh>
kcp fully replaces GenericConfig.BuildHandlerChainFunc, which means BuildHandlerChainWithStorageVersionPrecondition from the kubernetes fork (assigned in CreateAggregatorConfig when StorageVersionAPI + APIServerIdentity feature gates are enabled) is silently overwritten and never invoked. Apply WithStorageVersionPrecondition explicitly inside kcp's custom BuildHandlerChainFunc, always enabled. This ensures write requests to resources whose storage versions have not yet converged across all kcp shards are blocked during rolling upgrades — consistent with upstream Kubernetes behaviour. The middleware wraps the API handler before the authz chain and relies on WithRequestInfo from DefaultBuildHandlerChainFromStartToBeforeImpersonation being present in the outer chain at request time. Ref: kcp-dev/kubernetes#185 Signed-off-by: mjudeikis-bot <mjudeikis-bot@faros.sh> Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Co-authored-by: Hex (AI) <hex@faros.sh>
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
|
Follow-up on
genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPreconditionThis confirms the function is used as a full The fix remains: revert to |
|
Follow-up with concrete evidence for the
genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPreconditionSo it is used as a full The fix is straightforward — revert that one line back to return DefaultBuildHandlerChain(handler, c) |
|
Follow-up on
if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.StorageVersionAPI) &&
utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerIdentity) {
genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPrecondition
}This assigns the function directly as Fix: revert this one line back to func BuildHandlerChainWithStorageVersionPrecondition(apiHandler http.Handler, c *Config) http.Handler {
handler := genericapifilters.WithStorageVersionPrecondition(apiHandler, c.StorageVersionManager, c.Serializer)
return DefaultBuildHandlerChain(handler, c)
} |
What this PR does / why we need it:
Rebase to Kubernetes 1.35.1
Which issue(s) this PR is related to:
xref kcp-dev/kcp#3813
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: