Skip to content

[WIP] Rebase to Kubernetes 1.35.1#185

Closed
xmudrii wants to merge 60 commits intokcp-dev:kcp-1.35.1-baselinefrom
xmudrii:kcp-1.35.1
Closed

[WIP] Rebase to Kubernetes 1.35.1#185
xmudrii wants to merge 60 commits intokcp-dev:kcp-1.35.1-baselinefrom
xmudrii:kcp-1.35.1

Conversation

@xmudrii
Copy link
Copy Markdown
Member

@xmudrii xmudrii commented Feb 13, 2026

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?

Rebase to Kubernetes 1.35.1

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


sttts and others added 3 commits February 12, 2026 14:31
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>
sttts and others added 26 commits March 5, 2026 13:12
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>
sttts and others added 9 commits March 5, 2026 13:12
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>
@xmudrii xmudrii force-pushed the kcp-1.35.1 branch 2 times, most recently from 02a3801 to ec6856f Compare March 11, 2026 08:18
@kcp-ci-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign deads2k, liggitt, logicalhan for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}
err := s.decoder.Decode(value, objPtr, rev)
if err != nil {
spew.Dump(err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is left over

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be from my previous rebase :/

Copy link
Copy Markdown

@mjudeikis-bot mjudeikis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 != nil that 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 chain

to:

return DefaultBuildHandlerChainFromAuthzToCompletion(handler, c) // inner part only

This 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 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. If migration is still in progress: remove the panics, replace with a TODO.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment code is wrong but issue is real

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread staging/src/k8s.io/apiserver/pkg/server/config.go
Comment on lines +74 to +75
//var _ = initializer.WantsExternalKubeInformerFactory(&Lifecycle{})
//var _ = initializer.WantsExternalKubeClientSet(&Lifecycle{})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intended?

Copy link
Copy Markdown
Member Author

@xmudrii xmudrii Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjudeikis It has been there even before rebase:

//var _ = initializer.WantsExternalKubeInformerFactory(&Lifecycle{})
//var _ = initializer.WantsExternalKubeClientSet(&Lifecycle{})

@mjudeikis-bot
Copy link
Copy Markdown

Re: my comment on BuildHandlerChainWithStorageVersionPrecondition — withdrawing that concern.

Checked against kcp-1.34.2: this function calls DefaultBuildHandlerChainFromAuthzToCompletion there too. It is intentional — the storage version precondition handler sits between the outer (auth/impersonation) and inner (authz→completion) chain segments. The full chain is assembled by kcp server setup which calls all three parts separately. Not a bug.

@mjudeikis-bot
Copy link
Copy Markdown

Re the BuildHandlerChainWithStorageVersionPrecondition change (ref: #185 (comment)):

This looks incorrect — changing DefaultBuildHandlerChainDefaultBuildHandlerChainFromAuthzToCompletion breaks the function.

WithRequestInfo lives inside DefaultBuildHandlerChainFromStartToBeforeImpersonation. The comment right above the function says "WithStorageVersionPrecondition needs the WithRequestInfo to run first" — but by calling only DefaultBuildHandlerChainFromAuthzToCompletion, we skip the outer layer entirely. The resulting chain would be missing:

  • WithRequestInfo
  • Authentication
  • Audit
  • CORS / tracing / timeout / impersonation / priority-and-fairness

BuildHandlerChainWithStorageVersionPrecondition is used as a BuildHandlerChainFunc replacement — it must produce a complete chain.

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 BuildHandlerChainWithStorageVersionPrecondition should keep calling DefaultBuildHandlerChain (which now internally delegates to all three in the right order).

@mjudeikis-bot
Copy link
Copy Markdown

Follow-up on BuildHandlerChainWithStorageVersionPrecondition (ref my previous comment):

Checked where this function is actually used: it is only assigned to genericConfig.BuildHandlerChainFunc when both StorageVersionAPI and APIServerIdentity feature gates are enabled (aggregator.go). kcp does not reference either of these feature gates — zero hits in kcp-dev/kcp. So this code path is effectively dead in kcp and the FromAuthzToCompletion-only behavior has no practical impact.

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.

@mjudeikis-bot
Copy link
Copy Markdown

Suggesting a code comment on BuildHandlerChainWithStorageVersionPrecondition to document the kcp architecture decision:

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)
}

mjudeikis-bot pushed a commit to mjudeikis-bot/kcp that referenced this pull request Mar 12, 2026
…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>
mjudeikis-bot pushed a commit to mjudeikis-bot/kcp that referenced this pull request Mar 12, 2026
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>
@xmudrii xmudrii closed this Mar 12, 2026
@mjudeikis-bot
Copy link
Copy Markdown

Follow-up on BuildHandlerChainWithStorageVersionPrecondition (adding concrete evidence):

pkg/controlplane/apiserver/aggregator.go:77 sets:

genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPrecondition

This confirms the function is used as a full BuildHandlerChainFunc replacement. With the current PR calling only DefaultBuildHandlerChainFromAuthzToCompletion, the aggregator server would start missing authentication, audit, impersonation, and all other outer middleware.

The fix remains: revert to DefaultBuildHandlerChain(handler, c) in that function.

@mjudeikis-bot
Copy link
Copy Markdown

Follow-up with concrete evidence for the BuildHandlerChainWithStorageVersionPrecondition issue:

pkg/controlplane/apiserver/aggregator.go:77 sets:

genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPrecondition

So it is used as a full BuildHandlerChainFunc replacement for the aggregator server. With the current PR calling only DefaultBuildHandlerChainFromAuthzToCompletion, the aggregator would start with no authentication, no impersonation, no audit, no priority-and-fairness.

The fix is straightforward — revert that one line back to DefaultBuildHandlerChain:

return DefaultBuildHandlerChain(handler, c)

@mjudeikis-bot
Copy link
Copy Markdown

Follow-up on BuildHandlerChainWithStorageVersionPrecondition — confirmed the bug with a concrete callsite.

pkg/controlplane/apiserver/aggregator.go (line ~77):

if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.StorageVersionAPI) &&
    utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerIdentity) {
    genericConfig.BuildHandlerChainFunc = genericapiserver.BuildHandlerChainWithStorageVersionPrecondition
}

This assigns the function directly as BuildHandlerChainFunc — the full chain builder for the aggregator server. With the current PR code returning only DefaultBuildHandlerChainFromAuthzToCompletion, the aggregator would run without authentication, audit, impersonation, priority-and-fairness, etc. when both feature gates are enabled.

Fix: revert this one line back to DefaultBuildHandlerChain:

func BuildHandlerChainWithStorageVersionPrecondition(apiHandler http.Handler, c *Config) http.Handler {
	handler := genericapifilters.WithStorageVersionPrecondition(apiHandler, c.StorageVersionManager, c.Serializer)
	return DefaultBuildHandlerChain(handler, c)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants