Skip to content

fix: Do not fail analysis if node list does not exist #1678

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

Merged

Conversation

banjoh
Copy link
Member

@banjoh banjoh commented Nov 7, 2024

Description, Motivation and Context

When collection files from support bundles, we should not fail if node_list.json is not found. This file contains the list of nodes host bundles were collected from, not file content needing analysing.

Using the spec below, here are test results

cat spec.yaml
apiVersion: troubleshoot.sh/v1beta2
kind: HostPreflight
metadata:
  name: certificate
spec:
  collectors:
    - certificate:
        certificatePath: /etc/ssl/corp.crt
        keyPath: /etc/ssl/corp.key
  analyzers:
    - certificate:
        outcomes:
          - fail:
              when: "key-pair-missing"
              message: Certificate key pair not found in /etc/ssl
          - fail:
              when: "key-pair-switched"
              message: Cert and key pair are switched

Before

sudo preflight -v=2 --interactive=false spec.yaml
I1107 19:42:58.056605   93460 loader.go:261] Loaded 1 troubleshoot specs successfully
I1107 19:42:58.056826   93460 run.go:102] Preflight data collected in temporary directory: /tmp/preflightbundle-3189511120
[Certificate Key Pair] Running collector...

   --- FAIL: Certificate Key Pair
      --- Analyzer Failed: analyze: failed to get node list: host-collectors/system/node_list.json: not found
--- FAIL   certificate
FAILED

Saving preflight bundle to preflightbundle-2024-11-07T19_42_58.tar.gz

After

sudo preflight -v=2 --interactive=false spec.yaml
I1107 19:43:56.140479   94746 loader.go:261] Loaded 1 troubleshoot specs successfully
I1107 19:43:56.140714   94746 run.go:102] Preflight data collected in temporary directory: /tmp/preflightbundle-3861045054
[Certificate Key Pair] Running collector...
E1107 19:43:56.141531   94746 analyzer.go:94] no outcome matched for "Certificate Key Pair" host analyzer

Saving preflight bundle to preflightbundle-2024-11-07T19_43_56.tar.gz

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

@banjoh banjoh requested a review from a team as a code owner November 7, 2024 19:44
@banjoh banjoh added type::bug Something isn't working bug::regression labels Nov 7, 2024
@xavpaice xavpaice merged commit d25aa7d into replicatedhq:main Nov 7, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::regression type::bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants