vmware-tanzu / sonobuoy

Sonobuoy is a diagnostic tool that makes it easier to understand the state of a Kubernetes cluster by running a set of Kubernetes conformance tests and other plugins in an accessible and non-destructive manner.

Home Page:https://sonobuoy.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The `raw` result should take container exit status into consideration

Brunomachadob opened this issue · comments

Describe the solution you'd like

I am trying to build a plugin that needs to run a simple task, which will always output everything in plain text format into the stdout and exit with either 0 or 1. Based on that, I believe it makes sense to make use of the result-format: raw format.

The problem is that no matter the exit code I use, sonobuoy interprets it as a success, just because it could stat the file with the outcomes, as stated here:

// RawProcessFile will return an Item object with the File value set to the path in question. If the
// file is unable to be stat'd then the status of the Item is StatusFailed (StatusPassed otherwise).

It would be nice to have this result to take the container exit code into consideration, as the report could be a success or failure, not depending on the file existing or not, but based on the exit code.

Anything else you would like to add:

Here's an example plugin config:

sonobuoy-config:
  driver: Job
  plugin-name: simple-plugin
  result-format: raw
spec:
  command:
    - sh
  args: ["-c", "echo whatever > ${SONOBUOY_RESULTS_DIR}/report.txt; echo ${SONOBUOY_RESULTS_DIR}/report.txt > ${SONOBUOY_RESULTS_DIR}/done; exit 1"]
  image: bitnami/kubectl:latest
  name: simple-plugin
  imagePullPolicy: Always
  resources: {}
  volumeMounts:
  - mountPath: /tmp/sonobuoy/results
    name: results

Being executed with:

sonobuoy run --sonobuoy-image sonobuoy/sonobuoy:latest --plugin simple-plugin.yaml

Environment:

  • Sonobuoy version: v0.57.1
  • Kubernetes version: v1.27.10-eks-508b6b3
  • Cloud provider or hardware configuration: EKS
  • OS (e.g. from /etc/os-release): MacOS