Merge "Drop Travis CI support   - Update links"
diff --git a/ceph/common.sls b/ceph/common.sls
index c6067b0..b445355 100644
--- a/ceph/common.sls
+++ b/ceph/common.sls
@@ -25,8 +25,8 @@
 common_config:
   file.managed:
   - name: {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
-  - user: ceph
-  - group: ceph
+  - user: root
+  - group: root
   - source: salt://ceph/files/{{ common.version }}/ceph.conf.{{ grains.os_family }}
   - template: jinja
   {% if not common.get('container_mode', False) %}
diff --git a/ceph/files/grafana_dashboards/ceph_pools_prometheus.json b/ceph/files/grafana_dashboards/ceph_pools_prometheus.json
index 74ca5de..61e2780 100644
--- a/ceph/files/grafana_dashboards/ceph_pools_prometheus.json
+++ b/ceph/files/grafana_dashboards/ceph_pools_prometheus.json
@@ -158,7 +158,7 @@
           "steppedLine": false,
           "targets": [
             {
-              "expr": "avg(ceph_pool_usage_max_avail{name=\"$pool\"}) - avg(ceph_pool_usage_bytes_used{name=\"$pool\"})",
+              "expr": "avg(ceph_pool_usage_max_avail{name=\"$pool\"})",
               "format": "time_series",
               "interval": "",
               "intervalFactor": 1,
@@ -178,7 +178,7 @@
               "step": 60
             },
             {
-              "expr": "avg(ceph_pool_usage_max_avail{name=\"$pool\"})",
+              "expr": "avg(ceph_pool_usage_max_avail{name=\"$pool\"}) + avg(ceph_pool_usage_bytes_used{name=\"$pool\"})",
               "format": "time_series",
               "interval": "",
               "intervalFactor": 1,
@@ -284,7 +284,7 @@
           "tableColumn": "",
           "targets": [
             {
-              "expr": "avg(ceph_pool_usage_bytes_used{name=\"$pool\"}) / avg(ceph_pool_usage_max_avail{name=\"$pool\"})",
+              "expr": "avg(ceph_pool_usage_bytes_used{name=\"$pool\"}) / (avg(ceph_pool_usage_max_avail{name=\"$pool\"}) + avg(ceph_pool_usage_bytes_used{name=\"$pool\"}))",
               "format": "time_series",
               "interval": "",
               "intervalFactor": 1,
diff --git a/ceph/meta/prometheus.yml b/ceph/meta/prometheus.yml
index 0afcfc2..62f1b9d 100644
--- a/ceph/meta/prometheus.yml
+++ b/ceph/meta/prometheus.yml
@@ -70,32 +70,6 @@
       annotations:
         summary: "{%-endraw %}{{100*threshold}}{%- raw %}% of Ceph space is used"
         description: "{{ $ value }} bytes of Ceph OSD space (>= {%-endraw %}{{100*threshold}}{%- raw %}%) is used for 3 minutes. For details, run 'ceph df'."
-    CephServiceApplyLatencyTooHigh:
-      {%- endraw %}
-      {%- set threshold = monitoring.apply_latency_threshold|default('0.007')|float %}
-      if: >-
-        avg(ceph_apply_latency_sum) / avg(ceph_apply_latency_avgcount) > {{threshold}}
-      {%- raw %}
-      for: 3m
-      labels:
-        severity: warning
-        service: ceph
-      annotations:
-        summary: "Ceph apply latency reached the limit of {%- endraw %}{{threshold}}{%- raw %}s"
-        description: "The average Ceph apply latency is more than {%- endraw %}{{threshold}}{%- raw %} seconds for 3 minutes."
-    CephServiceCommitLatencyTooHigh:
-      {%- endraw %}
-      {%- set threshold = monitoring.commit_latency_threshold|default('0.7')|float %}
-      if: >-
-        avg(ceph_commit_latency_sum) / avg(ceph_commitcycle_latency_avgcount) > {{threshold}}
-      {%- raw %}
-      for: 3m
-      labels:
-        severity: warning
-        service: ceph
-      annotations:
-        summary: "Ceph commit latency reached the limit of {%- endraw %}{{threshold}}{%- raw %}s"
-        description: "The average Ceph commit latency is more than {%- endraw %}{{threshold}}{%- raw %} seconds for 3 minutes."
 {% endraw %}
 {%- if setup.pool is defined %}
 {%- for pool_name, pool in setup.pool.iteritems() %}
@@ -107,7 +81,7 @@
     CephPool{{pool_name|replace(".", "")|replace("-", "")}}SpaceUsageWarning:
       {%- set threshold = monitoring_pool.pool_space_used_utilization_warning_threshold|default('0.75')|float %}
       if: >-
-        ceph_pool_usage_bytes_used{name="{{pool_name}}"} / ceph_pool_usage_max_avail{name="{{pool_name}}"} > {{threshold}}
+        ceph_pool_usage_bytes_used{name="{{pool_name}}"} / (ceph_pool_usage_max_avail{name="{{pool_name}}"} + ceph_pool_usage_bytes_used{name="{{pool_name}}"}) > {{threshold}}
       for: 3m
       labels:
         severity: warning
@@ -115,10 +89,10 @@
       annotations:
         summary: "{{100*threshold}}% of Ceph pool space is used"
         description: "The Ceph {{pool_name}} pool uses {{100*threshold}}% of available space for 3 minutes. For details, run 'ceph df'."
-    CephPool{{pool_name|replace(".", "")|replace("-", "")}}SpaceUsageMinor:
+    CephPool{{pool_name|replace(".", "")|replace("-", "")}}SpaceUsageCritical:
       {%- set threshold = monitoring_pool.pool_space_used_critical_threshold|default('0.85')|float %}
       if: >-
-        ceph_pool_usage_bytes_used{name="{{pool_name}}"} / ceph_pool_usage_max_avail{name="{{pool_name}}"} > {{threshold}}
+        ceph_pool_usage_bytes_used{name="{{pool_name}}"} / ceph_pool_usage_max_avail{name="{{pool_name}}"} + ceph_pool_usage_bytes_used{name="{{pool_name}}"}) > {{threshold}}
       for: 3m
       labels:
         severity: minor
@@ -126,6 +100,7 @@
       annotations:
         summary: "{{100*threshold}}% of Ceph pool space is used"
         description: "The Ceph {{pool_name}} pool uses {{100*threshold}}% of available space for 3 minutes. For details, run 'ceph df'."
+    {%- if monitoring.cluster_stats.extra_alerts.get("enabled", False) %}
     CephPool{{pool_name|replace(".", "")|replace("-", "")}}WriteOpsTooHigh:
       {%- set threshold = monitoring_pool.pool_write_ops_threshold|default('200')|float %}
       if: >-
@@ -170,6 +145,7 @@
       annotations:
         summary: "{{threshold}} Ceph pool read bytes per second"
         description: "The number of Ceph {{pool_name}} pool read bytes per second is {{threshold}} for 3 minutes."
+    {%- endif %}
 {%- endfor %}
 {%- endif %}
 {%- endif %}
diff --git a/ceph/setup/keyring.sls b/ceph/setup/keyring.sls
index f26c608..bd49b45 100644
--- a/ceph/setup/keyring.sls
+++ b/ceph/setup/keyring.sls
@@ -11,6 +11,12 @@
 
 {% for keyring_name, keyring in common.get('keyring', {}).iteritems() %}
 
+{% set keyring_cmd = "ceph -c /etc/ceph/"+ common.get('cluster_name', 'ceph') + ".conf auth get-or-create client." %}
+{% set keyring_cap = [] %}
+{%- for cap_name, cap in  keyring.caps.iteritems() %}
+  {% do keyring_cap.append(cap_name + " '" + cap + "' ")%}
+{%- endfor %}
+
 {%- if keyring.name is defined %}
 
 {%- if keyring.name != 'admin' and keyring.key is defined and common.get("manage_keyring", False) %}
@@ -31,10 +37,11 @@
 
 {%- elif keyring.name != 'admin' %}
 
+{% set key_contents = salt['cmd.shell'](keyring_cmd + keyring.name + " " + keyring_cap|join(" ")) %}
 ceph_create_keyring_{{ keyring.name }}:
-  cmd.run:
-  - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf auth get-or-create client.{{ keyring.name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring.name }}.keyring"
-  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring.name }}.keyring"
+  file.managed:
+  - name: {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring.name }}.keyring
+  - contents: {{ key_contents | yaml_encode }}
 
 {%- endif %}
 
@@ -58,10 +65,11 @@
 
 {%- elif keyring_name != 'admin' %}
 
+{% set key_contents = salt['cmd.shell'](keyring_cmd + keyring_name + " " + keyring_cap|join(" ")) %}
 ceph_create_keyring_{{ keyring_name }}:
-  cmd.run:
-  - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf auth get-or-create client.{{ keyring_name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring_name }}.keyring"
-  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring_name }}.keyring"
+  file.managed:
+  - name: {{ common.prefix_dir }}/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.client.{{ keyring_name }}.keyring
+  - contents: {{ key_contents | yaml_encode }}
 
 {%- endif %}
 
diff --git a/metadata/service/monitoring/cluster_stats.yml b/metadata/service/monitoring/cluster_stats.yml
index 85ae108..fdca597 100644
--- a/metadata/service/monitoring/cluster_stats.yml
+++ b/metadata/service/monitoring/cluster_stats.yml
@@ -8,5 +8,7 @@
   ceph:
     monitoring:
       cluster_stats:
+        extra_alerts:
+          enabled: false
         enabled: true
         ceph_user: ${_param:ceph_monitoring_user}