Skip to content

Commit

Permalink
Bug 2000979: Empty the "ClusterIPs" along with "ClusterIP" when "Clus…
Browse files Browse the repository at this point in the history
…terIP" isn't "None" (vmware-tanzu#4101)

(cherry-pick from upstream)
More details please refer to vmware-tanzu#4098

Fixes vmware-tanzu#4098

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
  • Loading branch information
ywk253100 authored and sseago committed Sep 3, 2021
1 parent 20e8ad9 commit 36d4ce2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/4101-ywk253100
@@ -0,0 +1 @@
Empty the "ClusterIPs" along with "ClusterIP" when "ClusterIP" isn't "None"
1 change: 1 addition & 0 deletions pkg/restore/service_action.go
Expand Up @@ -54,6 +54,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 */
Expand Down
3 changes: 2 additions & 1 deletion pkg/restore/service_action_test.go
Expand Up @@ -58,13 +58,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",
},
},
Expand Down

0 comments on commit 36d4ce2

Please sign in to comment.