Replace blanket Reset() with targeted DeleteLabelValues to avoid
briefly wiping metrics for schedules that still exist. Track known
schedules in a set and only delete stale entries on each resync.
Extract the wait.Until closure into resyncBackupMetrics() so tests
can call it directly without goroutine timing. Replace hand-rolled
collectGaugeCount helper with testutil.CollectAndCount.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add a test that exercises the actual updateTotalBackupMetric goroutine
with a fake client to verify stale backupLastSuccessfulTimestamp
entries are pruned during a real resync cycle.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Avoid clearing backupLastSuccessfulTimestamp on transient API errors.
The reset and re-set now only run when the backup List call succeeds,
so existing metric values remain stable across temporary failures.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Remove the exported method that was only used in tests. Use the
existing Metrics() getter to access the gauge directly in the
backup controller test instead.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
The periodic backup metrics resync in updateTotalBackupMetric only set
backupLastSuccessfulTimestamp values but never removed stale entries.
When a schedule was deleted and its backups removed, the gauge persisted
until the Velero pod was restarted.
Reset the gauge before re-setting current values so that deleted
schedules are pruned automatically each resync cycle.
Fixes#9239
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add a method to reset all backupLastSuccessfulTimestamp gauge values.
This will be used by the backup controller's periodic resync to prune
stale metrics for deleted schedules.
Fixes#9239
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
curl piped straight into jq with no error check; a non-JSON or failed
HTTP response (rate limit, transient API error) broke jq with an
opaque parse error. Add --fail-with-body, retries, and validate the
parsed SHA before continuing.
Fixes#10048
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
* add documentation for backup filters
Add user guide for fine grained backup filters with examples
from easy to advanced.
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
* address review comments
- enhanced example 3, explain how each item got excluded
- enhanced example 8, explain the exact match rule, and how the
ordering affecting namespace that has multiple match patterns
- cross link to restore side design
- fix the error msg to be consistent with implemenation
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
---------
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
* Prioritize exact namespace match in restore
Align restore pipeline with backup pipeline by
evaluating exact namespace matches before glob
patterns in namespacedFilterPolicies. This ensures
specific overrides always win regardless of list
order.
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
* improve test cases
add test cases for exact listed first, and excat listed last to
ensure the behavior that the order does not matter for exact
listed namespace, the rule will be always honored.
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
---------
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>
Only 3 of 13 Velero CRDs had short names (bsl, vsl, ssr). This adds
short names to the remaining 10 CRDs for better kubectl usability:
Backup=bkp, Restore=rst, Schedule=sched, BackupRepository=br,
DeleteBackupRequest=dbr, DownloadRequest=dr, PodVolumeBackup=pvb,
PodVolumeRestore=pvr, DataUpload=du, DataDownload=dd
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add design doc for dynamic CLI resource autocompletion
Proposes adding ValidArgsFunction and RegisterFlagCompletionFunc
to all Velero CLI commands that accept existing resource names,
covering 20 commands and 5 flags across 6 resource types.
Signed-off-by: Joseph <jvaikath@redhat.com>
* Update design doc to reflect implementation details
- Document the shared completeNames helper using apimachinery's
meta.ExtractList/Accessor instead of six duplicated functions
- Add 3-second timeout, deep-copy, and per-item error resilience details
- Update generics alternative to explain why they were unnecessary
- Add testing section describing unit test coverage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
* Add RBAC and bash compatibility notes to design doc
- Note that users without list permission receive empty completions
- Document bash 4.0+ requirement and macOS bash 3.2 workarounds
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
* Add issue reference to design doc abstract
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
* Address PR review comments: add debug flag completion and arg deduplication
- Add `debug --backup` and `--restore` to flag completion table (chlins)
- Document deduplication of already-typed args in completeNames (chlins)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
* Trim design doc to focus on reviewable decisions
Remove implementation mechanics (code snippets, type alias justification,
deep-copy rationale, closure internals) that are verifiable from code.
Drop bash v1-to-v2 migration (v1 already supports ValidArgsFunction).
Fix flag count from 7 to 9 (add schedule create inherited flags).
Add Open Issues section for single-arg commands, comma-separated flag
values, and optional v2 migration.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
---------
Signed-off-by: Joseph <jvaikath@redhat.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per review feedback, these workflows are useful on forks:
- e2e-test-kind: tests pass on downstream forks
- pr-linter-check: keeps lint up to date for upstream-bound features
- nightly-trivy-scan: wanted in downstream forks
Also remove changelog file per reviewer request.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add repository guard (github.repository == 'velero-io/velero') to
workflows that should only run on the upstream repo. This prevents
unnecessary CI runs on forks like openshift/velero where these
workflows either fail due to missing secrets/config or duplicate
fork-specific CI.
Guarded workflows: auto_assign_prs, auto_label_prs,
auto_request_review, e2e-test-kind, nightly-trivy-scan,
pr-changelog-check, pr-codespell, pr-filepath-check,
pr-linter-check, prow-action, rebase, stale-issues.
Intentionally left unguarded: pr-ci-check (useful for contributors
on forks), get-go-version (reusable workflow_call only).
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Fix PodVolumeBackup metadata loss on fs-backup timeout
When a backup hits the fs-backup timeout, WaitAllPodVolumesProcessed
returned nil because PVBs were only collected from the indexer in the
done branch of the select. This discarded all PVB metadata including
already-completed PVBs, making their data unrestorable.
Move the PVB collection loop to run after the select so tracked PVBs
are always persisted regardless of timeout.
Fixes#9986
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add changelog for PR #9995
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Filter non-completed PVBs in hasPodVolumeBackup
After preserving tracked PVBs on timeout, non-completed PVBs (in-progress
or with no snapshot ID) would cause hasPodVolumeBackup to return true,
leading the restore to skip the original PV and dynamically re-provision
it without any data to restore from.
Only match PVBs that are Completed with a valid SnapshotID.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add unit tests for hasPodVolumeBackup phase filtering
Verify that hasPodVolumeBackup only matches PVBs that are Completed
with a valid SnapshotID, and rejects in-progress, failed, or
empty-snapshot PVBs.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
---------
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
curl api.github.com is subject to rate limit(60 requests per hour),
provide GitHub token increase the rate limits.
Signed-off-by: Adam Zhang <adam.zhang@broadcom.com>