mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Stop publishing Pod ResourceVersion in Endpoints and EndpointSlice API
The field is not used anywhere and its value may be stale as Endpoints and EndpointSlice won't be updated if there is only Pod ResourceVersion change..
This commit is contained in:
parent
422001df8b
commit
906e6d4670
@ -259,7 +259,6 @@ func podToEndpointAddressForService(svc *v1.Service, pod *v1.Pod) (*v1.EndpointA
|
||||
Namespace: pod.ObjectMeta.Namespace,
|
||||
Name: pod.ObjectMeta.Name,
|
||||
UID: pod.ObjectMeta.UID,
|
||||
ResourceVersion: pod.ObjectMeta.ResourceVersion,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ func testPod(namespace string, id int, nPorts int, isReady bool, ipFamilies []v1
|
||||
Namespace: namespace,
|
||||
Name: fmt.Sprintf("pod%d", id),
|
||||
Labels: map[string]string{"foo": "bar"},
|
||||
ResourceVersion: fmt.Sprint(id),
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{{Ports: []v1.ContainerPort{}}},
|
||||
@ -1430,16 +1431,16 @@ func TestPodToEndpointAddressForService(t *testing.T) {
|
||||
t.Fatalf("TargetRef.Kind: expected: %s, got: %s", "Pod", epa.TargetRef.Kind)
|
||||
}
|
||||
if epa.TargetRef.Namespace != pod.ObjectMeta.Namespace {
|
||||
t.Fatalf("TargetRef.Kind: expected: %s, got: %s", pod.ObjectMeta.Namespace, epa.TargetRef.Namespace)
|
||||
t.Fatalf("TargetRef.Namespace: expected: %s, got: %s", pod.ObjectMeta.Namespace, epa.TargetRef.Namespace)
|
||||
}
|
||||
if epa.TargetRef.Name != pod.ObjectMeta.Name {
|
||||
t.Fatalf("TargetRef.Kind: expected: %s, got: %s", pod.ObjectMeta.Name, epa.TargetRef.Name)
|
||||
t.Fatalf("TargetRef.Name: expected: %s, got: %s", pod.ObjectMeta.Name, epa.TargetRef.Name)
|
||||
}
|
||||
if epa.TargetRef.UID != pod.ObjectMeta.UID {
|
||||
t.Fatalf("TargetRef.Kind: expected: %s, got: %s", pod.ObjectMeta.UID, epa.TargetRef.UID)
|
||||
t.Fatalf("TargetRef.UID: expected: %s, got: %s", pod.ObjectMeta.UID, epa.TargetRef.UID)
|
||||
}
|
||||
if epa.TargetRef.ResourceVersion != pod.ObjectMeta.ResourceVersion {
|
||||
t.Fatalf("TargetRef.Kind: expected: %s, got: %s", pod.ObjectMeta.ResourceVersion, epa.TargetRef.ResourceVersion)
|
||||
if epa.TargetRef.ResourceVersion != "" {
|
||||
t.Fatalf("TargetRef.ResourceVersion: expected empty, got: %s", epa.TargetRef.ResourceVersion)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service,
|
||||
Namespace: pod.ObjectMeta.Namespace,
|
||||
Name: pod.ObjectMeta.Name,
|
||||
UID: pod.ObjectMeta.UID,
|
||||
ResourceVersion: pod.ObjectMeta.ResourceVersion,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -283,7 +282,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -300,7 +298,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -317,7 +314,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -336,7 +332,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -355,7 +350,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -375,7 +369,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPodHostname.Name,
|
||||
UID: readyPodHostname.UID,
|
||||
ResourceVersion: readyPodHostname.ResourceVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -396,7 +389,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
terminatingGateEnabled: true,
|
||||
@ -416,7 +408,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
terminatingGateEnabled: false,
|
||||
@ -438,7 +429,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
terminatingGateEnabled: true,
|
||||
@ -458,7 +448,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
terminatingGateEnabled: false,
|
||||
@ -480,7 +469,6 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
Namespace: ns,
|
||||
Name: readyPod.Name,
|
||||
UID: readyPod.UID,
|
||||
ResourceVersion: readyPod.ResourceVersion,
|
||||
},
|
||||
},
|
||||
terminatingGateEnabled: true,
|
||||
@ -937,6 +925,7 @@ func newPod(n int, namespace string, ready bool, nPorts int, terminating bool) *
|
||||
Name: fmt.Sprintf("pod%d", n),
|
||||
Labels: map[string]string{"foo": "bar"},
|
||||
DeletionTimestamp: deletionTimestamp,
|
||||
ResourceVersion: fmt.Sprint(n),
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{{
|
||||
|
@ -851,6 +851,28 @@ func TestEndpointsEqualBeyondHash(t *testing.T) {
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Pod resourceVersion removed",
|
||||
ep1: &discovery.Endpoint{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
},
|
||||
Addresses: []string{"10.0.0.1"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod0", ResourceVersion: "1"},
|
||||
Zone: utilpointer.StringPtr("zone-1"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
},
|
||||
ep2: &discovery.Endpoint{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
},
|
||||
Addresses: []string{"10.0.0.1"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod0", ResourceVersion: ""},
|
||||
Zone: utilpointer.StringPtr("zone-1"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@ -933,6 +955,14 @@ func TestEndpointSubsetsEqualIgnoreResourceVersion(t *testing.T) {
|
||||
})},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Pod ResourceVersion removed",
|
||||
subsets1: []v1.EndpointSubset{*es1, *es2},
|
||||
subsets2: []v1.EndpointSubset{*es1, *copyAndMutateEndpointSubset(es2, func(es *v1.EndpointSubset) {
|
||||
es.Addresses[0].TargetRef.ResourceVersion = ""
|
||||
})},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Ports changed",
|
||||
subsets1: []v1.EndpointSubset{*es1, *es2},
|
||||
|
Loading…
Reference in New Issue
Block a user