auto restart influxdb and grafana support 71/36371/1
authorrexlee8776 <limingjiang@huawei.com>
Thu, 22 Jun 2017 12:14:38 +0000 (12:14 +0000)
committerrexlee8776 <limingjiang@huawei.com>
Thu, 22 Jun 2017 12:14:38 +0000 (12:14 +0000)
JIRA: YARDSTICK-686

Change-Id: If486df4d825f9d0b03eeaa77716cc2855e2f1bd0
Signed-off-by: rexlee8776 <limingjiang@huawei.com>
api/resources/env_action.py

index 7bfaf27..dd65665 100644 (file)
@@ -20,6 +20,7 @@ import glob
 from six.moves import configparser
 from oslo_serialization import jsonutils
 from docker import Client
+from docker.utils import create_host_config
 
 from api.database.handler import AsyncTaskHandler
 from api.utils import influx
@@ -98,7 +99,9 @@ def _create_data_source():
 def _create_grafana_container(client):
     ports = [3000]
     port_bindings = {k: k for k in ports}
-    host_config = client.create_host_config(port_bindings=port_bindings)
+    restart_policy = {"MaximumRetryCount": 0, "Name": "always"}
+    host_config = client.create_host_config(port_bindings=port_bindings,
+                                            restart_policy=restart_policy)
 
     container = client.create_container(image='%s:%s' % (consts.GRAFANA_IMAGE,
                                                          consts.GRAFANA_TAG),
@@ -150,7 +153,9 @@ def _create_influxdb_container(client):
 
     ports = [8083, 8086]
     port_bindings = {k: k for k in ports}
-    host_config = client.create_host_config(port_bindings=port_bindings)
+    restart_policy = {"MaximumRetryCount": 0, "Name": "always"}
+    host_config = client.create_host_config(port_bindings=port_bindings,
+                                            restart_policy=restart_policy)
 
     container = client.create_container(image='%s:%s' % (consts.INFLUXDB_IMAGE,
                                                          consts.INFLUXDB_TAG),