troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

Allow templating of outcome messages for the Node Resources Analyzer

Open diamonwiggins opened this issue 1 year ago • 2 comments

Describe the rationale for the suggested feature.

When using the Node Resources, a user may want to template the outcome message with the values retrieved from the node/cluster, so that the outcome messages don't have to be static as they are today. For example, a user may want to write the following spec:

apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
  name: sample
spec:
  analyzers:
    - nodeResources:
        filters:
          cpuArchitecture: amd64
        checkName: Must have at least 3 nodes in the cluster
        outcomes:
          - fail:
              when: "count() < 3"
              message: This application requires at least 3 nodes. Only {{ .NodeCount }} nodes found.
          - pass:
              message: This cluster has enough nodes.

Describe the feature

A user would be able to include certain values gathered by the Node Resources as templates in the outcome message, so they can generate more dynamic messages. The templates we allow for usage in the outcome message would need to account for mulit-node clusters and when filters like cpuArchitecture are used in the spec. For example, in a 10 node cluster where only half the node are amd64, if the {{ .NodeCount }} template was used in conjunction with a filter for `amd64, it should only return the 5 nodes that match that filter.

Describe alternatives you've considered

Describe alternative solutions here. Include any workarounds you've considered.

Additional context

Add additional context about the feature request. If the change is substantial, consider attaching files to the issue outlining architectural changes, data flows, file formats etc., anything that helps describe the requested change.

diamonwiggins avatar Aug 14 '24 16:08 diamonwiggins