Skip to content

Commit ba858e3

Browse files
authored
Fix must-gather output for omc compatibility (#4965)
* produce omc-compatible output from must-gather * Add changelog entry for must-gather omc compatibility fix * Collect logs from all pods in controller-manager deployment We need to loop over the pods (in case replicas > 1) * Update binary path to /usr/bin/gather * Change collection dir to /must-gather * Fix stale binary path in README and flag description in config * Collect logs for CR pods and consolidate must-gather e2e tests processPodsByInstance was writing pod YAML but not collecting container logs, so collector/TA/bridge pod logs were missing from must-gather output. Now iterates all containers and calls getPodLogs for each. Remove the stale must-gather check from the otlp-metrics-traces e2e test — it used the old directory layout and is fully covered by the dedicated must-gather test. * Fix omc log path and add pod YAML to log directory omc expects container logs at pods/<pod>/<container>/<container>/logs/ (container name repeated twice), not pods/<pod>/<container>/logs/. Also, omc logs discovers pods from pods/<pod>/<pod>.yaml — write pod YAML there so omc logs can find and display them. * must-gather: replace naive pluralFor with static lookup table The previous implementation appended "es"/"s" based on whether the Kind string ended in "s". This produces wrong paths for kinds like NetworkPolicy (→ "networkpolicys" instead of "networkpolicies"), which omc cannot find. Replace it with an explicit map covering all Kinds the tool collects. log.Fatalf on unknown kinds ensures omissions are caught immediately rather than silently writing to a path omc cannot parse. * Add omc validation to must-gather e2e test Download omc binary and verify it can parse the gathered output: get opentelemetrycollectors, get deployments, get pods, and logs. * Fix omc log validation by setting project before log check omc logs defaults to the 'default' project, so it couldn't find the gather-collector pod in the chainsaw-must-gather namespace.
1 parent acde6d6 commit ba858e3

12 files changed

Lines changed: 574 additions & 442 deletions

File tree

.chloggen/fix-must-gather.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: must-gather
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fix must-gather output to produce omc-compatible directory layout and correct YAML serialization
9+
10+
# One or more tracking issues related to the change
11+
issues: [4965]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: |
17+
Previously collected files used a per-collector directory with kind-prefixed filenames (e.g. `namespaces/<ns>/<collector-name>/deployment-<name>.yaml`),
18+
which omc cannot parse. Output now follows the standard omc layout (`namespaces/<ns>/<api-group>/<resource-plural>/<name>.yaml`).
19+
Also fixes missing apiVersion/kind fields in serialized YAML, incorrect default output directory, and adds collection of CRDs and OpAMPBridge resources.

cmd/gather/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ RUN INSTALL_PKGS=" \
99
WORKDIR /
1010

1111
ARG TARGETARCH
12-
COPY bin/must-gather_${TARGETARCH} /usr/bin/must-gather
12+
COPY bin/must-gather_${TARGETARCH} /usr/bin/gather
1313

1414
USER 65532:65532
1515

16-
ENTRYPOINT ["/usr/bin/must-gather"]
16+
ENTRYPOINT ["/usr/bin/gather"]

cmd/gather/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This is the recommended way to do it if you are not using OpenShift.
2424
If you want to use the image in a running cluster, you need to run the following command:
2525

2626
```sh
27-
oc adm must-gather --image=ghcr.io/open-telemetry/opentelemetry-operator/must-gather -- /usr/bin/must-gather --operator-namespace opentelemetry-operator-system
27+
oc adm must-gather --image=ghcr.io/open-telemetry/opentelemetry-operator/must-gather -- /usr/bin/gather --operator-namespace opentelemetry-operator-system
2828
```
2929

3030
### Using it as a CLI

0 commit comments

Comments
 (0)