Skip to content

Fix SOS report extraction failure due to tar --one-top-level bug#132

Open
m4d3bug wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
m4d3bug:fix/sos-cross-device-link
Open

Fix SOS report extraction failure due to tar --one-top-level bug#132
m4d3bug wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
m4d3bug:fix/sos-cross-device-link

Conversation

@m4d3bug
Copy link

@m4d3bug m4d3bug commented Mar 19, 2026

Problem

SOS report extraction fails with Invalid cross-device link errors on all files when using --one-top-level combined with --strip-components in GNU tar 1.34 (shipped with RHEL 9). This affects both gather_sos (control plane nodes) and gather_edpm_sos (EDPM nodes).

All SOS report directories end up empty (0 bytes), and since the original tar.xz is unconditionally deleted after the failed extraction, the data is permanently lost.

Root Cause

GNU tar 1.34 has a bug where --one-top-level combined with --strip-components triggers Invalid cross-device link errors, even when source and destination are on the same filesystem. This is not a hard link or cross-filesystem issue — it affects all file types (regular files, directories, symlinks).

Verified by testing:

# FAILS - 17273 errors, 0 files extracted
tar --one-top-level=/tmp/test --strip-components=1 -Jxf sosreport.tar.xz

# WORKS - 0 errors, 15052 files extracted
tar -C /tmp/test --strip-components=1 -Jxf sosreport.tar.xz

Fix

  1. Replace --one-top-level=DIR with -C DIR in both gather_sos and gather_edpm_sos — achieves the same result (extract into a specific directory) without the bug
  2. Check tar exit code before deleting the original archive — if extraction fails, the compressed file is preserved as a fallback

Testing

Tested on RHEL 9 with GNU tar 1.34:

  • Before fix: all 4 sosreport directories (3 control plane + 1 EDPM) were empty with 17,000+ Invalid cross-device link errors
  • After fix: 15,052 files extracted successfully (194MB)

Environment

  • OpenShift 4.18.30
  • openstack-must-gather image: registry.redhat.io/rhoso-operators/openstack-must-gather-rhel9:1.0
  • GNU tar 1.34 (RHEL 9)

Closes #131

@openshift-ci openshift-ci bot requested review from gibizer and stuggi March 19, 2026 04:48
@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign abays for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

SOS report extraction fails with "Invalid cross-device link" errors on
all files when using --one-top-level combined with --strip-components in
GNU tar 1.34. This causes all SOS report directories to be empty, and
since the original tar.xz is unconditionally deleted after extraction,
the data is permanently lost.

Fix by:
1. Replacing --one-top-level with -C (which achieves the same result
   of extracting into a specific directory without the bug)
2. Checking tar exit code before deleting the original archive, so the
   compressed file is preserved as fallback if extraction fails

Tested with GNU tar 1.34 on RHEL 9 — before the fix all sosreport
directories were empty (0 bytes, 17000+ extraction errors), after the
fix 15000+ files extracted successfully (194MB).

Closes openstack-k8s-operators#131
@m4d3bug m4d3bug force-pushed the fix/sos-cross-device-link branch from c8bd25f to 0a2c4fe Compare March 19, 2026 05:00
@m4d3bug m4d3bug changed the title Fix SOS report extraction failure due to cross-device hard links Fix SOS report extraction failure due to tar --one-top-level bug Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SOS reports are empty due to cross-device hard link extraction failure

1 participant