Skip to content

Commit eaa52a9

Browse files
committed
Disable APIExport VW urls
Signed-off-by: Mangirdas Judeikis <Mangirdas@Judeikis.LT> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent 7814220 commit eaa52a9

9 files changed

+74
-299
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apis.kcp.io/v1alpha1
2+
kind: APIExportEndpointSlice
3+
metadata:
4+
name: shards.core.kcp.io
5+
spec:
6+
export:
7+
name: shards.core.kcp.io
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apis.kcp.io/v1alpha1
2+
kind: APIExportEndpointSlice
3+
metadata:
4+
name: tenancy.kcp.io
5+
spec:
6+
export:
7+
name: tenancy.kcp.io
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apis.kcp.io/v1alpha1
2+
kind: APIExportEndpointSlice
3+
metadata:
4+
name: topology.kcp.io
5+
spec:
6+
export:
7+
name: topology.kcp.io

pkg/features/kcp_features.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ const (
4242
// alpha: v0.1
4343
// Enables workspace mounts via frontProxy.
4444
WorkspaceMounts featuregate.Feature = "WorkspaceMounts"
45+
46+
// owner: @mjudeikis
47+
// alpha: v0.1
48+
// Enables Poplaing VirtualWorkspace urls on APIExport. This enables to use Deprecated APIExport VirtualWorkspace urls.
49+
// This is a temporary feature to ease the migration to the new VirtualWorkspace urls.
50+
EnableDeprecatedAPIExportVirtualWorkspacesUrls featuregate.Feature = "EnableDeprecatedAPIExportVirtualWorkspacesUrls"
4551
)
4652

4753
// DefaultFeatureGate exposes the upstream feature gate, but with our gate setting applied.
@@ -112,7 +118,9 @@ var defaultVersionedGenericControlPlaneFeatureGates = map[featuregate.Feature]fe
112118
WorkspaceMounts: {
113119
{Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Alpha},
114120
},
115-
121+
EnableDeprecatedAPIExportVirtualWorkspacesUrls: {
122+
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
123+
},
116124
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
117125
// unintentionally on either side:
118126

pkg/reconciler/apis/apiexport/apiexport_controller_test.go

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ func TestReconcile(t *testing.T) {
5252

5353
apiBindings []interface{}
5454

55-
wantGenerationFailed bool
56-
wantError bool
57-
wantCreateSecretCalled bool
58-
wantUnsetIdentity bool
59-
wantDefaultSecretRef bool
60-
wantStatusHashSet bool
61-
wantVerifyFailure bool
62-
wantIdentityValid bool
63-
wantVirtualWorkspaceURLsError bool
64-
wantVirtualWorkspaceURLsReady bool
55+
wantGenerationFailed bool
56+
wantError bool
57+
wantCreateSecretCalled bool
58+
wantUnsetIdentity bool
59+
wantDefaultSecretRef bool
60+
wantStatusHashSet bool
61+
wantVerifyFailure bool
62+
wantIdentityValid bool
6563
}{
6664
"create secret when ref is nil and secret doesn't exist": {
6765
secretExists: false,
@@ -122,8 +120,7 @@ func TestReconcile(t *testing.T) {
122120
apiBindings: []interface{}{
123121
"something",
124122
},
125-
listShardsError: errors.New("foo"),
126-
wantVirtualWorkspaceURLsError: true,
123+
listShardsError: errors.New("foo"),
127124
},
128125
"virtualWorkspaceURLs set when APIBindings present": {
129126
secretRefSet: true,
@@ -135,7 +132,6 @@ func TestReconcile(t *testing.T) {
135132
apiBindings: []interface{}{
136133
"something",
137134
},
138-
wantVirtualWorkspaceURLsReady: true,
139135
},
140136
}
141137

@@ -287,21 +283,6 @@ func TestReconcile(t *testing.T) {
287283
if tc.wantIdentityValid {
288284
requireConditionMatches(t, apiExport, conditions.TrueCondition(apisv1alpha2.APIExportIdentityValid))
289285
}
290-
291-
if tc.wantVirtualWorkspaceURLsError {
292-
requireConditionMatches(t, apiExport,
293-
conditions.FalseCondition(
294-
apisv1alpha2.APIExportVirtualWorkspaceURLsReady,
295-
apisv1alpha2.ErrorGeneratingURLsReason,
296-
conditionsv1alpha1.ConditionSeverityError,
297-
"",
298-
),
299-
)
300-
}
301-
302-
if tc.wantVirtualWorkspaceURLsReady {
303-
requireConditionMatches(t, apiExport, conditions.TrueCondition(apisv1alpha2.APIExportVirtualWorkspaceURLsReady))
304-
}
305286
})
306287
}
307288
}

