Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(support-bundle): default in-cluster collectors in host support bundle #1394

Conversation

banjoh
Copy link
Member

@banjoh banjoh commented Nov 23, 2023

Description, Motivation and Context

Ensure cluster-resources and cluster-info collectors are present only when a support bundle spec contains in-cluster collectors.

If there is not running cluster, support-bundle logs an error like below which leads users to think that the support bundle was not generated. A follow-up PR will be created to fix that message.

[evans] $ support-bundle examples/collect/host/cpu.yaml

Error: failed to run collect and analyze process: failed to run collectors: failed to check RBAC for collectors: failed to run subject review: Post "http://localhost:8080/apis/authorization.k8s.io/v1/selfsubjectaccessreviews": dial tcp [::1]:8080: connect: connection refused
✘-1 ~/repos/replicated/troubleshoot [main {origin/main}|✚ 4…9⚑ 7]

Fixes: #1393

Checklist

  • New and existing tests pass locally with introduced changes.
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • Yes
  • No

…ndle

Ensure cluster-resources and cluster-info collectors are present only
when a support bundle spec contains in-cluster collectors.
@banjoh banjoh requested a review from a team as a code owner November 23, 2023 18:45
@banjoh banjoh added bug::regression type::bug Something isn't working type::feature New feature or request and removed bug::regression type::bug Something isn't working type::feature New feature or request labels Nov 23, 2023
Copy link
Member

@xavpaice xavpaice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is failing tests, but it is?

* Improve error messages
* Util function appending elements to a nil slice that allows adding
  specs to an empty slice of collectors/analysers/redactors
@banjoh banjoh force-pushed the em/remove-in-cluster-collectors-from-host-support-bundle branch from 840dca4 to 799c55a Compare November 24, 2023 17:21
@banjoh
Copy link
Member Author

banjoh commented Nov 24, 2023

not sure why this is failing tests, but it is?

Its a valid issue. I've fixed it in this commit. Essentially, a bug surfaced itself when collecting a support bundle using a spec like below

apiVersion: troubleshoot.sh/v1beta2
kind: Collector
metadata:
  name: collector-sample
spec:
  collectors: []

Golang treats empty slices the same as nil slices when it comes to its built in functions such as append(), len() etc. That last commit handles that peculiar behaviour.

@banjoh
Copy link
Member Author

banjoh commented Nov 27, 2023

@xavpaice tests have been fixed

@banjoh banjoh merged commit e5e26ee into replicatedhq:main Nov 27, 2023
25 checks passed
@banjoh banjoh deleted the em/remove-in-cluster-collectors-from-host-support-bundle branch November 27, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::normal type::bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default cluster-resources and cluster-info collectors added in host only support bundle
4 participants