Skip to content

Remove unnecessary -z flag from tar extraction commands#2635

Merged
rkoster merged 1 commit intocloudfoundry:mainfrom
mdzhigarov:main
Nov 6, 2025
Merged

Remove unnecessary -z flag from tar extraction commands#2635
rkoster merged 1 commit intocloudfoundry:mainfrom
mdzhigarov:main

Conversation

@mdzhigarov
Copy link
Copy Markdown
Contributor

Summary

This PR removes the unnecessary -z flag from tar extraction commands throughout the BOSH codebase. Modern tar implementations support automatic compression detection based on file signatures and fallback to filename suffixes.

Changes Made

  • BOSH Director Components: Updated release and stemcell extraction in update_release.rb, update_stemcell.rb, release_job.rb, and job_template_loader.rb
  • Integration Tests: Updated nginx and NATS service utilities
  • CI Scripts: Updated export-release script

Technical Details

The -z flag is only required when reading from pipes or tape drives without random access. For regular file operations, modern tar implementations can automatically detect compression formats using:

  1. File signatures (magic bytes at the beginning of files)
  2. Filename suffixes as fallback (e.g., .tgz, .tar.gz)

Compatibility

  • ✅ Maintains compatibility with modern tar implementations (GNU tar, BSD tar)
  • ✅ Preserves -z flag where still needed (pipes, test utilities)
  • ✅ All existing unit tests pass (they mock the execution layer)
  • ✅ No functional changes to error handling or cleanup logic

Preparation for Future Enhancement

This change is done in preparation for introducing a --no-compression flag in the bosh create-release command, which will allow creating uncompressed release tarballs that can be processed with the simplified tar commands.

Testing

  • All unit tests continue to pass
  • Tests mock the Exec.sh calls, so they verify error handling behavior rather than specific command syntax
  • No integration test changes required as the functionality remains identical

References

Modern tar implementations support automatic compression detection based on
file signatures and fallback to filename suffixes. The -z flag is only
required when reading from pipes or tape drives without random access.

This change removes the -z flag from tar extraction commands in:
- BOSH Director release and stemcell extraction
- Job template extraction
- Integration test utilities
- CI export scripts

The changes maintain compatibility with modern tar implementations while
simplifying the codebase. Test utilities and pipe-based extractions
correctly retain the -z flag where needed.

This change is done in preparation for introducing a no-compression flag
in the bosh create-release command, which will allow creating uncompressed
release tarballs that can be processed with the simplified tar commands.
@aramprice
Copy link
Copy Markdown
Member

aramprice commented Oct 22, 2025

@aramprice aramprice requested review from a team, benjaminguttmann-avtq and ystros and removed request for a team October 22, 2025 21:51
@aramprice aramprice moved this from Inbox to Pending Review | Discussion in Foundational Infrastructure Working Group Oct 23, 2025
Copy link
Copy Markdown
Contributor

@KauzClay KauzClay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to clarify my understanding.

This is related to the --no-compression flag change because the -z flag on non-compressed files will cause tar to fail?

Any by removing the z, since tar can auto-detect, it can safely expand things that were tar-ed without compression?

@mdzhigarov
Copy link
Copy Markdown
Contributor Author

Just trying to clarify my understanding.

This is related to the --no-compression flag change because the -z flag on non-compressed files will cause tar to fail?

Any by removing the z, since tar can auto-detect, it can safely expand things that were tar-ed without compression?

Yep, exactly

@rkoster rkoster marked this pull request as draft October 30, 2025 15:50
@rkoster rkoster marked this pull request as ready for review November 6, 2025 21:55
@github-project-automation github-project-automation bot moved this from Pending Review | Discussion to Pending Merge | Prioritized in Foundational Infrastructure Working Group Nov 6, 2025
@rkoster
Copy link
Copy Markdown
Contributor

rkoster commented Nov 6, 2025

Merging this PR since it is a non breaking change and a path forward for the UX of the no compression feature has been determined during today's FI working group meeting (this was the previous blocker).

@rkoster rkoster merged commit 89e494f into cloudfoundry:main Nov 6, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Nov 6, 2025
mdzhigarov added a commit to mdzhigarov/bosh that referenced this pull request Mar 18, 2026
Follow-up to PR cloudfoundry#2635 which removed the -z flag from tar extraction
commands but missed the validate_tgz method in package_persister.rb
and its corresponding test expectations.

The -z flag forces gzip decompression, causing failures when processing
non-gzip-compressed package archives. Modern tar auto-detects the
compression format without needing the -z flag.

Made-with: Cursor
aramprice pushed a commit that referenced this pull request Mar 18, 2026
Follow-up to PR #2635 which removed the -z flag from tar extraction
commands but missed the validate_tgz method in package_persister.rb
and its corresponding test expectations.

The -z flag forces gzip decompression, causing failures when processing
non-gzip-compressed package archives. Modern tar auto-detects the
compression format without needing the -z flag.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

5 participants