Skip to content

Commit ef88694

Browse files
authored
Merge pull request kubernetes#80978 from wojtek-t/selflink_deprecation
Deprecate SelfLink and introduce feature gate to disable its propagation
2 parents 6d49d69 + f0a8aec commit ef88694

File tree

14 files changed

+67
-94
lines changed

14 files changed

+67
-94
lines changed

api/openapi-spec/swagger.json

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

pkg/controller/volume/scheduling/scheduler_binder_test.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ var (
5353
boundPVC = makeTestPVC("bound-pvc", "1G", "", pvcBound, "pv-bound", "1", &waitClass)
5454
boundPVC2 = makeTestPVC("bound-pvc2", "1G", "", pvcBound, "pv-bound2", "1", &waitClass)
5555
boundPVCNode1a = makeTestPVC("unbound-pvc", "1G", "", pvcBound, "pv-node1a", "1", &waitClass)
56-
badPVC = makeBadPVC()
5756
immediateUnboundPVC = makeTestPVC("immediate-unbound-pvc", "1G", "", pvcUnbound, "", "1", &immediateClass)
5857
immediateBoundPVC = makeTestPVC("immediate-bound-pvc", "1G", "", pvcBound, "pv-bound-immediate", "1", &immediateClass)
5958

@@ -556,28 +555,6 @@ func makeTestPVC(name, size, node string, pvcBoundState int, pvName, resourceVer
556555
return pvc
557556
}
558557

559-
func makeBadPVC() *v1.PersistentVolumeClaim {
560-
fs := v1.PersistentVolumeFilesystem
561-
return &v1.PersistentVolumeClaim{
562-
ObjectMeta: metav1.ObjectMeta{
563-
Name: "bad-pvc",
564-
Namespace: "testns",
565-
UID: types.UID("pvc-uid"),
566-
ResourceVersion: "1",
567-
// Don't include SefLink, so that GetReference will fail
568-
},
569-
Spec: v1.PersistentVolumeClaimSpec{
570-
Resources: v1.ResourceRequirements{
571-
Requests: v1.ResourceList{
572-
v1.ResourceName(v1.ResourceStorage): resource.MustParse("1G"),
573-
},
574-
},
575-
StorageClassName: &waitClass,
576-
VolumeMode: &fs,
577-
},
578-
}
579-
}
580-
581558
func makeTestPV(name, node, capacity, version string, boundToPVC *v1.PersistentVolumeClaim, className string) *v1.PersistentVolume {
582559
fs := v1.PersistentVolumeFilesystem
583560
pv := &v1.PersistentVolume{
@@ -1046,12 +1023,6 @@ func TestAssumePodVolumes(t *testing.T) {
10461023
expectedBindings: []*bindingInfo{makeBinding(unboundPVC, pvNode1aBound)},
10471024
expectedProvisionings: []*v1.PersistentVolumeClaim{},
10481025
},
1049-
"claimref-failed": {
1050-
podPVCs: []*v1.PersistentVolumeClaim{unboundPVC},
1051-
bindings: []*bindingInfo{makeBinding(unboundPVC, pvNode1a), makeBinding(badPVC, pvNode1b)},
1052-
pvs: []*v1.PersistentVolume{pvNode1a, pvNode1b},
1053-
shouldFail: true,
1054-
},
10551026
"tmpupdate-failed": {
10561027
podPVCs: []*v1.PersistentVolumeClaim{unboundPVC},
10571028
bindings: []*bindingInfo{makeBinding(unboundPVC, pvNode1a), makeBinding(unboundPVC2, pvNode1b)},

pkg/kubelet/container/ref_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ func TestGenerateContainerRef(t *testing.T) {
132132
},
133133
success: true,
134134
},
135-
{
136-
name: "no-selflink",
137-
pod: &noSelfLinkPod,
138-
container: &v1.Container{},
139-
expected: nil,
140-
success: false,
141-
},
142135
{
143136
name: "defaulted-selflink",
144137
pod: &defaultedSelfLinkPod,

staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go

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

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto

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

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/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go

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

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)