Skip to content

Allow for a custom healthcheck field in the operator configmap#658

Merged
openshift-merge-bot[bot] merged 1 commit into
validatedpatterns:mainfrom
mbaldessari:custom-hc
Jun 3, 2026
Merged

Allow for a custom healthcheck field in the operator configmap#658
openshift-merge-bot[bot] merged 1 commit into
validatedpatterns:mainfrom
mbaldessari:custom-hc

Conversation

@mbaldessari

Copy link
Copy Markdown
Contributor

By populating the gitops.customHealthChecks in the patterns-operator-config
it is possible to customize the healthchecks in the argocd clusterwide
hub instance.

Tested as follows:

  1. Observe stock argocd healthcheck:

    oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
    Subscription
  2. Patch operator configmap

    cat > custom-hc.yaml
    - group: app
      kind: Deployment
      check: |
        hs = {}
        if obj.status ~= nil then
          if obj.status.readyReplicas == obj.status.replicas then
            hs.status = "Healthy"
          else
            hs.status = "Progressing"
          end
        end
        return hs
    - group: batch
      kind: Job
      check: |
        hs = {}
        if obj.status ~= nil and obj.status.succeeded ~= nil and obj.status.succeeded > 0 then
          hs.status = "Healthy"
        else
          hs.status = "Progressing"
        end
        return hs
    oc patch configmap patterns-operator-config \
    -n patterns-operator \
    --type merge \
    -p "$(jq -n --arg v "$(cat ~/custom-hc.yaml)" '{"data":{"gitops.customHealthChecks":$v}}')"
  3. Observe the change (no pod restarts needed):

    oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
    Subscription
    Deployment
    Job
4. Edit the configmap and remove the Job healthcheck:

   ```sh
   oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
   Subscription
   Deployment
   ```

By populating the `gitops.customHealthChecks` in the `patterns-operator-config`
it is possible to customize the healthchecks in the argocd clusterwide
hub instance.

Tested as follows:

  1. Observe stock argocd healthcheck:

     ```sh
     oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
     Subscription
     ```

  2. Patch operator configmap

     ```sh
     cat > custom-hc.yaml
     - group: app
       kind: Deployment
       check: |
         hs = {}
         if obj.status ~= nil then
           if obj.status.readyReplicas == obj.status.replicas then
             hs.status = "Healthy"
           else
             hs.status = "Progressing"
           end
         end
         return hs
     - group: batch
       kind: Job
       check: |
         hs = {}
         if obj.status ~= nil and obj.status.succeeded ~= nil and obj.status.succeeded > 0 then
           hs.status = "Healthy"
         else
           hs.status = "Progressing"
         end
         return hs
     oc patch configmap patterns-operator-config \
     -n patterns-operator \
     --type merge \
     -p "$(jq -n --arg v "$(cat ~/custom-hc.yaml)" '{"data":{"gitops.customHealthChecks":$v}}')"
     ```

   3. Observe the change (no pod restarts needed):

      ```sh
      oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
      Subscription
      Deployment
      Job
      ```

    4. Edit the configmap and remove the Job healthcheck:

       ```sh
       oc get argocd -n vp-gitops vp-gitops -o jsonpath='{.spec.resourceHealthChecks}' | jq -r '.[].kind'
       Subscription
       Deployment
       ```
@openshift-ci openshift-ci Bot requested review from darkdoc and dminnear-rh June 3, 2026 08:50
@openshift-ci

openshift-ci Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mbaldessari

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Jun 3, 2026
@darkdoc

darkdoc commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jun 3, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit c5bae1f into validatedpatterns:main Jun 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants