mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
service update event should be triggered when appProtocol in port is changed.
Signed-off-by: MartinForReal <fanshangxiang@gmail.com>
This commit is contained in:
parent
4516c7972d
commit
f68345b2f0
@ -640,6 +640,10 @@ func portEqualForLB(x, y *v1.ServicePort) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(x.AppProtocol, y.AppProtocol) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1391,6 +1391,75 @@ func TestNeedsUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedNeedsUpdate: true,
|
expectedNeedsUpdate: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testName: "If appProtocol is the same",
|
||||||
|
updateFn: func() {
|
||||||
|
oldSvc = &v1.Service{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "tcp-service",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
Spec: v1.ServiceSpec{
|
||||||
|
Ports: []v1.ServicePort{{
|
||||||
|
Port: 80,
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
|
TargetPort: intstr.Parse("22"),
|
||||||
|
}},
|
||||||
|
Type: v1.ServiceTypeLoadBalancer,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
newSvc = oldSvc.DeepCopy()
|
||||||
|
},
|
||||||
|
expectedNeedsUpdate: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "If appProtocol is set when previously unset",
|
||||||
|
updateFn: func() {
|
||||||
|
oldSvc = &v1.Service{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "tcp-service",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
Spec: v1.ServiceSpec{
|
||||||
|
Ports: []v1.ServicePort{{
|
||||||
|
Port: 80,
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
|
TargetPort: intstr.Parse("22"),
|
||||||
|
}},
|
||||||
|
Type: v1.ServiceTypeLoadBalancer,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
newSvc = oldSvc.DeepCopy()
|
||||||
|
protocol := "http"
|
||||||
|
newSvc.Spec.Ports[0].AppProtocol = &protocol
|
||||||
|
},
|
||||||
|
expectedNeedsUpdate: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "If appProtocol is set to a different value",
|
||||||
|
updateFn: func() {
|
||||||
|
protocol := "http"
|
||||||
|
oldSvc = &v1.Service{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "tcp-service",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
Spec: v1.ServiceSpec{
|
||||||
|
Ports: []v1.ServicePort{{
|
||||||
|
Port: 80,
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
|
TargetPort: intstr.Parse("22"),
|
||||||
|
AppProtocol: &protocol,
|
||||||
|
}},
|
||||||
|
Type: v1.ServiceTypeLoadBalancer,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
newSvc = oldSvc.DeepCopy()
|
||||||
|
newProtocol := "tcp"
|
||||||
|
newSvc.Spec.Ports[0].AppProtocol = &newProtocol
|
||||||
|
},
|
||||||
|
expectedNeedsUpdate: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
controller, _, _ := newController()
|
controller, _, _ := newController()
|
||||||
|
Loading…
Reference in New Issue
Block a user