Skip to content
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

healthrules: messagePath is treated as a requirement #983

Open
cirocosta opened this issue Aug 19, 2022 · 0 comments
Open

healthrules: messagePath is treated as a requirement #983

cirocosta opened this issue Aug 19, 2022 · 0 comments

Comments

@cirocosta
Copy link
Contributor

Bug description:

in the rfc that introduced healthRules (see readable version of the RFC) it's stated:

Authors can also optionally define a messagePath, which is a path in the resource where Cartographer can pull off a message to display in the owner status.

however, absent of such field, we always end up with a message that indicates that an error occurred, which gives the impression that such field is treated as a requirement.

for instance, consider the following supply chain:

apiVersion: carto.run/v1alpha1
kind: ClusterSupplyChain
metadata:
  name: app
spec:
  selector:
    foo: bar

  resources:
    - name: first
      templateRef:
        kind: ClusterImageTemplate
        name: template

with the template being defined as

apiVersion: carto.run/v1alpha1
kind: ClusterImageTemplate
metadata:
  name: template
spec:
  params:
    - name: healthy
      default: "yep"

  imagePath: .data.image

  healthRule:
    multiMatch:
      healthy:
        matchFields:
          - key: 'data.healthy'
            operator: 'In'
            values: ['yep']
      unhealthy:
        matchFields:
          - key: 'data.healthy'
            operator: 'NotIn'
            values: ['yep']

  template:
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: $(workload.metadata.name)$
    data:
      image: foo
      healthy: $(params.healthy)$

now, creating a workload that matches the supply chain, we end up with:

kind: Workload
status:
  conditions:
  - reason: Ready
    status: "True"
    type: SupplyChainReady
  - reason: ResourceSubmissionComplete
    status: "True"
    type: ResourcesSubmitted
  - reason: HealthyConditionRule
    status: "True"
    type: ResourcesHealthy
  - reason: Ready                            #! yep, we're ready
    status: "True"
    type: Ready
  observedGeneration: 1
  resources:
  - name: first
    conditions:
    - reason: ResourceSubmissionComplete
      status: "True"
      type: ResourceSubmitted
    - reason: MatchedField
      status: "True"                        #! yep, we're healthy
      message: 'field value: yep, message: unknown, error retrieving message path []'
      type: Healthy                         #!        '---.
    - reason: Ready                         #!          "error" implying requirement
      status: "True"
      type: Ready

Steps to reproduce:

Please provide a set of steps to reproduce the behavior (example):

  1. apply the objects above
  2. observe status of Workload

Expected behavior:

keep being ready: true as we see, but, in the message field for the resource condition (type healthy), avoid mentioning the lack of messagePath as an error (in case messagePath points at something that's indeed wrong, I think it makes sense to explicitly mention that it's indeed an error but then also ready: false it).

Versions:

  • local kind cluster (1.23.4)
  • cartographer version (latest main - b5a7d29)
  • k8s version (1.23.4)

Additional context:

see

messageValue, messageErr := evaluator.EvaluateJsonPath(requirement.MessagePath, stampedObject.UnstructuredContent())
if messageErr != nil {
messageValue = fmt.Sprintf("unknown, error retrieving message path [%s]", requirement.MessagePath)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant