216 Commits

Author SHA1 Message Date
Gerard Nguyen
191ebdb598 feat: [sc-106759] Troubleshoot: uri field only download when we're not downloading (#1567)
* remove uri: when url is provided
2024-06-24 10:12:41 +10:00
Gerard Nguyen
fb0f81d076 bug: [sc-103753] Host analysers are not deduplicating during multiple spec merges #1485 (#1542)
* dedupe host collector and analyzer

* dedup analyzer

* add unit test

* use generic
2024-05-17 09:34:29 +10:00
Gerard Nguyen
088f0321e7 feat: [sc-103119] URI is not replacing the spec but merging instead (#1541)
* only replace spec that has uri

* add unit test

* fix unit tests from code review
2024-05-03 11:36:27 +01:00
Evans Mungai
aeaac7a70f Revert "feat: URI is not replacing the spec but merging instead (#1537) (#1539)
Revert "feat: [sc-103119] URI is not replacing the spec but merging instead (#1537)"

This reverts commit c2f72ecd0c.
2024-05-01 14:38:46 +01:00
Gerard Nguyen
c2f72ecd0c feat: [sc-103119] URI is not replacing the spec but merging instead (#1537)
fix uri spec to replace origin spec
2024-04-30 14:13:35 +12:00
Evans Mungai
c9830de736 chore: Update CLI prompt to run command as root (#1517) 2024-03-28 19:13:33 +00:00
Evans Mungai
e6aff48f1b feat: Prompt for privileged user if host collectors present in spec (#1513)
* feat: Prompt for privileged user if host collectors present

* Prompt preflight checks that have host collectors

* Show cursor before prompting
2024-03-28 11:51:19 +00:00
Evans Mungai
e4363a1e50 fix (supportbundle): Add default collectors when expected (#1418)
* fix (supportbundle): Add default collectors when expected

* Remove unnecessary change

* Add default collectors to a empty spec

* Add more tests
2024-01-08 11:32:04 +00:00
Evans Mungai
e5e26eea14 fix(support-bundle): default in-cluster collectors in host support bundle (#1394)
* fix(support-bundle): default in-cluster collectors in host support bundle

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

* Various improvements

* Improve error messages
* Util function appending elements to a nil slice that allows adding
  specs to an empty slice of collectors/analysers/redactors

* Fix failing test
2023-11-27 18:33:02 +00:00
Diamon Wiggins
08c3fcf3df Gracefully handle unreachable URIs in loadSupportBundleSpecsFromURIs (#1383)
* gracefully handle unreachable URIs in loadSupportBundleSpecsFromURIs

* let caller decide how to handle the error

* fix klog import

* Add a test to ensure failing to load uri does not error

---------

Co-authored-by: Evans Mungai <evans@replicated.com>
2023-10-27 14:48:09 +01:00
Evans Mungai
312e467160 fix: embed troubleshoot version string from module dependency (#1371)
If troubleshoot is used as a dependency in go.mod, the version
information of the release would be missing at runtime. This is
because the version string is injected to binaries at build time
using linker flags (LD) passed to the compiler (check Makefile)
2023-10-16 13:51:55 +01:00
Evans Mungai
15a4802cd2 feat: Add dry run flag to print support bundle specs to std out (#1337)
* Add dry-run flag

* No traces on dry run

* More refactoring

* More updates to support bundle binary

* More refactoring changes

* Different approach of loading specs from URIs

* Self review

* More changes after review and testing

* fix how we parse oci image uri

* Remove unnecessary comment

* Add missing file

* Fix failing tests

* Better error check for no collectors

* Add default collectors when parsing support bundle specs

* Add missed test fixture

* Download specs with correct headers

* Fix typo
2023-10-10 18:43:32 +01:00
Evans Mungai
73a2d882d7 fix: Store custom resources in JSON & YAML format (#1360)
fix: Store custom resources as JSON and YAML files
2023-10-10 17:50:15 +01:00
Evans Mungai
b9f4fc4390 feat: Dry run flag to print preflight specs to std out (#1240) 2023-09-12 14:42:10 +01:00
Evans Mungai
ff03bfa9cd chore: make spec loaders internal APIs (#1313)
* chore: make specs an internal package

* Some minor improvements

* Use LoadClusterSpecs in support bundle implementation

* Remove change accidentally committed

* Use LoadFromCLIArgs in preflight CLI implementation

* Update comment

* Fix edge case where the label selector is an empty string

* Fix failing test
2023-08-30 14:02:30 +01:00
Dexter Yan
f0efbf658a fix(message): solve the terminal UI issue of truncating the message if it is long (#1242) 2023-06-28 11:06:15 +12:00
Dexter Yan
f9dbccd354 feat(support-bundle): add support labels for troubleshoot.io and troubleshoot.sh (#1203) 2023-06-08 16:05:35 +01:00
Evans Mungai
401dfe2c57 feat: add loader APIs to load specs from raw troubleshoot spec (#1202)
* feat: add loader APIs to load specs from a list of yaml docs

The change introduces a loader package that will contain loader
public APIs. The aim of these APIs will be to, given any source of
troubleshoot specs, the loaders will fetch the specs and parse out
all troubleshoot objects that can be extracted.

* Some refactoring

* Some more changes

* More changes caught when testing vendor portal

* Add tests and rename Troubleshoot kinds struct

* Additional test

* Handle ConfigMap and Secrets with multiple specs in them

* Fix failing test

* Revert multidoc split implementation

* Fix merge conflict

* Change LoadFromXXX functions to a single LoadSpecs function
2023-06-06 16:48:29 -04:00
Evans Mungai
1939f5464d fix (support-bundle): Ensure specs are merged correctly (#1181)
When the support-bundle cli is used with --load-cluster-specs,
not all discovered specs are merged into the spec used to collect
data.

Fixes: #1179
2023-05-26 13:43:57 +01:00
Nathan Sullivan
3548b46cfc support multiple exit codes based on what went wrong/right (#1135)
0 = all passed, 3 = at least one failure, 4 = no failures but at least 1 warn

1 as a catch all (generic errors), 2 for invalid input/specs etc

ref https://github.com/replicatedhq/troubleshoot/issues/1131

docs https://github.com/replicatedhq/troubleshoot.sh/pull/489
2023-05-10 09:33:13 +10:00
danj-replicated
285631446e Add ability to fetch preflights from OCI registry to standard out (#1117)
* add oci-fetch command
2023-04-14 11:25:42 +12:00
Evans Mungai
dc1687a76a fix: Discover specs from namespaces user is allowed (#1098)
* fix: Discover specs from namespaces user is allowed

If a user has limited access to read secrets and config maps
from certain namespaces in a cluster, we'd need to gracefully
fail when forbidden errors are caught. We'll log them and continue
searching for specs in other namespaces.
2023-04-05 18:50:46 +12:00
Dexter Yan
79f8e6efab feat(support-bundle): check if the cluster IsNamespacedScopeRBAC and use current namespace (#1055)
feat(support-bundle): add IsNamespacedScope check
2023-03-22 11:33:54 -04:00
Evans Mungai
546ffde14b feat: use klog as the default logging library (#1008) 2023-02-24 18:24:51 +00:00
Tom Wieczorek
9f6739fdbe feat(support-bundle): print progress in debug non-interactive mode (#1010)
Currently, there's no debug logs whatsoever when running a command like

    troubleshoot --debug --interactive=false

Tackle this by printing similar log statements as presented in
interactive mode to the debug logger. Refactor the code a bit so there's
no need for a dedicated finished channel and to exit the goroutines
properly.

Co-authored-by: Evans Mungai <evans@replicated.com>
2023-02-15 19:13:35 +00:00
Tom Wieczorek
e85e91e784 chore: remove unused code (#1013)
Remove code snippets that are not used across the codebase.
2023-02-10 17:27:50 +00:00
Evans Mungai
100f9a13b6 feat: Record summary of execution times of support bundle operations (collect/redact/analyse) (#935)
When running a support bundle, we want to know how long each operation
(collect, redact, analyze) takes. This commit adds a new trace exporter
that records the start and end times of each operation, and then prints
a summary of the execution. The summary is also stored in the support
bundle.

Related to #923
2023-02-07 09:50:21 +00:00
yunju.lly
1114902707 refactor: keep support bundle concat logic to be consistent with Preflight concat (#1002)
* refactor: keep support bundle concat logic to be consistent with Preflight
* test: add tests for support bundle spec concat function
2023-02-03 11:05:11 +00:00
Diamon Wiggins
4fca6aff98 Deduplication for In-Cluster Collectors (#972)
* adding dedup for in cluster collectors

* add tests

* return collector as is whenever marshalling to json fails

---------

Co-authored-by: Evans Mungai <evans@replicated.com>
2023-02-01 14:14:43 -05:00
Dexter Yan
962e2c7d7e feat(support-bundle): optimize the error log of ceph and longhorn when kURL add-on were not enabled (#943) 2023-01-10 09:37:42 +13:00
Evans Mungai
a31e2ff1b9 chore: Add CLI flags to enable CPU & memory profiling (#926)
Allow collecting of CPU and memory diagnostics when running troubleshoot CLI applications using --memprofile and --cpuprofile flags. These flags accept file paths if where to store the collected runtime data
2023-01-04 11:56:07 +00:00
Evans Mungai
a523551da9 feat(redactors): Run redactors on an existing support bundle (#887)
* feat(redactors): Run redactors on an existing support bundle

Add redact subcommand to support-bundle to allow running redactors on an
existing bundle to creating a new redacted bundle.

The command will be launched like so

support-bundle redact <redactor urls> --bundle support-bundle.tar.gz

Fixes: #705
2023-01-03 18:05:15 +00:00
ada mancini
e2053a00a2 rename the troubleshoot label to "support-bundle" (#918) 2022-12-22 19:00:05 -03:00
Diamon Wiggins
f2be6f5829 Allow Preflight CLI to consume multiple specs as input (#894)
To keep both the Support Bundle and Preflight CLIs similar, this PR adds the ability for the Preflight binary to allow multiple specs be provided as CLI args and for them all to be run.
2022-12-14 14:50:01 -04:00
Xav Paice
6530cb364f feat: Add docsgen command (#862)
* feat: Add docsgen command

* docs: add CLI docs for support-bundle and preflight
2022-11-21 11:31:08 -05:00
Diamon Wiggins
c34d80c300 Discover Redactors in Cluster (#827)
Adds the ability to search for support bundle specs and redactors, in both configmaps and secrets
2022-11-10 17:36:51 +13:00
Xav Paice
3513eeca19 Ensure clusterResources is added prior to other collectors (#768)
This change ensures that the clusterResources collector runs prior to any others
in order to not collect info on pods that collectors run during collection.

Additionally centralizes functions that are common to all collection to make future
maintenance simpler.

Fixes: #767
2022-11-01 12:16:01 +13:00
stefanrepl
9c986a74a6 make runPreflight and preflight cli flags public (#769) 2022-10-10 16:34:54 -06:00
Edgar Lanting
56a68a4fef Issue #695 - Add --no-uri flag to support-bundle to ignore the uri field and revert back to the default spec… (#717)
Add --follow-uri flag to support-bundle to ignore the uri field when set in a spec

Implement the new CLI flag in `root.go` so we can pass it if we need to ignore the `uri` field in a spec. This also serves as a minimal documentation effort when running `support-bundle --help`.

Fixes: #695
2022-10-10 07:30:21 +13:00
Evans Mungai
906fa88119 Fit wrapped long url in more information analyser message (#758) 2022-10-06 10:21:52 +13:00
Diamon Wiggins
c7b84ad1e5 Refactor in-clusters collectors to use struct per collector (#670)
refactor in-clusters collectors to use struct per collector
2022-10-03 13:53:05 -04:00
Diamon Wiggins
44ae409081 fix concat spec for cluster secrets (#750) 2022-09-30 08:24:33 +13:00
Diamon Wiggins
b66145e514 fixing logger statements 2022-09-14 11:56:16 -04:00
Diamon Wiggins
be070c98e1 add handling for when no collectors or host collectors are specified 2022-09-14 11:19:44 -04:00
Diamon Wiggins
7eecf6c526 improving error handling 2022-09-14 10:58:08 -04:00
Diamon Wiggins
126346e1fe update run.go 2022-09-14 00:57:33 -04:00
Diamon Wiggins
e7fe012f2f handling when no args are provided 2022-09-14 00:36:04 -04:00
Diamon Wiggins
e53871b4dc adding tests 2022-09-13 23:00:57 -04:00
Diamon Wiggins
93da8b6ac7 change name of flag 2022-09-13 18:42:33 -04:00
Diamon Wiggins
7120516b13 fixing description for cli flags 2022-09-11 18:39:55 -04:00