@@ -8,9 +8,8 @@ export OMC=${OMC:-true}
88export OSP_NS=" ${OSP_NS-openstack} "
99export OSP_OPERATORS_NS=" ${OSP_OPERATORS_NS-openstack-operators} "
1010
11- # This option is used for CI purposes and
12- # is enabled by default
13- export SOS_DECOMPRESS=${SOS_DECOMPRESS:- 1}
11+ # This option is used for CI purposes and is disabled by default
12+ export SOS_DECOMPRESS=${SOS_DECOMPRESS:- 0}
1413export BASE_COLLECTION_PATH=" ${BASE_COLLECTION_PATH:-/ must-gather} "
1514export SOS_PATH=" ${BASE_COLLECTION_PATH} /sos-reports"
1615export SOS_PATH_NODES=" ${SOS_PATH} /_all_nodes"
@@ -98,6 +97,66 @@ declare -a OSP_SERVICES=(
9897export OSP_SERVICES
9998
10099
100+ # Archive the collected data into a single downloadable file.
101+ # When SOS_DECOMPRESS=0, SOS reports are kept as .tar.xz archives and
102+ # recompressing them with XZ produces no size reduction while adding
103+ # significant time. In that case, non-SOS data is compressed separately
104+ # into an intermediate XZ archive, then bundled with the already-compressed
105+ # SOS files into a plain tar.
106+ # Otherwise (SOS_DECOMPRESS=1 or no SOS reports), a single XZ pass over
107+ # everything is used.
108+ function compress {
109+ # The path to store the compressed result
110+ local compressed_path=${COMPRESSED_PATH:- " ${BASE_COLLECTION_PATH} " }
111+ # whether to delete or keep the uncompressed files.
112+ # Defaults to keep them.
113+ local delete_after=${DELETE_AFTER_COMPRESSION:- 0}
114+ local archive
115+
116+ if [[ ${SOS_DECOMPRESS} -eq 0 ]] && \
117+ [[ -n " $( find " ${SOS_PATH} " -type f 2> /dev/null | head -1) " ]]; then
118+ archive=" ${compressed_path} /must-gather.tar"
119+ local rhoso_archive=" ${compressed_path} /rhoso-data.tar.xz"
120+
121+ # Compress only non-SOS data (CRDs, CMs, logs, DB dumps) into an
122+ # intermediate XZ archive, excluding the SOS directory entirely.
123+ tar \
124+ --exclude=' must-gather.tar' \
125+ --exclude=' rhoso-data.tar.xz' \
126+ --exclude=' sos-reports' \
127+ --warning=no-file-changed --ignore-failed \
128+ -cJf \
129+ " ${rhoso_archive} " " ${BASE_COLLECTION_PATH} " || true
130+
131+ # Bundle the intermediate archive with the SOS reports into a plain
132+ # tar (no compression) so already-compressed SOS data is not re-processed.
133+ tar \
134+ --exclude=' must-gather.tar' \
135+ --warning=no-file-changed --ignore-failed \
136+ -cf \
137+ " ${archive} " " ${rhoso_archive} " " ${SOS_PATH} " || true
138+
139+ rm -f " ${rhoso_archive} "
140+ else
141+ archive=" ${compressed_path} /must-gather.tar.xz"
142+
143+ tar \
144+ --exclude=' must-gather.tar.xz' \
145+ --warning=no-file-changed --ignore-failed \
146+ -cJf \
147+ " ${archive} " " ${BASE_COLLECTION_PATH} " || true
148+ fi
149+
150+ echo " The ${archive} now can be attached to the support case."
151+
152+ if [[ ${delete_after} -eq 1 ]]; then
153+ find " ${BASE_COLLECTION_PATH} " \
154+ -mindepth 1 \
155+ -not -path " *must-gather.tar*" \
156+ -delete
157+ fi
158+ }
159+
101160WEBHOOKS_COLLECTION_PATH=${BASE_COLLECTION_PATH} /webhooks
102161export WEBHOOKS_COLLECTION_PATH
103162
0 commit comments