Skip to content

General fixes#112

Merged
Joeavaikath merged 4 commits intomigtools:oadp-devfrom
Joeavaikath:general-fixes
Feb 4, 2026
Merged

General fixes#112
Joeavaikath merged 4 commits intomigtools:oadp-devfrom
Joeavaikath:general-fixes

Conversation

@Joeavaikath
Copy link
Contributor

Why the changes were made

This PR improves the nonadmin backup describe command with better output formatting, bug fixes, and code quality improvements:

1. Improve nonadmin backup describe output formatting

  • Aligns the nonadmin backup describe output to match the admin/Velero backup describe format for consistency
  • Makes the output more readable by parsing JSON data structures and displaying them hierarchically
  • Moves the Resource List to appear before Backup Volumes section (matching admin output order)
  • Skips printing empty sections (no snapshots, no errors/warnings) to reduce clutter

2. Refactor download request logic to eliminate code duplication

  • Consolidates duplicate download request logic into a reusable ProcessDownloadRequest function in the shared package
  • Reduces code duplication across backup describe, logs, and download commands
  • Improves maintainability and consistency in error handling and timeout behavior

3. Fix gzip decompression for backup downloads and enhance describe command

  • Fixes gzip decompression issue when downloading backup data
  • Ensures downloaded content is properly decompressed before processing
  • Enhances error handling in the describe command

How to test the changes made

Prerequisites

# Create a nonadmin backup
kubectl oadp nonadmin backup create test-backup --namespace <your-namespace>

# Wait for backup to complete
kubectl oadp nonadmin backup get test-backup

Test 1: Basic describe output formatting

kubectl oadp nonadmin backup describe test-backup

Expected output:
- Clean, well-formatted output matching Velero admin backup describe style
- Resource List appears after "Items backed up" and before "Backup Volumes"
- Empty sections are not shown

Before:
Resource List:
  {"v1/ConfigMap":["namespace/config1","namespace/config2"],...}

After:
Resource List:
  v1/ConfigMap:
    - namespace/config1
    - namespace/config2
  v1/Secret:
    - namespace/secret1

Test 2: Detailed output with --details flag

kubectl oadp nonadmin backup describe test-backup --details

Expected output:
- Only non-empty sections are displayed (Volume Snapshot Details, Backup Results, Item Operations)
- Backup Results shows separated Errors and Warnings subsections
- JSON data is formatted and indented for readability
- Empty arrays/objects result in section being skipped entirely

Test 3: Download and logs commands (refactoring verification)

# Test download still works with refactored code
kubectl oadp nonadmin backup download test-backup BackupLog

# Test logs command
kubectl oadp nonadmin backup logs test-backup

Expected output:
- Downloads complete successfully with proper gzip decompression
- Logs are displayed correctly
- No regression in functionality

Visual Comparison

Compare the output to admin backup describe:
# Admin backup describe (for reference)
velero backup describe <backup-name> --details

# Nonadmin backup describe (should look similar)
kubectl oadp nonadmin backup describe test-backup --details

The nonadmin output should now closely match the admin format, making it easier for users familiar with Velero to understand the nonadmin interface.

Joeavaikath and others added 3 commits February 3, 2026 19:40
This commit addresses issues with compressed backup data and adds new
functionality for detailed backup information:

Download improvements:
- Fix gzip detection to check file magic bytes (0x1f 0x8b) in addition
  to Content-Encoding header. Object storage signed URLs often serve
  .gz files without the Content-Encoding header, causing decompressed
  content to be displayed as binary gibberish
- Add comprehensive debug logging to download functions for easier
  troubleshooting
- Use buffered reader with Peek() to detect gzip format without
  consuming the stream

Describe command enhancements:
- Add --details flag to fetch additional backup information including
  volume snapshots, resource lists, backup results, and item operations
- Exclude describe command from output wrapper (similar to logs command)
  to prevent buffering issues with large downloads
- Update tests to reflect describe command exclusion

Installation improvements:
- Enhance make install output formatting with clearer status messages
- Show version info during installation verification

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Extract common download request creation and polling logic into a new
shared function CreateAndWaitForDownloadURL. This eliminates ~53 lines
of duplicated code between the logs and describe commands.

Key changes:
- Add CreateAndWaitForDownloadURL function to handle request creation
  and polling with optional progress callbacks
- Add OnProgress callback to DownloadRequestOptions for progress indication
- Refactor logs command to use shared function (75 lines → 22 lines)
- Simplify printDetailedBackupInfo to accept backup name string instead
  of full NonAdminBackup object
- Remove debug log statements from download.go
- Clean up unused imports in logs.go

This maintains the key behavioral difference between commands:
- logs: streams content for low memory usage
- describe --details: buffers content for formatting

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Align nonadmin backup describe output with admin backup format:
- Move Resource List before Backup Volumes section to match admin order
- Parse and format Resource List JSON as hierarchical structure with bullets
- Skip printing sections with no data (empty snapshots, no errors/warnings)
- Parse and format Volume Snapshot Details, Backup Results, and Item Operations as readable JSON
- Split Backup Results into separate Errors and Warnings subsections

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
Remove unused assignment to hasOutput variable in printDetailedBackupInfo
function. The assignment at line 447 had no effect since it was in the
last section and the variable was never used afterward.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Joseph <jvaikath@redhat.com>
@Joeavaikath Joeavaikath merged commit d70ead9 into migtools:oadp-dev Feb 4, 2026
15 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.

All commands that stream output will need to skip the velero->oadp replacement wrapper --details flag does not work for NonAdmin backup and restores

1 participant