Skip to content

Commit d9a41be

Browse files
authored
Merge pull request #3615 from SimonTheLeg/finalizing-workspace
Add terminating virtualworkspace
2 parents e741bb5 + 1d3257e commit d9a41be

File tree

44 files changed

+2310
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2310
-35
lines changed

config/crds/core.kcp.io_logicalclusters.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ spec:
119119
- resource
120120
- uid
121121
type: object
122+
terminators:
123+
description: |-
124+
Terminators are set on creation by the system and copied to status when
125+
termination starts.
126+
items:
127+
description: |-
128+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
129+
terminator controller.
130+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
131+
type: string
132+
type: array
122133
type: object
123134
status:
124135
default: {}
@@ -197,6 +208,18 @@ spec:
197208
- Ready
198209
- Unavailable
199210
type: string
211+
terminators:
212+
description: |-
213+
Terminators are set on creation by the system and must be cleared
214+
by a controller before the logical cluster can be deleted. The LogicalCluster object
215+
will stay in the phase "Deleting" until all terminator are cleared.
216+
items:
217+
description: |-
218+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
219+
terminator controller.
220+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
221+
type: string
222+
type: array
200223
type: object
201224
type: object
202225
served: true

config/crds/tenancy.kcp.io_workspaces.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,17 @@ spec:
299299
- Ready
300300
- Unavailable
301301
type: string
302+
terminators:
303+
description: |-
304+
terminators must be cleared by a controller before the workspace is being
305+
deleted.
306+
items:
307+
description: |-
308+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
309+
terminator controller.
310+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
311+
type: string
312+
type: array
302313
type: object
303314
required:
304315
- spec

config/crds/tenancy.kcp.io_workspacetypes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ spec:
249249
minItems: 1
250250
type: array
251251
type: object
252+
terminator:
253+
description: |-
254+
Terminator determines if this WorkspaceType has an associated terminating
255+
controller. These controllers are used to add functionality to a Workspace;
256+
all controllers must finish their work before the Workspace is being deleted.
257+
258+
One terminating controller is supported per WorkspaceType; the identifier
259+
for this terminator will be a colon-delimited string using the workspace in which
260+
the WorkspaceType is defined, and the type's name. For example, if a
261+
WorkspaceType `example` is created in the `root:org` workspace, the implicit
262+
terminator name is `root:org:example`.
263+
type: boolean
252264
type: object
253265
status:
254266
description: WorkspaceTypeStatus defines the observed state of WorkspaceType.

config/root-phase0/apiexport-tenancy.kcp.io.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ spec:
1414
crd: {}
1515
- group: tenancy.kcp.io
1616
name: workspaces
17-
schema: v250421-25d98218b.workspaces.tenancy.kcp.io
17+
schema: v251015-1d163d0e5.workspaces.tenancy.kcp.io
1818
storage:
1919
crd: {}
2020
- group: tenancy.kcp.io
2121
name: workspacetypes
22-
schema: v250806-4c99c4583.workspacetypes.tenancy.kcp.io
22+
schema: v251015-1d163d0e5.workspacetypes.tenancy.kcp.io
2323
storage:
2424
crd: {}
2525
status: {}

config/root-phase0/apiresourceschema-logicalclusters.core.kcp.io.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
22
kind: APIResourceSchema
33
metadata:
44
creationTimestamp: null
5-
name: v241020-fce06d31d.logicalclusters.core.kcp.io
5+
name: v251016-6e24e0d49.logicalclusters.core.kcp.io
66
spec:
77
group: core.kcp.io
88
names:
@@ -117,6 +117,17 @@ spec:
117117
- resource
118118
- uid
119119
type: object
120+
terminators:
121+
description: |-
122+
Terminators are set on creation by the system and copied to status when
123+
termination starts.
124+
items:
125+
description: |-
126+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
127+
terminator controller.
128+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
129+
type: string
130+
type: array
120131
type: object
121132
status:
122133
default: {}
@@ -195,6 +206,18 @@ spec:
195206
- Ready
196207
- Unavailable
197208
type: string
209+
terminators:
210+
description: |-
211+
Terminators are set on creation by the system and must be cleared
212+
by a controller before the logical cluster can be deleted. The LogicalCluster object
213+
will stay in the phase "Deleting" until all terminator are cleared.
214+
items:
215+
description: |-
216+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
217+
terminator controller.
218+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
219+
type: string
220+
type: array
198221
type: object
199222
type: object
200223
served: true

