-
Notifications
You must be signed in to change notification settings - Fork 421
Add finalizing virtualworkspace #3615
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?
Conversation
[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 |
…rName This is required so we can use the LogicalClusterFinalizer as a custom string type like we do it with LogicalClusterInitializer On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
…urls" This reverts commit 623580d.
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
564fb45
to
0eb0bc1
Compare
0400091
to
d46891c
Compare
Getting the ball rolling on the discussion items:
|
0dc7d81
to
c2ecefe
Compare
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
c2ecefe
to
73b07b0
Compare
/test pull-kcp-test-e2e-shared |
Im somehow tempted to say - let's use the same behaviour - patch status. Feels like the finalisers field should be protected from user modification here. And If we agree otherwise, I would make the same change to both virtual workspaces to have consistent behaviour.
+1 on having proxy. In my head consistent sysmte beahaviour is above trying to be smart :) |
} | ||
|
||
// add finalizers from the status as hashed labels | ||
finalizerKeys := sets.New[string]() |
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. the hashed thing here due to .
in the name?
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.
Main motivation was to keep it consistent with how initializers do it (see code block directly above this one).
I think the idea behind this was:
kcp/sdk/apis/tenancy/initialization/utils.go
Lines 87 to 89 in 459fa3b
// InitializerToLabel transforms an initializer into a key-value pair to add to a label set. We use a hash | |
// to create a unique identifier from this information, prefixing the hash in order to create a value which | |
// is unlikely to collide, and adding the full hash as a value in order to make it difficult to forge the pair. |
// LogicalClusterFinalizerName attached to the owner of the LogicalCluster resource (usually a Workspace) so that we can control | ||
// deletion of LogicalCluster resources. | ||
LogicalClusterFinalizer = "core.kcp.io/logicalcluster" | ||
LogicalClusterFinalizerName = "core.kcp.io/logicalcluster" |
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.
This could be separate PR and diff for this would be way way smaller.
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.
for next time. lets leave it for now.
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.
looks close :)
withoutRootPathPrefix := strings.TrimPrefix(urlPath, rootPathPrefix) | ||
|
||
// Incoming requests to this virtual workspace will look like: | ||
// /services/finalizingworkspace/<finalizer>/clusters/<something>/apis/workload.kcp.io/v1alpha1/synctargets |
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.
can we remove synctarget from example? :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.
Ah good old copy pasting stuff. will change it :D
// - request finalization by a specific controller | ||
// | ||
// That is, a request for | ||
// GET /services/finalizingworkspaces/<finalizer>/clusters/*/apis/core.kcp.io/v1alpha1/logicalclusters |
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.
This would change if we go proxy way? I mean we would get access to the logical cluster via similar url?
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 directly. Initializers use 3 distinct virtual workspaces under the hood to handle this:
- handles all the LIST requests (aka get
clusters/*
) - handles GET/PATCH requests to a single Logicalcluster (aka update
clusters/asdfasdfa
). I think this mainly exists so we can restrict which fields of a LogicalCluster a user can edit, because with 3., I think you can just do about anything you want with the objects - handles all other requests and proxies them straight through to kcp
But I agree that maybe this doc.go is written a bit misleading. I just copy pasted it from initializers and never looked back 😅. I'll update it to be a bit more precise once I have built virtualworkspace 3.
Let's leave this comment open for now.
|
||
// HasDeletionTimestamp returns whether a runtime.object has a deletion timestamp | ||
// wrapping the meta.Objects deletiontimestamp functionality. | ||
var HasDeletionTimestamp ObjectFilterFunc = func(ctx context.Context, obj runtime.Object) bool { |
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.
need to be public?
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.
Oh yeah that is a good point, there is no big value in exposing this and it is only a helper func for WithDeletionTimestamp
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
73b07b0
to
593e6e6
Compare
- pkg/virtual/finalizingworkspaces - sdk/apis/tenancyfinalization - test/e2e/virtual/finalizingworkspaces On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
On-behalf-of: SAP <[email protected]> Signed-off-by: Simon Bein <[email protected]>
@SimonTheLeg: The following tests 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. |
This PR adds the finalizing virtual workspace and surrounding logic. Similiar to initializers, Workspacetypes can specify having a finalizer or inherit finalizers via extends.With. These finalizers get added to the Logicalclusters and need to be removed before a logicalcluster can be fully deleted. A virtual workspace is being provided which gives access to all Logicalclusters which have the corresponding finalizer. This allows end-users to write operators with custom cleanup logic.
More details can be obtained from the docs update in this PR.
Open discussions / TODOs
metadata.finalizers
, as this has the most k8s native feel. This is also how it is implemented at the moment. This is slightly different to how initializers work, since for initializers you would remove it fromstatus.initializers
. Back then we decided that for finalizers we prefer themetadata.finalizers
approach due to ease of use. However while working on this some new facts have come to light, which make me wonder if we want to stick with this approach: The main factor is that we cannot directly use regular finalizers (e.g. "root:myworkspacetype"), as the colon:
character is not allowed in themetadata.finalizers
field. We therefore always have to convert these. Currently we simply replace the colon character with a dot (https://github.com/SimonTheLeg/kcp/blob/d46891c8d2111ce3d1e94891ab4bfcc9137d4d46/sdk/apis/tenancy/finalization/utils.go#L71-L73). However for end-users I think this is rather confusing, because they would also need to do this conversion. As a result I am wondering if it would not be better if we keep this implementation detail hidden; Essentially build it exactly like we do it for initializers and have people patch the status there and then our controller would update the metadata.finalizers field. What do you prefer?Summary
What Type of PR Is This?
/kind feature
Release Notes