pkg/cmd/cli/restore/logs.go was the last command in the CLI still calling
cmd.Exit, which calls os.Exit directly. Two of its own tests were skipped
because of it, and said so:
t.Skip("Cannot test restore not complete case due to cmd.Exit() call")
This gives restore logs the LogsOptions shape that backup logs already
uses: Complete, BindFlags and Run returning an error, with the cobra
command passing that to cmd.CheckError. Both skipped tests now run and
assert on the returned errors.
Exit status is unchanged; cmd.CheckError also exits 1. The two refusal
messages now carry the standard "An error occurred:" prefix and match
the wording backup logs uses.
Signed-off-by: saral <ilovegojo2580@gmail.com>
* Add printer columns for Backup and Restore CRDs
kubectl get backup and kubectl get restore fall back to the default
NAME/AGE table because neither type declares printer columns, while
Schedule and BackupStorageLocation do. Anything reading the API without
the velero binary cannot see a backup's phase, error count or timing.
Printer columns were added in #2881 and reverted in #3652 as a
workaround for #3600, a CRD install error that was never root-caused.
Schedule regained columns in 2022 and BackupStorageLocation has them
today, with no recurrence.
Only fields expressible as plain JSONPath are included. Expiration is
deliberately omitted: kubectl renders a date column as time elapsed,
so a future expiration prints <invalid>, which covers every backup that
has not yet expired.
Fixes#10199
Signed-off-by: saral <ilovegojo2580@gmail.com>
* Rename changelog name to pass changelog check
Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
---------
Signed-off-by: saral <ilovegojo2580@gmail.com>
Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
Co-authored-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
kubectl get volumesnapshotlocation falls back to NAME and AGE, while
BackupStorageLocation beside it shows provider and phase. This follows
the same pattern for the remaining location type.
Phase is worth surfacing here because the CLI does not print it.
velero snapshot-location get shows only NAME and PROVIDER, so
status.phase, which carries the same Available/Unavailable enum as
BackupStorageLocation, is currently not visible from either tool.
Raised as an open question on #10199 and left out of #10200 to keep that
change to the two types the issue was filed about.
Signed-off-by: saral <ilovegojo2580@gmail.com>
- Fix 'dataudownload' typo in DataDownload warning log message
(data_download_controller.go:696)
- Fix 'datadownlad' misspelled structured log field key to 'datadownload'
(data_download_controller.go:700) - this caused the log field to be
unqueryable by the correct key name
- Fix 'retrieveable' -> 'retrievable' in BackupRepository maintenance
status messages (maintenance.go:354, 417)
- Update corresponding test assertion to match corrected string
(maintenance_test.go:792)
Signed-off-by: shellyco-code <shellyco-code@users.noreply.github.com>
Co-authored-by: shellyco-code <shellyco-code@users.noreply.github.com>
restore-wait's securityContext fallback chain checked the fs-restore
ConfigMap, then the first container's SecurityContext, then hardcoded
runAsUser 1000. It never consulted pod.Spec.SecurityContext, so pods
that set identity only at the pod level got a helper running as uid
1000 regardless of the workload's actual uid. On volumes where restored
content is owner-only-visible to a non-1000 uid, the helper's stat on
the done-file returns EACCES forever and the pod deadlocks at Init:0/1.
Add pod-level spec.securityContext.runAsUser/runAsGroup as a fallback
between the container-level check and the hardcoded default, since the
workload's own identity is the one that can read what it restored.
Defer to the pod's own RunAsNonRoot setting when runAsUser is 0, since
the hardcoded RunAsNonRoot: true would otherwise contradict a root uid.
Also add a test case covering both container-level and pod-level
SecurityContext set together, confirming container-level still wins.
Fixes#10046
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Register cobra completion callbacks for all commands that accept
existing Velero resource names. A centralized completeNames helper
uses apimachinery's meta.ExtractList/Accessor to list resources with
a 3-second timeout, filter by prefix, and deduplicate already-typed
arguments. Wires ValidArgsFunction on 20 commands and
RegisterFlagCompletionFunc on 9 flags across backup, restore,
schedule, backuplocation, snapshotlocation, repo, and debug.
Closes#9782
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
* Add SnapshotClassParameter constant and GetSnapshotClass getter
Add a new snapshotClass action parameter to volume policies, allowing
users to specify which VolumeSnapshotClass to use for CSI snapshots.
This follows the existing dataMover parameter pattern with a typed
constant and getter method on the Action struct.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add snapshotClass parameter validation
Validate the snapshotClass parameter in Action.validate(): it must only
appear on snapshot actions, must be a string, and must not be empty.
Follows the same validation pattern as the dataMover parameter.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add volume policy tier to VolumeSnapshotClass selection
Add GetVolumeSnapshotClassFromVolumePolicy helper and extend
GetVolumeSnapshotClass with a policySnapshotClass parameter. The new
tier sits between PVC annotation and backup annotation in the priority
chain: PVC annotation > volume policy > backup annotation > VSC label.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Wire snapshotClass from volume policy through CSI plugin
In pvcBackupItemAction.Execute, call GetActionParameters to extract the
snapshotClass from the matched volume policy and pass it through
getVolumeSnapshotReference and createVolumeSnapshot to
GetVolumeSnapshotClass. This connects the volume policy parameter to
the CSI snapshot creation path.
Fixes#8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add changelog for PR #10070
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Document snapshotClass volume policy parameter
Add documentation for the new snapshotClass parameter in the volume
policy snapshot action. Update the CSI docs to include volume policy
as a tier in the VolumeSnapshotClass selection priority, and add
Example 6 to resource-filtering.md showing multi-array usage.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Fix import ordering in pvc_action.go
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add end-to-end test for snapshotClass volume policy parameter
Verify that when a volume policy specifies snapshotClass, the CSI
plugin creates a VolumeSnapshot using that VolumeSnapshotClass. The
test uses a VSC without the velero label to confirm selection comes
from the volume policy parameter, not the label-based fallback.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Fix gofmt struct field alignment in pvc_action_test.go
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Add GetSnapshotClass to VolumeHelper interface
Add a GetSnapshotClass method to VolumeHelper that encapsulates the
extraction of the snapshotClass parameter from volume policy actions.
This avoids requiring callers to parse raw parameters from
GetActionParameters. Simplify the CSI plugin to use the new method.
Ref: #8807
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
* Fix gofmt formatting in resource_policies.go
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
---------
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
archive.Unmarshal returns (nil, err) when an item file contains malformed
JSON, and restoreItem dereferences its obj argument on entry, so an
additional item that fails to unmarshal must be skipped rather than passed
on. The loop only records the error and continues today; nothing covers
that, so removing the continue reintroduces a nil pointer dereference in
the restore reconciler without failing any test.
The item file is added to the tarball so the existing Stat check passes and
the unmarshal is actually reached.
Signed-off-by: chlins <chlins.zhang@gmail.com>
EnsureNamespaceExistsAndIsReady wrote the tracker key with namespace.Kind
(getNamespace() sets Kind=Namespace) but read it with clusterNS.Kind
(client.Get strips TypeMeta -> Kind=empty). The keys never matched, so the
skip-path never fired and every item in a terminating namespace paid the full
--terminating-resource-timeout wait (per-resource instead of per-namespace).
Use the passed-in namespace object for Contains so Add/Contains keys match.
Add a regression test that reproduces the production Kind divergence.
Signed-off-by: Shashank1306s <shashasingh@microsoft.com>
Co-authored-by: Shashank1306s <shashasingh@microsoft.com>
Co-authored-by: Priyansh Choudhary <im1706@gmail.com>
Modify the logs.
Modify the CRD's data mover's comment.
Modify the resource policy's GetDataMover for default data mover case.
Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
Detect the host path volumes by their source instead of their name, so the customized ones are excluded as well. Drop the container capability changes since the data mover needs them to access the data, and fix the copyright headers.
Signed-off-by: chlins <chlins.zhang@gmail.com>
The CSI snapshot and generic restore exposers access data through PVCs, so they no longer inherit the node-agent host path volumes. Also drop all capabilities on the data mover container.
Signed-off-by: chlins <chlins.zhang@gmail.com>
Verify the --default-resource-modifier-configmap flag is wired through
VeleroOptions to the deployment args via AllResources.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add the flag to the existing TestCreateCommand test to verify flag
binding and option parsing.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
- Log when SkipDefaultResourceModifier skips the default modifier
- Add test for unsupported ResourceModifier Kind (warns, does not
apply default)
- Add test for default ConfigMap with invalid rules (validation
failure is non-fatal)
- loadResourceModifierConfigMap now at 100% coverage
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
- Add Default Resource Modifiers section to restore-resource-modifiers.md
- Add --default-resource-modifier-configmap to customize-installation.md
- Add examples/default-resource-modifier-cni.yaml with CNI annotation
stripping rules for OVN-K and Multus
- Update restore describer to show SkipDefaultResourceModifier when set
- Log warning when ResourceModifier Kind is not ConfigMap instead of
silently doing nothing
- Add deployment_test.go coverage for the new server flag
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
- Fix fallthrough bug: when ResourceModifier is set with a non-ConfigMap
kind, do not fall through to applying the server default. The outer
check on ResourceModifier != nil now prevents default application
regardless of the Kind value.
- Include underlying error in fatal validation message for ConfigMap
retrieval failures.
- Strengthen exclusive precedence test: default ConfigMap intentionally
does not exist while per-restore does, proving the default is never
consulted.
- Add test for invalid default ConfigMap data (non-fatal, warn and
proceed).
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add --default-resource-modifier-configmap to the install CLI and
deployment builder so administrators can configure it during velero
install. Wire through VeleroOptions and podTemplateConfig following
the existing --backup-repository-configmap pattern.
Add SkipDefaultResourceModifier builder method to RestoreBuilder.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
When set, the server-configured default resource modifier is skipped
for this restore. Only sets the *bool field when the flag is true,
leaving it nil otherwise.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Thread DefaultResourceModifierConfigMap from server config through to
restoreReconciler. Refactor validateAndComplete to use a shared
loadResourceModifierConfigMap helper that handles both default and
per-restore ConfigMap loading.
Precedence: per-restore modifier takes exclusive precedence over the
default. Default ConfigMap errors are non-fatal (warn and proceed).
SkipDefaultResourceModifier opt-out is respected.
Includes unit tests covering: default-only, per-restore override,
skip flag, missing default (non-fatal), missing per-restore (fatal),
and no modifier configured.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add *bool field following existing RestoreSpec conventions (RestorePVs,
PreserveNodePorts, IncludeClusterResources). When true, the server
default resource modifier is skipped for this restore.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
Add DefaultResourceModifierConfigMap field to the server Config struct
and bind it as a CLI flag. When set, it references a ConfigMap name in
the Velero namespace containing default resource modifier rules to apply
to all restores.
Follows the existing pattern used by --backup-repository-configmap and
--repo-maintenance-job-configmap.
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>