pkg/reconciler/apis/apiexport/apiexport_reconcile.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/kcp-dev/logicalcluster/v3"
3232

3333
virtualworkspacesoptions "github.com/kcp-dev/kcp/cmd/virtual-workspaces/options"
34+
kcpfeatures "github.com/kcp-dev/kcp/pkg/features"
3435
"github.com/kcp-dev/kcp/pkg/logging"
3536
apiexportbuilder "github.com/kcp-dev/kcp/pkg/virtual/apiexport/builder"
3637
apisv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
@@ -111,15 +112,18 @@ func (c *controller) reconcile(ctx context.Context, apiExport *apisv1alpha2.APIE
111112
}
112113
*/
113114

114-
if err := c.updateVirtualWorkspaceURLs(ctx, apiExport); err != nil {
115-
conditions.MarkFalse(
116-
apiExport,
117-
apisv1alpha2.APIExportVirtualWorkspaceURLsReady,
118-
apisv1alpha2.ErrorGeneratingURLsReason,
119-
conditionsv1alpha1.ConditionSeverityError,
120-
"%v",
121-
err,
122-
)
115+
// TODO(mjudeikis): Remove this and move to batteries.
116+
if kcpfeatures.DefaultFeatureGate.Enabled(kcpfeatures.EnableDeprecatedAPIExportVirtualWorkspacesUrls) {
117+
if err := c.updateVirtualWorkspaceURLs(ctx, apiExport); err != nil {
118+
conditions.MarkFalse(
119+
apiExport,
120+
apisv1alpha2.APIExportVirtualWorkspaceURLsReady,
121+
apisv1alpha2.ErrorGeneratingURLsReason,
122+
conditionsv1alpha1.ConditionSeverityError,
123+
"%v",
124+
err,
125+
)
126+
}
123127
}
124128

125129
return nil

pkg/reconciler/tenancy/workspacetype/workspacetype_controller_reconcile.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"k8s.io/klog/v2"
2727

2828
virtualworkspacesoptions "github.com/kcp-dev/kcp/cmd/virtual-workspaces/options"
29+
kcpfeatures "github.com/kcp-dev/kcp/pkg/features"
2930
"github.com/kcp-dev/kcp/pkg/virtual/initializingworkspaces"
3031
"github.com/kcp-dev/kcp/sdk/apis/tenancy/initialization"
3132
tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1"
@@ -34,22 +35,23 @@ import (
3435
)
3536

3637
func (c *controller) reconcile(ctx context.Context, wt *tenancyv1alpha1.WorkspaceType) {
37-
if err := c.updateVirtualWorkspaceURLs(ctx, wt); err != nil {
38-
conditions.MarkFalse(
39-
wt,
40-
tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady,
41-
tenancyv1alpha1.ErrorGeneratingURLsReason,
42-
conditionsv1alpha1.ConditionSeverityError,
43-
"%v",
44-
err,
45-
)
46-
} else {
47-
conditions.MarkTrue(
48-
wt,
49-
tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady,
50-
)
38+
if kcpfeatures.DefaultFeatureGate.Enabled(kcpfeatures.EnableDeprecatedAPIExportVirtualWorkspacesUrls) {
39+
if err := c.updateVirtualWorkspaceURLs(ctx, wt); err != nil {
40+
conditions.MarkFalse(
41+
wt,
42+
tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady,
43+
tenancyv1alpha1.ErrorGeneratingURLsReason,
44+
conditionsv1alpha1.ConditionSeverityError,
45+
"%v",
46+
err,
47+
)
48+
} else {
49+
conditions.MarkTrue(
50+
wt,
51+
tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady,
52+
)
53+
}
5154
}
52-
5355
conditions.SetSummary(wt)
5456
}
5557

0 commit comments

Comments
 (0)