velero icon indicating copy to clipboard operation
velero copied to clipboard

Check whether the namespaces specified in namespace filter exist.

Open blackpiglet opened this issue 7 months ago • 1 comments

Check whether the namespaces specified in the backup.Spec.IncludeNamespaces exist during backup resource collection. If not, log an error message to mark the backup as PartiallyFailed.

Thank you for contributing to Velero!

Please add a summary of your change

Create a backup with a namespace filter, and specify a non-existing namespace in the filter. The backup fails with a validation error.

velero backup create --include-namespaces=kube-public,invalid invalid-tst
Backup request "invalid-tst" submitted successfully.
Run `velero backup describe invalid-tst` or `velero backup logs invalid-tst` for more details.

k -n velero get backup invalid-tst  -o yaml
apiVersion: velero.io/v1
kind: Backup
metadata:
  annotations:
    velero.io/resource-timeout: 10m0s
    velero.io/source-cluster-k8s-gitversion: v1.29.4-gke.1043002
    velero.io/source-cluster-k8s-major-version: "1"
    velero.io/source-cluster-k8s-minor-version: "29"
  creationTimestamp: "2024-07-02T03:01:38Z"
  generation: 2
  labels:
    velero.io/storage-location: default
  name: invalid-tst
  namespace: velero
  resourceVersion: "100954432"
  uid: ee6eb635-1fe2-4d3f-8278-050c813fe042
spec:
  csiSnapshotTimeout: 10m0s
  defaultVolumesToFsBackup: false
  hooks: {}
  includedNamespaces:
  - kube-public
  - invalid
  itemOperationTimeout: 4h0m0s
  metadata: {}
  snapshotMoveData: false
  storageLocation: default
  ttl: 720h0m0s
  volumeSnapshotLocations:
  - default
status:
  expiration: "2024-08-01T03:01:38Z"
  formatVersion: 1.1.0
  phase: FailedValidation
  validationErrors:
  - 'Invalid included/excluded namespace lists: Namespace "invalid" not found'
  version: 1

This is not an ideal behavior. The preferred behavior should be making the backup as PartiallyFailed and continues the backup process. https://github.com/vmware-tanzu/velero/issues/7928#issuecomment-2199548047

Does your change fix a particular issue?

Fixes #7928

Please indicate you've done the following:

  • [x] Accepted the DCO. Commits without the DCO will delay acceptance.
  • [x] Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • [ ] Updated the corresponding documentation in site/content/docs/main.

blackpiglet avatar Jul 02 '24 07:07 blackpiglet