Skip to content

Pod Logs may not be written to bundle when name property is omitted #1784

@diamonwiggins

Description

@diamonwiggins

Pod Logs may not be written to bundle when name property is omitted

Bug Description

When the name property is omitted from a logs collector, the symlinks for pod logs may be created with a leading slash in the path. This can lead to inconsistent behavior where the logs might not be properly written to or accessible in the support bundle.

Expected Behavior

It's actually not clear what we want the expected behavior to be here. In our docs on troubleshoot.sh, we document that the name property is required.

https://troubleshoot.sh/docs/collect/logs/

However, i've seen many references of people omitted name without issue, and I was able to omit it without issue testing locally, so it's not clear exactly why this happens

Steps To Reproduce

  1. Create a support bundle specification without a name property in the logs collector:
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
spec:
  collectors:
    - logs:
        selector:
          - app=my-application
  1. Run the support bundle collection:
kubectl support-bundle ./bundle-spec.yaml
  1. Examine the generated bundle - you might find that logs are missing or not accessible through the expected paths.

The issue resides in pkg/collect/logs.go where the linkRelPathPrefix is created from the collector name:

// TODO: If collectorName is empty, the path is stored with a leading slash
// Retain this behavior otherwise analysers in the wild may break
linkRelPathPrefix := fmt.Sprintf("%s/%s", collectorName, pod.Name)

When collectorName is empty, this results in a path starting with / which can cause issues with path normalization and symlink creation in the bundle.

Additional Context

The issue exists in the codebase as a known issue (marked with a TODO comment), but it can lead to real-world problems where logs are not properly included in support bundles. This affects all use cases where users omit the name property from logs collectors.

  • Operating system: Affects all platforms where Troubleshoot is used
  • Troubleshoot version: All recent versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    type::bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions