Skip to content

Commit 0542a42

Browse files
committed
Review comments
1 parent 72e80d3 commit 0542a42

File tree

12 files changed

+45
-19
lines changed

12 files changed

+45
-19
lines changed

config/crds/tenancy.kcp.io_workspaces.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ spec:
4848
depending on access pattern. All workspace implementations share the characteristic
4949
that the URL that serves a given workspace can be used with standard Kubernetes
5050
API machinery and client libraries and command line tools.
51+
52+
Workspaces supports mounting, by specifying an Mount object in the spec.
53+
If a Mount is specified, the workspace will be mounted to the specified mount object and
54+
LogicalCluster will not be created.
5155
properties:
5256
apiVersion:
5357
description: |-
@@ -149,7 +153,7 @@ spec:
149153
type: object
150154
mount:
151155
description: |-
152-
Mount is a reference to a an object implementing a mounting feature. It is used to orchestrate
156+
Mount is a reference to an object implementing a mounting feature. It is used to orchestrate
153157
where the traffic, intended for the workspace, is sent.
154158
If specified, logicalcluster will not be created and the workspace will be mounted
155159
using reference mount object.
@@ -186,6 +190,9 @@ spec:
186190
required:
187191
- ref
188192
type: object
193+
x-kubernetes-validations:
194+
- message: mount is immutable
195+
rule: self == oldSelf
189196
type:
190197
description: |-
191198
type defines properties of the workspace both on creation (e.g. initial

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
resources:
1010
- group: tenancy.kcp.io
1111
name: workspaces
12-
schema: v250315-28b43d5a9.workspaces.tenancy.kcp.io
12+
schema: v250421-25d98218b.workspaces.tenancy.kcp.io
1313
storage:
1414
crd: {}
1515
- group: tenancy.kcp.io

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

Lines changed: 9 additions & 2 deletions
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: v250315-28b43d5a9.workspaces.tenancy.kcp.io
5+
name: v250421-25d98218b.workspaces.tenancy.kcp.io
66
spec:
77
group: tenancy.kcp.io
88
names:
@@ -46,6 +46,10 @@ spec:
4646
depending on access pattern. All workspace implementations share the characteristic
4747
that the URL that serves a given workspace can be used with standard Kubernetes
4848
API machinery and client libraries and command line tools.
49+
50+
Workspaces supports mounting, by specifying an Mount object in the spec.
51+
If a Mount is specified, the workspace will be mounted to the specified mount object and
52+
LogicalCluster will not be created.
4953
properties:
5054
apiVersion:
5155
description: |-
@@ -147,7 +151,7 @@ spec:
147151
type: object
148152
mount:
149153
description: |-
150-
Mount is a reference to a an object implementing a mounting feature. It is used to orchestrate
154+
Mount is a reference to an object implementing a mounting feature. It is used to orchestrate
151155
where the traffic, intended for the workspace, is sent.
152156
If specified, logicalcluster will not be created and the workspace will be mounted
153157
using reference mount object.
@@ -184,6 +188,9 @@ spec:
184188
required:
185189
- ref
186190
type: object
191+
x-kubernetes-validations:
192+
- message: mount is immutable
193+
rule: self == oldSelf
187194
type:
188195
description: |-
189196
type defines properties of the workspace both on creation (e.g. initial

pkg/admission/workspace/admission.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (o *workspace) Validate(ctx context.Context, a admission.Attributes, _ admi
166166
}
167167

168168
// Not a mountpoint - validate the spec fields
169-
if !old.Spec.IsMounted() {
169+
if old.Spec.Mount == nil {
170170
if old.Spec.Cluster != "" && ws.Spec.Cluster == "" {
171171
return admission.NewForbidden(a, errors.New("spec.cluster cannot be unset"))
172172
}
@@ -257,7 +257,7 @@ func (o *workspace) Validate(ctx context.Context, a admission.Attributes, _ admi
257257
}
258258
}
259259

260-
if ws.Spec.IsMounted() {
260+
if ws.Spec.Mount != nil {
261261
if ws.Spec.Mount.Reference.Kind == "" {
262262
return admission.NewForbidden(a, errors.New("spec.mount.kind must be set"))
263263
}

pkg/index/index.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,17 @@ func (c *State) DeleteWorkspace(shard string, ws *tenancyv1alpha1.Workspace) {
183183
delete(c.shardClusterWorkspaceMount[shard][clusterName], ws.Name)
184184
if len(c.shardClusterWorkspaceMount[shard][clusterName]) == 0 {
185185
delete(c.shardClusterWorkspaceMount[shard], clusterName)
186+
if len(c.shardClusterWorkspaceMount[shard]) == 0 {
187+
delete(c.shardClusterWorkspaceName, shard)
188+
}
186189
}
187190
}
188191
delete(c.shardClusterWorkspaceNameErrorCode[shard][clusterName], ws.Name)
189192
if len(c.shardClusterWorkspaceNameErrorCode[shard][clusterName]) == 0 {
190193
delete(c.shardClusterWorkspaceNameErrorCode[shard], clusterName)
194+
if len(c.shardClusterWorkspaceNameErrorCode[shard]) == 0 {
195+
delete(c.shardClusterWorkspaceNameErrorCode, shard)
196+
}
191197
}
192198
}
193199

pkg/openapi/zz_generated.openapi.go

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

pkg/reconciler/tenancy/workspace/workspace_reconcile_metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type metaDataReconciler struct {
3232

3333
func (r *metaDataReconciler) reconcile(ctx context.Context, workspace *tenancyv1alpha1.Workspace) (reconcileStatus, error) {
3434
logger := klog.FromContext(ctx).WithValues("reconciler", "metadata")
35-
if workspace.Spec.IsMounted() {
35+
if workspace.Spec.Mount != nil {
3636
return reconcileStatusContinue, nil
3737
}
3838

pkg/reconciler/tenancy/workspace/workspace_reconcile_phase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type phaseReconciler struct {
4242
func (r *phaseReconciler) reconcile(ctx context.Context, workspace *tenancyv1alpha1.Workspace) (reconcileStatus, error) {
4343
logger := klog.FromContext(ctx).WithValues("reconciler", "phase")
4444

45-
if !workspace.Spec.IsMounted() {
45+
if workspace.Spec.Mount == nil {
4646
switch workspace.Status.Phase {
4747
case corev1alpha1.LogicalClusterPhaseScheduling:
4848
if workspace.Spec.URL != "" && workspace.Spec.Cluster != "" {

pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type schedulingReconciler struct {
8383

8484
func (r *schedulingReconciler) reconcile(ctx context.Context, workspace *tenancyv1alpha1.Workspace) (reconcileStatus, error) {
8585
logger := klog.FromContext(ctx).WithValues("reconciler", "scheduling")
86-
if workspace.Spec.IsMounted() {
86+
if workspace.Spec.Mount != nil {
8787
return reconcileStatusContinue, nil
8888
}
8989

pkg/reconciler/tenancy/workspacemounts/workspacemounts_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ func (c *Controller) process(ctx context.Context, key string) (bool, error) {
207207
} else {
208208
gvr.Version = ref.APIVersion
209209
}
210+
if ref.Namespace != "" {
211+
return c.dynamicClusterClient.Cluster(cluster).Resource(gvr).Namespace(ref.Namespace).Get(ctx, ref.Name, metav1.GetOptions{})
212+
}
210213
return c.dynamicClusterClient.Cluster(cluster).Resource(gvr).Get(ctx, ref.Name, metav1.GetOptions{})
211214
}
212215

0 commit comments

Comments
 (0)