This is a clone of issue OCPBUGS-19942. The following is the description of the original issue:
—
This is a clone of issue OCPBUGS-16735. The following is the description of the original issue:
—
Description of problem:
oc adm inspect generated files sometime have the leading "---" and some time do not. This depends on the order of objects collected. This by itself is not an issue. However this becomes an issue when combined with multiple invocations of oc adm inspect and collecting data to the same directory like must-gather does. If an object is collected multiple times then the second time oc might overwrite the original file improperly and leave 4 bytes of the original content behind. This is happening when not writing the "---\n" in the second invocation as this makes the content 4B shorter and the original tailing 4B are left in the file intact. This garbage confuses YAML parsers.
Version-Release number of selected component (if applicable):
4.14 nighly as of Jul 25 and before
How reproducible:
Always
Steps to Reproduce:
Run oc adm inspect twice with different order of objects: [msivak@x openshift-must-gather]$ oc adm inspect performanceprofile,machineconfigs,nodes --dest-dir=inspect.dual --all-namespaces [msivak@x openshift-must-gather]$ oc adm inspect nodes --dest-dir=inspect.dual --all-namespaces And then check the alphabetically first node yaml file - it will have garbage at the end of the file.
Actual results:
Garbage at the end of the file.
Expected results:
No garbage.
Additional info:
I believe this is caused by the lack of Truncate mode here https://github.com/openshift/oc/blob/master/pkg/cli/admin/inspect/writer.go#L54 Collecting data multiple times cannot be easily avoided when multiple collect scripts are combined with relatedObjects requested by operators.
- blocks
-
OCPBUGS-20293 oc adm inspect does not truncate files when overwriting
- Verified
- clones
-
OCPBUGS-19942 oc adm inspect does not truncate files when overwriting
- Closed
- is blocked by
-
OCPBUGS-20291 oc adm inspect does not truncate files when overwriting
- Closed
- links to
-
RHBA-2023:6272 OpenShift Container Platform 4.11.z bug fix update