Merge pull request #107527 from wojtek-t/remove_selflink_ga
Graduate RemoveSelfLink to Stable
This commit is contained in:
@@ -11,7 +11,6 @@ metadata:
|
||||
name: nginx-deployment
|
||||
namespace: test
|
||||
resourceVersion: "355959"
|
||||
selfLink: /apis/extensions/v1beta1/namespaces/test/deployments/nginx-deployment
|
||||
uid: 51ac266e-9a37-11e6-8738-0800270c4edc
|
||||
spec:
|
||||
replicas: 1
|
||||
|
||||
@@ -682,16 +682,10 @@ func TestApplyManagedFields(t *testing.T) {
|
||||
t.Fatalf("Failed to marshal object: %v", err)
|
||||
}
|
||||
|
||||
selfLink := ""
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(genericfeatures.RemoveSelfLink) {
|
||||
selfLink = `
|
||||
"selfLink": "` + accessor.GetSelfLink() + `",`
|
||||
}
|
||||
|
||||
expected := []byte(`{
|
||||
"metadata": {
|
||||
"name": "test-cm",
|
||||
"namespace": "default",` + selfLink + `
|
||||
"namespace": "default",
|
||||
"uid": "` + string(accessor.GetUID()) + `",
|
||||
"resourceVersion": "` + accessor.GetResourceVersion() + `",
|
||||
"creationTimestamp": "` + accessor.GetCreationTimestamp().UTC().Format(time.RFC3339) + `",
|
||||
@@ -2565,7 +2559,6 @@ func benchAll(b *testing.B, client kubernetes.Interface, pod v1.Pod) {
|
||||
pod.ObjectMeta.CreationTimestamp = metav1.Time{}
|
||||
pod.ObjectMeta.ResourceVersion = ""
|
||||
pod.ObjectMeta.UID = ""
|
||||
pod.ObjectMeta.SelfLink = ""
|
||||
|
||||
// Create pod for repeated-updates
|
||||
pod.Name = "repeated-pod"
|
||||
|
||||
@@ -42,13 +42,10 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
appsv1ac "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||
corev1ac "k8s.io/client-go/applyconfigurations/core/v1"
|
||||
metav1ac "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
|
||||
"k8s.io/component-base/version"
|
||||
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||
@@ -969,67 +966,6 @@ func TestMultiWatch(t *testing.T) {
|
||||
t.Errorf("durations: %v", dur)
|
||||
}
|
||||
|
||||
func runSelfLinkTestOnNamespace(t *testing.T, c clientset.Interface, namespace string) {
|
||||
podBody := v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "selflinktest",
|
||||
Namespace: namespace,
|
||||
Labels: map[string]string{
|
||||
"name": "selflinktest",
|
||||
},
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{Name: "name", Image: "image"},
|
||||
},
|
||||
},
|
||||
}
|
||||
pod, err := c.CoreV1().Pods(namespace).Create(context.TODO(), &podBody, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed creating selflinktest pod: %v", err)
|
||||
}
|
||||
if err = c.CoreV1().RESTClient().Get().RequestURI(pod.SelfLink).Do(context.TODO()).Into(pod); err != nil {
|
||||
t.Errorf("Failed listing pod with supplied self link '%v': %v", pod.SelfLink, err)
|
||||
}
|
||||
|
||||
podList, err := c.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("Failed listing pods: %v", err)
|
||||
}
|
||||
|
||||
if err = c.CoreV1().RESTClient().Get().RequestURI(podList.SelfLink).Do(context.TODO()).Into(podList); err != nil {
|
||||
t.Errorf("Failed listing pods with supplied self link '%v': %v", podList.SelfLink, err)
|
||||
}
|
||||
|
||||
found := false
|
||||
for i := range podList.Items {
|
||||
item := &podList.Items[i]
|
||||
if item.Name != "selflinktest" {
|
||||
continue
|
||||
}
|
||||
found = true
|
||||
err = c.CoreV1().RESTClient().Get().RequestURI(item.SelfLink).Do(context.TODO()).Into(pod)
|
||||
if err != nil {
|
||||
t.Errorf("Failed listing pod with supplied self link '%v': %v", item.SelfLink, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("never found selflinktest pod in namespace %s", namespace)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelfLinkOnNamespace(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.RemoveSelfLink, false)()
|
||||
|
||||
result := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins", "ServiceAccount"}, framework.SharedEtcd())
|
||||
defer result.TearDownFn()
|
||||
|
||||
c := clientset.NewForConfigOrDie(result.ClientConfig)
|
||||
|
||||
runSelfLinkTestOnNamespace(t, c, "default")
|
||||
}
|
||||
|
||||
func TestApplyWithApplyConfiguration(t *testing.T) {
|
||||
deployment := appsv1ac.Deployment("nginx-deployment-3", "default").
|
||||
WithSpec(appsv1ac.DeploymentSpec().
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/apiserver/pkg/storage/etcd3"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||
)
|
||||
@@ -118,11 +119,11 @@ func TestCrossGroupStorage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
versioner := etcd3.APIObjectVersioner{}
|
||||
for _, resource := range resources {
|
||||
// clear out the things cleared in etcd
|
||||
versioned := versionedData[resource.Mapping.Resource]
|
||||
versioned.SetResourceVersion("")
|
||||
versioned.SetSelfLink("")
|
||||
versioner.PrepareObjectForStorage(versioned)
|
||||
versionedJSON, err := versioned.MarshalJSON()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user