Skip to content

Commit 3bf4eb7

Browse files
committed
Deprecate SelfLink + featuregate for setting it
1 parent 399d09c commit 3bf4eb7

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ type ListMeta struct {
6161
// selfLink is a URL representing this object.
6262
// Populated by the system.
6363
// Read-only.
64+
//
65+
// DEPRECATED
66+
// Kubernetes will stop propagating this field in 1.20 release and the field is planned
67+
// to be removed in 1.21 release.
6468
// +optional
6569
SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,1,opt,name=selfLink"`
6670

@@ -148,6 +152,10 @@ type ObjectMeta struct {
148152
// SelfLink is a URL representing this object.
149153
// Populated by the system.
150154
// Read-only.
155+
//
156+
// DEPRECATED
157+
// Kubernetes will stop propagating this field in 1.20 release and the field is planned
158+
// to be removed in 1.21 release.
151159
// +optional
152160
SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,4,opt,name=selfLink"`
153161

staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,7 @@ func PatchResource(r rest.Patcher, scope *RequestScope, admit admission.Interfac
224224
}
225225
trace.Step("Object stored in database")
226226

227-
requestInfo, ok := request.RequestInfoFrom(ctx)
228-
if !ok {
229-
scope.err(fmt.Errorf("missing requestInfo"), w, req)
230-
return
231-
}
232-
if err := setSelfLink(result, requestInfo, scope.Namer); err != nil {
227+
if err := setObjectSelfLink(ctx, result, req, scope.Namer); err != nil {
233228
scope.err(err, w, req)
234229
return
235230
}

staging/src/k8s.io/apiserver/pkg/endpoints/handlers/rest.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ import (
3939
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
4040
"k8s.io/apiserver/pkg/endpoints/metrics"
4141
"k8s.io/apiserver/pkg/endpoints/request"
42+
"k8s.io/apiserver/pkg/features"
4243
"k8s.io/apiserver/pkg/registry/rest"
44+
utilfeature "k8s.io/apiserver/pkg/util/feature"
4345
"k8s.io/klog"
4446
)
4547

@@ -318,6 +320,10 @@ func checkName(obj runtime.Object, name, namespace string, namer ScopeNamer) err
318320
// TODO: remove the need for the namer LinkSetters by requiring objects implement either Object or List
319321
// interfaces
320322
func setObjectSelfLink(ctx context.Context, obj runtime.Object, req *http.Request, namer ScopeNamer) error {
323+
if utilfeature.DefaultFeatureGate.Enabled(features.RemoveSelfLink) {
324+
return nil
325+
}
326+
321327
// We only generate list links on objects that implement ListInterface - historically we duck typed this
322328
// check via reflection, but as we move away from reflection we require that you not only carry Items but
323329
// ListMeta into order to be identified as a list.

staging/src/k8s.io/apiserver/pkg/features/kube_features.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ const (
132132
//
133133
// Enables managing request concurrency with prioritization and fairness at each server
134134
RequestManagement featuregate.Feature = "RequestManagement"
135+
136+
// owner: @wojtek-t
137+
// alpha: v1.16
138+
//
139+
// Deprecates and removes SelfLink from ObjectMeta and ListMeta.
140+
RemoveSelfLink featuregate.Feature = "RemoveSelfLink"
135141
)
136142

137143
func init() {
@@ -156,4 +162,5 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
156162
WinDSR: {Default: false, PreRelease: featuregate.Alpha},
157163
WatchBookmark: {Default: true, PreRelease: featuregate.Beta},
158164
RequestManagement: {Default: false, PreRelease: featuregate.Alpha},
165+
RemoveSelfLink: {Default: false, PreRelease: featuregate.Alpha},
159166
}

0 commit comments

Comments
 (0)