troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

Add support for CPU architecture to cpu host collector/analyser

Open banjoh opened this issue 1 year ago • 0 comments

Describe the rationale for the suggested feature.

In some environments, someone may want to check what CPU architecture the system is running on so as to be able to perform preflight checks before deployments e.g an application that's not built for ARM may have a preflight failure for arm64 architecture

Describe the feature

Extent https://troubleshoot.sh/docs/host-collect-analyze/cpu/ host collector/analyser

  • Collect KernelArch value from https://pkg.go.dev/github.com/shirou/gopsutil/[email protected]/host#InfoStat and store in a new machineArch field. This value will be the output of uname -m
  • Extend the analyser to allow checking machineArch values like so
  hostAnalyzers:
    - cpu:
        checkName: "Check machine architecture"
        outcomes:
          - fail:
              when: "machineArch != x86_64"
              message: This server is not x86_64
          - fail:
              when: "machineArch == amd64"
              message: This server is amd64
  • Add Info.MachineArch template to allow crafting outcome messages such as {{ Info.MachineArch }} machine architecture is not supported

Describe alternatives you've considered

One can use a combination of run collector and regex analyser like so to achieve the same result. The message template bit would be missing though

apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
  name: run
spec:
  hostCollectors:
    - run:
        collectorName: "uname-m"
        command: "sh"
        args: ["-c", "uname -m"]
  hostAnalyzers:
    - textAnalyze:
        checkName: "uname-m"
        file: "host-collectors/run-host/uname-m.txt"
        matchRegex: "x86_64|aarch64|arm64"
        outcomes:
          - pass:
              when: "pass"
              message: "Architecture is supported"
          - fail:
              message: "Architecture is not supported"

banjoh avatar Jul 23 '24 11:07 banjoh