Empty the "ClusterIPs" along with "ClusterIP" when "ClusterIP" isn't "None" (#4101)

More details please refer to #4098

Fixes #4098

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开)
2021-09-03 10:33:50 -04:00
committed by GitHub
parent 240b4e666f
commit 305dfa0d3c
3 changed files with 4 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Empty the "ClusterIPs" along with "ClusterIP" when "ClusterIP" isn't "None"
+1
View File
@@ -55,6 +55,7 @@ func (a *ServiceAction) Execute(input *velero.RestoreItemActionExecuteInput) (*v
if service.Spec.ClusterIP != "None" {
service.Spec.ClusterIP = ""
service.Spec.ClusterIPs = nil
}
/* Do not delete NodePorts if restore triggered with "--preserve-nodeports" flag */
+2 -1
View File
@@ -73,13 +73,14 @@ func TestServiceActionExecute(t *testing.T) {
expectedRes corev1api.Service
}{
{
name: "clusterIP (only) should be deleted from spec",
name: "clusterIP/clusterIPs should be deleted from spec",
obj: corev1api.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "svc-1",
},
Spec: corev1api.ServiceSpec{
ClusterIP: "should-be-removed",
ClusterIPs: []string{"should-be-removed"},
LoadBalancerIP: "should-be-kept",
},
},