Commit Graph

88 Commits

Author SHA1 Message Date
Evans Mungai
aea4f7c87c feat: Optionally save preflight bundles to disk (#1612)
* feat: Optionally save preflight bundles to disk

Signed-off-by: Evans Mungai <evans@replicated.com>

* Add e2e test of saving preflight bundle

Signed-off-by: Evans Mungai <evans@replicated.com>

* Update cli docs

Signed-off-by: Evans Mungai <evans@replicated.com>

* Expose GetVersionFile function publicly

Signed-off-by: Evans Mungai <evans@replicated.com>

* Store analysis.json file in preflight bundle

Signed-off-by: Evans Mungai <evans@replicated.com>

* Run go fmt when running lint fixers

Signed-off-by: Evans Mungai <evans@replicated.com>

* Always generate a preflight bundle in CLI

Signed-off-by: Evans Mungai <evans@replicated.com>

* Print saving bundle message to stderr

Signed-off-by: Evans Mungai <evans@replicated.com>

* Revert changes in docs directory

Signed-off-by: Evans Mungai <evans@replicated.com>

* Use NewResult constructor

Signed-off-by: Evans Mungai <evans@replicated.com>

* Log always when preflight bundle is saved to disk

Signed-off-by: Evans Mungai <evans@replicated.com>

---------

Signed-off-by: Evans Mungai <evans@replicated.com>
2024-09-16 23:36:52 +01:00
dependabot[bot]
bd6c5b976d chore(deps): bump the security group across 1 directory with 16 updates (#1604)
* chore(deps): bump the security group across 1 directory with 16 updates

Bumps the security group with 12 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/containers/image/v5](https://github.com/containers/image) | `5.32.1` | `5.32.2` |
| [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) | `1.7.5` | `1.7.6` |
| [github.com/vmware-tanzu/velero](https://github.com/vmware-tanzu/velero) | `1.14.0` | `1.14.1` |
| [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) | `1.28.0` | `1.29.0` |
| [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) | `1.28.0` | `1.29.0` |
| [k8s.io/api](https://github.com/kubernetes/api) | `0.30.3` | `0.31.0` |
| [k8s.io/apiextensions-apiserver](https://github.com/kubernetes/apiextensions-apiserver) | `0.30.3` | `0.31.0` |
| [k8s.io/cli-runtime](https://github.com/kubernetes/cli-runtime) | `0.30.3` | `0.31.0` |
| [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) | `0.18.5` | `0.19.0` |
| [helm.sh/helm/v3](https://github.com/helm/helm) | `3.15.3` | `3.15.4` |
| [k8s.io/kubelet](https://github.com/kubernetes/kubelet) | `0.30.3` | `0.31.0` |
| [k8s.io/metrics](https://github.com/kubernetes/metrics) | `0.30.3` | `0.31.0` |



Updates `github.com/containers/image/v5` from 5.32.1 to 5.32.2
- [Release notes](https://github.com/containers/image/releases)
- [Commits](https://github.com/containers/image/compare/v5.32.1...v5.32.2)

Updates `github.com/hashicorp/go-getter` from 1.7.5 to 1.7.6
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/go-getter/compare/v1.7.5...v1.7.6)

Updates `github.com/vmware-tanzu/velero` from 1.14.0 to 1.14.1
- [Release notes](https://github.com/vmware-tanzu/velero/releases)
- [Changelog](https://github.com/vmware-tanzu/velero/blob/main/CHANGELOG.md)
- [Commits](https://github.com/vmware-tanzu/velero/compare/v1.14.0...v1.14.1)

Updates `go.opentelemetry.io/otel` from 1.28.0 to 1.29.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.28.0...v1.29.0)

Updates `go.opentelemetry.io/otel/sdk` from 1.28.0 to 1.29.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.28.0...v1.29.0)

Updates `k8s.io/api` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/api/compare/v0.30.3...v0.31.0)

Updates `k8s.io/apiextensions-apiserver` from 0.30.3 to 0.31.0
- [Release notes](https://github.com/kubernetes/apiextensions-apiserver/releases)
- [Commits](https://github.com/kubernetes/apiextensions-apiserver/compare/v0.30.3...v0.31.0)

Updates `k8s.io/apimachinery` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.30.3...v0.31.0)

Updates `k8s.io/apiserver` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/apiserver/compare/v0.30.3...v0.31.0)

Updates `k8s.io/cli-runtime` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/cli-runtime/compare/v0.30.3...v0.31.0)

Updates `k8s.io/client-go` from 0.30.3 to 0.31.0
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.30.3...v0.31.0)

Updates `sigs.k8s.io/controller-runtime` from 0.18.5 to 0.19.0
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.18.5...v0.19.0)

Updates `helm.sh/helm/v3` from 3.15.3 to 3.15.4
- [Release notes](https://github.com/helm/helm/releases)
- [Commits](https://github.com/helm/helm/compare/v3.15.3...v3.15.4)

Updates `k8s.io/kubelet` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/kubelet/compare/v0.30.3...v0.31.0)

Updates `k8s.io/metrics` from 0.30.3 to 0.31.0
- [Commits](https://github.com/kubernetes/metrics/compare/v0.30.3...v0.31.0)

Updates `k8s.io/utils` from 0.0.0-20230726121419-3b25d923346b to 0.0.0-20240711033017-18e509b52bc8
- [Commits](https://github.com/kubernetes/utils/commits)

---
updated-dependencies:
- dependency-name: github.com/containers/image/v5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: security
- dependency-name: github.com/hashicorp/go-getter
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: security
- dependency-name: github.com/vmware-tanzu/velero
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: security
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/apiextensions-apiserver
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/apiserver
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/cli-runtime
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: helm.sh/helm/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: security
- dependency-name: k8s.io/kubelet
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/metrics
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: security
- dependency-name: k8s.io/utils
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: security
...

Signed-off-by: dependabot[bot] <support@github.com>

* Run go mod tidy

Signed-off-by: Evans Mungai <evans@replicated.com>

* Update schemas and thier generator tools

* controller-gen to v0.16.2
* client-gen to v0.28.13

Signed-off-by: Evans Mungai <evans@replicated.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Evans Mungai <evans@replicated.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evans Mungai <evans@replicated.com>
2024-09-04 15:54:07 +12:00
Gerard Nguyen
47656a8e6f feat: etcd collector (#1589)
* new schema for etcd collector

* add placeholder

* wip

* get supported distribution

* add exec implementation

* wait for etcd pod to be ready

* misc

* update k0s etcd certs path

* fix unit tests

* address code reviews

* update from code review

* add etcdctl version
2024-08-13 08:42:26 +10:00
Evans Mungai
123d17ab4a feat: node metrics collector (#1516)
* feat: node metrics collector

A collector to collect node metrics served by the API server as
per the documented API https://kubernetes.io/docs/reference/instrumentation/node-metrics/

* Update CRD schemas

* Add tests

* Remove clean from build target

* Update comments

* Commit missing tests

* Remove unnecessary log in tests
2024-04-02 14:59:55 +01:00
Evans Mungai
ca5ff88964 chore: Update code generator and controller tools (#1515) 2024-03-28 11:52:15 +00:00
Ethan Mosbaugh
e24ca642aa feat: sonobuoy collector (#1469) 2024-02-16 06:56:15 -08:00
Evans Mungai
e2adfa3774 fix: Correct selector used to find installer specs when redacting (#1456) 2024-02-07 10:36:15 +00:00
Diamon Wiggins
1447e18c56 feat: Allow templating of outcome messages for the JSON/YAML compare analyzers (#1432)
* feat: allow templating of the outcome message for the JSON and YAML Compare analyzers

* Update pkg/analyze/json_compare.go

Co-authored-by: Evans Mungai <evans@replicated.com>
2024-01-26 10:56:57 -05:00
Evans Mungai
37a5cce8ce chore: minor updates to docs and Makefile (#1433)
* Deprecate old Makefile targets
* Name Makefile targets to point to files they 'make' as per convention
* Update the contributing doc
* Update CLI docs left behind
2024-01-25 18:55:51 +00: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
f3d49c657f chore: Do not create package json files (#1347) 2023-10-02 14:32:33 +13:00
ada mancini
543931631b Local watch script (#1304)
* local watch script for building troubleshoot
2023-08-25 15:12:22 +12:00
Dexter Yan
38ff340883 feat(e2e): add e2e go test for support-bundler (#1265) 2023-08-25 14:43:09 +12:00
Evans Mungai
73201c0304 feat: Add regex host analyser (#1267)
* feat: Add regular expressions host anaylser

This anaylser is the same as the in-cluster text anaylser. You pass in
search expressions to find values in files collected in a bundle

* additional test assertion to check analyser warn
2023-07-18 07:18:53 +12:00
Evans Mungai
f64d98b5c3 feat(examples): loading troubleshoot specs from helm chart example (#1252)
* feat(examples): loading troubleshoot specs from helm chart example
2023-06-29 13:31:59 +12:00
Evans Mungai
145bad7e8e chore: add make target to build all binaries together (#1211)
Add make build target that builds all troubleshoot binaries in parallel
using -j make flag that lets make run all make sub-targets as separate jobs
2023-06-06 10:15:28 -04:00
ada mancini
41cd7c2aa4 watchrsync job to push binaries to a test machine (#1158)
* ignore some more stuff

* watchrsync make command like kurl project

* document watchrsync

* the actual watchrsync script

* dont need these for npm dependencies

* Revert "dont need these for npm dependencies"

This reverts commit bdb4e62c38.

* install gaze-run-interrupt with make

* watchrsync instructions
2023-06-05 10:35:25 -04:00
Evans Mungai
27c68a7e53 chore: update deprecated trivy cli option (#1197) 2023-05-31 10:49:58 -04:00
Evans Mungai
a86d9435a8 feat(collector): Add host collector to copy files to a bundle (#1068)
* Boiler plate for host copy collector

* feat: Add copy host collector

* Add tests

* No need to handle symlinks in a special way

System libraries (os.ReadAll, os.ReadDir) already handle symlinks
2023-04-05 15:43:38 +01:00
Evans Mungai
546ffde14b feat: use klog as the default logging library (#1008) 2023-02-24 18:24:51 +00:00
Tom Wieczorek
752dacd5ed chore: Don't print which error in Makefile (#1012)
The which binary is used to detect if client-gen is installed, and if
it's not, the Makefile will install it. The initial detection prints
an error if it's not found. This is misleading, as it is actually an
expected situation.
2023-02-10 17:26:16 +00:00
Tom Wieczorek
49fe355086 chore: Don't hardcode /bin/bash (#1011)
Bash is not always installed in /bin/bash. Mitigate that by relying on
bash being in PATH.
2023-02-10 17:25:57 +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
Camila Macedo
f27c64cf85 chore: chore: update binaries used to build manifests and k8s (#997)
- client-gen version from v0.22.0 to v0.26.1
- controller-gen version from v0.7.0 to v0.11.2
- k8s pacth from 1.26.0 to 1.26.1
2023-02-01 17:06:46 +00:00
Evans Mungai
c62e71a578 chore: Filter tests to run when calling make test (#983) 2023-01-27 11:48:43 +13:00
Nathan Sullivan
827c49ca00 adding test coverage for preflight.RunPreflights() (#949)
* adding test coverage for preflight.RunPreflights()

TDD to work on https://github.com/replicatedhq/troubleshoot/issues/906
and verify the fix is successful

* go.mod/go.sum: removing gnomock stuff since it's not in use (yet)

* Makefile: try running the preflight integration test with the e2e tests,
since there's a K3s instance in place already

* Makefile add a dedicated test-integration task, which runs as it's own
github action job

* Makefile: exclude a few things from test-integration that break the
github action job

* WIP on preflight tests, addressing some of @banjoh's feedback, more to
go though (specifically changing over to using assert)

* preflight tests: use the testify libraries, restructure code to be
formatted more like other tests in this project
2023-01-13 08:22:57 +10: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
Evans Mungai
b693e6650d chore: Add GH workflow to ensure schemas are generated in a PR (#872)
* Make file target to check generated schemas

* Add missing yaml tag to Logs struct

* chore: Add GH workflow to ensure schemas are generated in a PR
2022-11-28 10:58:09 +13:00
Xav Paice
48faf0c144 Revert "Add ghcr to package releases (#848)" (#868)
This reverts commit 233966d4be.
2022-11-22 17:14:04 +13: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
Chris Sanders
233966d4be Add ghcr to package releases (#848) 2022-11-17 11:12:54 +13:00
Evans Mungai
e02074941e Add golangci-lint linter make target (#752)
Add line, and lint-and-fix make targets
2022-10-10 09:52:02 +13:00
Diamon Wiggins
a0fb06f0b9 E2E Tests for Support Bundle CLI (#761)
* adding e2e tests for support bundle cli

* update e2e.yaml
2022-10-07 14:43:16 +13:00
Pavan Sokke Nagaraj
3da43b18c9 remove redundant client-gen code 2022-06-02 19:33:47 -04:00
Ethan Mosbaugh
d3cf4fc7f4 Run e2e tests locally 2022-06-02 13:41:00 +00:00
Ethan Mosbaugh
d2d19a2490 Change build step name to test 2022-05-17 17:20:45 +00:00
Ethan Mosbaugh
5c269e2aaf E2E preflight tests 2022-05-17 17:20:45 +00:00
Pavan Sokke Nagaraj
9ec9806b62 add cve scan github cron action (#572) 2022-05-10 13:52:30 -04:00
Ethan Mosbaugh
177f2da16d Update github.com/containers/image/v5 2021-11-30 23:37:25 +00:00
Ethan Mosbaugh
59d50e7679 Fix go mod 2021-11-30 21:26:24 +00:00
Andrew Reed
7b36e6a1f8 Copy in longhorn client (#454) 2021-10-22 15:24:07 -05:00
Simon Croome
977fc438ea Remote host collectors (#392)
* Add collect command and remote host collectors

Adds the ability to run a host collector on a set of remote k8s nodes.
Target nodes can be filtered using the --selector flag, with the same
syntax as kubectl.  Existing flags for --collector-image,
--collector-pullpolicy and --request-timeout are used.  To run on a
specified node, --selector="kubernetes.io/hostname=kind-worker2" could
be used.

The collect command is used by the remote collector to output the
results using a "raw" format, which uses the filename as the key, and
the value the output as a escaped json string.  When run manually it
defaults to fully decoded json. The existing block devices,
ipv4interfaces and services host collectors don't decode properly - the
fix is to convert their slice output to a map (fix not included as
unsure what depends on the existing format).

The collect command is also useful for troubleshooting preflight issues.

Examples are included to show remote collector usage.

```
bin/collect --collector-image=croomes/troubleshoot:latest  examples/collect/remote/memory.yaml --namespace test
{
  "kind-control-plane": {
    "system/memory.json": {
      "total": 1304207360
    }
  },
  "kind-worker": {
    "system/memory.json": {
      "total": 1695780864
    }
  },
  "kind-worker2": {
    "system/memory.json": {
      "total": 1726353408
    }
  }
}
```

The preflight command has been updated to run remote collectors.  To run
a host collector remotely it must be specified in the spec as a
`remoteCollector`:

```
apiVersion: troubleshoot.sh/v1beta2
kind: HostPreflight
metadata:
  name: memory
spec:
  remoteCollectors:
    - memory:
        collectorName: memory
  analyzers:
    - memory:
        outcomes:
          - fail:
              when: "< 8Gi"
              message: At least 8Gi of memory is required
          - warn:
              when: "< 32Gi"
              message: At least 32Gi of memory is recommended
          - pass:
              message: The system has as sufficient memory
```

Results for each node are analyzed separately, with the node name
appended to the title:

```
bin/preflight --interactive=false --collector-image=croomes/troubleshoot:latest examples/preflight/remote/memory.yaml --format=json
{memory running 0 1}
{memory completed 1 1}
{
  "fail": [
    {
      "title": "Amount of Memory (kind-worker2)",
      "message": "At least 8Gi of memory is required"
    },
    {
      "title": "Amount of Memory (kind-worker)",
      "message": "At least 8Gi of memory is required"
    },
    {
      "title": "Amount of Memory (kind-control-plane)",
      "message": "At least 8Gi of memory is required"
    }
  ]
}
```

Also added a host collector to allow preflight checks of required kernel
modules, which is the main driver for this change.
2021-10-06 09:03:53 -05:00
Salah Aldeen Al Saleh
1bdd3db8c5 update schemas (#428)
* update schemas

* update controller-gen
2021-09-23 11:03:19 -07:00
John Murphy
639bf7a832 Add signed SBOM to troubleshoot (#414)
This change will generate a signed software bill of materials and add it to the repository release archives when the project is released.
2021-09-21 13:55:41 -05:00
Salah Aldeen Al Saleh
ac2a0484e2 add build flags to ffi (#349) 2021-04-12 11:23:46 -07:00
divolgin
7a0c6e5383 use containers package instead of go-containerregistry 2021-04-11 21:39:44 +00:00
Marc Campbell
c7fdec0291 Removing Scopeagent 2021-01-28 18:22:48 +00:00
divolgin
9e669b3f13 Remove RRD dependency and switch to dynamic linking 2020-11-12 19:13:25 +00:00
divolgin
5a1321da02 Collector and analyzer for RRD data 2020-11-10 17:19:17 +00:00
divolgin
a0ce85ae1e Adding troubleshoot.sh/v1beta2 2020-09-01 19:57:11 +00:00