Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check whether the namespaces specified in namespace filter exist. #7965

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

blackpiglet
Copy link
Contributor

@blackpiglet blackpiglet commented Jul 2, 2024

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.
#7928 (comment)

Does your change fix a particular issue?

Fixes #7928

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • 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.

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.81%. Comparing base (28d64c2) to head (cf5dfdf).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7965      +/-   ##
==========================================
- Coverage   58.83%   58.81%   -0.02%     
==========================================
  Files         345      345              
  Lines       28795    28796       +1     
==========================================
- Hits        16941    16936       -5     
- Misses      10425    10430       +5     
- Partials     1429     1430       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blackpiglet blackpiglet force-pushed the 7928_fix branch 3 times, most recently from ff1b059 to 254e492 Compare July 3, 2024 10:21
@blackpiglet blackpiglet changed the title Set DualModeLog for both backup prepare and run stages. Check whether the namespaces specified in namespace filter exist. Jul 3, 2024
@blackpiglet blackpiglet marked this pull request as ready for review July 3, 2024 10:29
Check whether the namespaces specified in the
backup.Spec.IncludeNamespaces exist during backup resource collcetion
If not, log error to mark the backup as PartiallyFailed.

Signed-off-by: Xun Jiang <blackpigletbruce@gmail.com>
@blackpiglet blackpiglet merged commit 6fb109f into vmware-tanzu:main Jul 10, 2024
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1.14.0 Scheduled backup fails if namespace doesn't exist
4 participants