diff --git a/changelogs/unreleased/4462-ywk253100 b/changelogs/unreleased/4462-ywk253100 new file mode 100644 index 000000000..e02b9ed34 --- /dev/null +++ b/changelogs/unreleased/4462-ywk253100 @@ -0,0 +1 @@ +Ignore the provided port is already allocated error when restoring the LoadBalancer service \ No newline at end of file diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 19e500269..3b1e3e94c 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -1328,11 +1328,12 @@ func isAlreadyExistsError(ctx *restoreContext, obj *unstructured.Unstructured, e if apierrors.IsAlreadyExists(err) { return true } - // the "invalid value" error rather than "already exists" error returns when restoring nodePort service - // that has nodePort preservation if the same nodePort service already exists. + // The "invalid value error" or "internal error" rather than "already exists" error returns when restoring nodePort service in the following two cases: + // 1. For NodePort service, the service has nodePort preservation while the same nodePort service already exists. - Get invalid value error + // 2. For LoadBalancer service, the "healthCheckNodePort" already exists. - Get internal error // If this is the case, the function returns true to avoid reporting error. // Refer to https://github.com/vmware-tanzu/velero/issues/2308 for more details - if obj.GetKind() != "Service" || !apierrors.IsInvalid(err) { + if obj.GetKind() != "Service" { return false } statusErr, ok := err.(*apierrors.StatusError) diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index faada13f9..14680d7ef 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -3044,16 +3044,6 @@ func TestIsAlreadyExistsError(t *testing.T) { }, expected: false, }, - { - name: "The input error isn't InvalidError", - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "kind": "Service", - }, - }, - err: apierrors.NewBadRequest(""), - expected: false, - }, { name: "The StatusError contains no causes", obj: &unstructured.Unstructured{