Skip to content

Commit

Permalink
Empty the "ClusterIPs" along with "ClusterIP" when "ClusterIP" isn't …
Browse files Browse the repository at this point in the history
…"None"

More details please refer to vmware-tanzu#4098

Fixes vmware-tanzu#4098

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
  • Loading branch information
ywk253100 committed Sep 2, 2021
1 parent edeec84 commit 972a774
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/restore/service_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion pkg/restore/service_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
Expand Down

0 comments on commit 972a774

Please sign in to comment.