mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
Skip namespace in terminating state in backup resource collection.
To make sure resources in terminating namespaces are not included. Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
committed by
Xun Jiang/Bruce Jiang
parent
f3685f37f6
commit
2d71430e80
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
@@ -114,6 +115,16 @@ func (nt *nsTracker) init(
|
||||
nt.logger = logger
|
||||
|
||||
for _, namespace := range unstructuredNSs {
|
||||
ns := new(corev1api.Namespace)
|
||||
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(namespace.UnstructuredContent(), ns); err != nil {
|
||||
nt.logger.WithError(err).Errorf("Fail to convert unstructured into namespace %s", namespace.GetName())
|
||||
continue
|
||||
}
|
||||
if ns.Status.Phase != corev1api.NamespaceActive {
|
||||
nt.logger.Infof("Skip namespace %s because it's not in Active phase.", namespace.GetName())
|
||||
continue
|
||||
}
|
||||
|
||||
if nt.singleLabelSelector != nil &&
|
||||
nt.singleLabelSelector.Matches(labels.Set(namespace.GetLabels())) {
|
||||
nt.logger.Debugf("Track namespace %s, because its labels match backup LabelSelector.",
|
||||
|
||||
Reference in New Issue
Block a user