config/root-phase0/apiresourceschema-workspaces.tenancy.kcp.io.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
22
kind: APIResourceSchema
33
metadata:
44
creationTimestamp: null
5-
name: v250421-25d98218b.workspaces.tenancy.kcp.io
5+
name: v251015-1d163d0e5.workspaces.tenancy.kcp.io
66
spec:
77
group: tenancy.kcp.io
88
names:
@@ -297,6 +297,17 @@ spec:
297297
- Ready
298298
- Unavailable
299299
type: string
300+
terminators:
301+
description: |-
302+
terminators must be cleared by a controller before the workspace is being
303+
deleted.
304+
items:
305+
description: |-
306+
LogicalClusterTerminator is a unique string corresponding to a logical cluster
307+
terminator controller.
308+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(:[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[a-z0-9][a-z0-9]([-a-z0-9]*[a-z0-9])?))|(system:.+)$
309+
type: string
310+
type: array
300311
type: object
301312
required:
302313
- spec

config/root-phase0/apiresourceschema-workspacetypes.tenancy.kcp.io.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
22
kind: APIResourceSchema
33
metadata:
44
creationTimestamp: null
5-
name: v250806-4c99c4583.workspacetypes.tenancy.kcp.io
5+
name: v251015-1d163d0e5.workspacetypes.tenancy.kcp.io
66
spec:
77
group: tenancy.kcp.io
88
names:
@@ -247,6 +247,18 @@ spec:
247247
minItems: 1
248248
type: array
249249
type: object
250+
terminator:
251+
description: |-
252+
Terminator determines if this WorkspaceType has an associated terminating
253+
controller. These controllers are used to add functionality to a Workspace;
254+
all controllers must finish their work before the Workspace is being deleted.
255+
256+
One terminating controller is supported per WorkspaceType; the identifier
257+
for this terminator will be a colon-delimited string using the workspace in which
258+
the WorkspaceType is defined, and the type's name. For example, if a
259+
WorkspaceType `example` is created in the `root:org` workspace, the implicit
260+
terminator name is `root:org:example`.
261+
type: boolean
250262
type: object
251263
status:
252264
description: WorkspaceTypeStatus defines the observed state of WorkspaceType.

pkg/admission/logicalcluster/admission.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ func (o *plugin) Admit(ctx context.Context, a admission.Attributes, _ admission.
111111

112112
logicalCluster.Status.Initializers = logicalCluster.Spec.Initializers
113113

114+
logicalCluster.Status.Terminators = logicalCluster.Spec.Terminators
115+
114116
return updateUnstructured(u, logicalCluster)
115117
}
116118

pkg/openapi/zz_generated.openapi.go

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/reconciler/core/logicalcluster/logicalcluster_reconcile.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ type reconciler interface {
3636
}
3737

3838
func (c *Controller) reconcile(ctx context.Context, logicalCluster *corev1alpha1.LogicalCluster) (bool, error) {
39+
// reconcilers which modify Status should be last
40+
// reconcilers which modify ObjectMeta, need to return reconcileStatusStopAndRequeue on change
3941
reconcilers := []reconciler{
4042
&metaDataReconciler{},
43+
&terminatorReconciler{},
4144
&phaseReconciler{},
4245
&urlReconciler{shardExternalURL: c.shardExternalURL},
4346
}

0 commit comments

Comments
 (0)