Browse Source

cadvisor metrics are missing due to worng kubernetes version.

the following [1] if statement fail due to bad float format.
float by default trailng only one zero (i.e 1.1 instead of 1.10)
this bug causes the scraper to missed cadvisr metrics.

[1]
https://github.com/openshift/openshift-ansible/blob/3de29f6d5a3017b57c553c5e2fb63a50994df840/roles/openshift_prometheus/templates/prometheus.yml.j2#L97
Eldad Marciano 7 years ago
parent
commit
da52ffba46

+ 1 - 1
roles/openshift_prometheus/tasks/facts.yaml

@@ -6,5 +6,5 @@
   register: oc_version
 
 - set_fact:
-    kubernetes_version: "{{ oc_version.results.kubernetes_short | float }}"
+    kubernetes_version: "{{ '%.2f' | format(oc_version.results.kubernetes_short|float) }}"
     openshift_prometheus_serviceaccount_annotations: "{{ l_openshift_prometheus_serviceaccount_annotations + openshift_prometheus_serviceaccount_annotations|list }}"

+ 0 - 4
roles/openshift_prometheus/templates/prometheus.yml.j2

@@ -100,11 +100,7 @@ scrape_configs:
     ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
   bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
 
-{% if kubernetes_version | float() >= 1.7 | float() %}
   metrics_path: /metrics/cadvisor
-{% else %}
-  metrics_path: /metrics
-{% endif %}
 
   kubernetes_sd_configs:
   - role: node