Ignore the provided port is already allocated error when restoring the LoadBalancer service (#4462)
Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>pull/4480/head
parent
d7aa82d8ed
commit
c7cd95a374
|
@ -0,0 +1 @@
|
|||
Ignore the provided port is already allocated error when restoring the LoadBalancer service
|
|
@ -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)
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue