Skip to content

nodehealthcheck_ongoing_remediation metric stuck at 1 after remediation completes due to mismatched label sets #390

Description

@NyxTrail

Hi,
Looks like when a node is being remediated, the nodehealthcheck_ongoing_remediation metric uses a label set with name=< node-name >:
https://github.com/medik8s/node-healthcheck-operator/blob/main/controllers/nodehealthcheck_controller.go#L618

And once the remediation is completed, the metric uses a label set with name=< remediation-cr-name >:
https://github.com/medik8s/node-healthcheck-operator/blob/main/controllers/resources/status.go#L66

This results in the metrics appearing as shown below:
Image
In the image, the yellow line (value=0) has name set to remdiation CR name and the blue line (value=1, stuck) has name set to node name.

That is, the metric for the node name is permanently stuck at 1, incorrectly indicating an ongoing remediation.

Steps to reproduce

  1. Induce a node to be unhealthy (I usually stop kubelet)
  2. Wait for the node to be remediated
  3. Observe the metrics.

Sample raw metrics:

      {
        "metric": {
          "__name__": "nodehealthcheck_ongoing_remediation",
          "container": "kube-rbac-proxy",
          "endpoint": "https",
          "exported_instance": "x.x.x.x:yy",
          "exported_job": "node-healthcheck-controller-manager-metrics-service",
          "exported_namespace": "openshift-workload-availability",
          "instance": "my-redacted-instance:my-port",
          "job": "prometheus-federate-job",
          "name": "<node-name>",    // This is the node name
          "namespace": "openshift-workload-availability",
          "pod": "node-healthcheck-controller-manager-7f6475d7d4-zvrxw",
          "prometheus": "openshift-monitoring/k8s",
          "prometheus_replica": "prometheus-k8s-0",
          "remediation": "SelfNodeRemediation",
          "service": "node-healthcheck-controller-manager-metrics-service"
        },
        "value": [
          1771598863.253,
          "1"   // Value is "1" for Node name
        ]
      },
      {
        "metric": {
          "__name__": "nodehealthcheck_ongoing_remediation",
          "container": "kube-rbac-proxy",
          "endpoint": "https",
          "exported_instance": "x.x.x.x:yy",
          "exported_job": "node-healthcheck-controller-manager-metrics-service",
          "exported_namespace": "openshift-workload-availability",
          "instance": "my-redacted-instance:my-port",
          "job": "prometheus-federate",
          "name": "<node-name>-mh7vw",   // This is the remediation CR
          "namespace": "openshift-workload-availability",
          "pod": "node-healthcheck-controller-manager-7f6475d7d4-zvrxw",
          "prometheus": "openshift-monitoring/k8s",
          "prometheus_replica": "prometheus-k8s-0",
          "remediation": "SelfNodeRemediation",
          "service": "node-healthcheck-controller-manager-metrics-service"
        },
        "value": [
          1771598863.253,
          "0"  // Value is "0" for remediation CR
        ]
      }

Looks like the issue was introduced in this PR: #231 , when

metrics.ObserveNodeHealthCheckRemediationDeleted(node.GetName(), remediationCR.GetNamespace(), remediationCR.GetKind())

was moved to deleteRemediationCR method:

metrics.ObserveNodeHealthCheckRemediationDeleted(remediationCR.GetName(), remediationCR.GetNamespace(), remediationCR.GetKind())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions