Support rally in docker
* also disable the troublsome "collectd client installation" Change-Id: Ie185df9b4cbebf7285a904a4aa09a526e8c2cb28
This commit is contained in:
@@ -4,7 +4,6 @@ import logging
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
import site
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@@ -15,17 +14,6 @@ logging.basicConfig(filename='/var/log/check_health.log',
|
|||||||
format='%(asctime)s;%(levelname)s;%(lineno)s;%(message)s',
|
format='%(asctime)s;%(levelname)s;%(lineno)s;%(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S')
|
datefmt='%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
# Activate virtual environment for Rally
|
|
||||||
logging.info("Start to activate Rally virtual environment......")
|
|
||||||
virtual_env = '/opt/rally'
|
|
||||||
activate_this = '/opt/rally/bin/activate_this.py'
|
|
||||||
execfile(activate_this, dict(__file__=activate_this))
|
|
||||||
site.addsitedir(virtual_env)
|
|
||||||
if virtual_env not in sys.path:
|
|
||||||
sys.path.append(virtual_env)
|
|
||||||
logging.info("Activated virtual environment.")
|
|
||||||
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from rally import db
|
from rally import db
|
||||||
from rally.common import version
|
from rally.common import version
|
||||||
@@ -151,7 +139,7 @@ class HealthCheck(object):
|
|||||||
def create_deployment(self):
|
def create_deployment(self):
|
||||||
dpl_file_name = '.'.join((self.deployment_name, 'json'))
|
dpl_file_name = '.'.join((self.deployment_name, 'json'))
|
||||||
dpl_path = os.path.join(self.rally_deployment_dir, dpl_file_name)
|
dpl_path = os.path.join(self.rally_deployment_dir, dpl_file_name)
|
||||||
logging.info('deployment config file path is %s' % dpl_path)
|
logging.debug('deployment config file path is %s' % dpl_path)
|
||||||
|
|
||||||
if not os.path.isfile(dpl_path):
|
if not os.path.isfile(dpl_path):
|
||||||
err_msg = 'Cannot find deployment config file for rally.'
|
err_msg = 'Cannot find deployment config file for rally.'
|
||||||
@@ -204,7 +192,7 @@ class HealthCheck(object):
|
|||||||
if file.endswith('.json'):
|
if file.endswith('.json'):
|
||||||
tasks.append(os.path.join(dirpath, file))
|
tasks.append(os.path.join(dirpath, file))
|
||||||
|
|
||||||
logging.info("Get all tasks config are %s" % tasks)
|
logging.debug("Get all tasks config are %s" % tasks)
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
def get_tasks_uuid_from_db(self, deployment_id):
|
def get_tasks_uuid_from_db(self, deployment_id):
|
||||||
@@ -220,13 +208,13 @@ class HealthCheck(object):
|
|||||||
logging.info(command)
|
logging.info(command)
|
||||||
returncode, output, err = self.exec_cli(command)
|
returncode, output, err = self.exec_cli(command)
|
||||||
|
|
||||||
logging.info("task [%s] output is %s" % (task_name, output))
|
logging.debug("task [%s] output is %s" % (task_name, output))
|
||||||
print "Done task [%s]" % task_name
|
logging.info("Done task [%s]" % task_name)
|
||||||
|
|
||||||
print "Start to collect report......"
|
logging.info("Start to collect report......")
|
||||||
self.collect_and_send_report(task_name, output)
|
self.collect_and_send_report(task_name, output)
|
||||||
|
|
||||||
print "Collecting report for task [%s] is done!" % task_name
|
logging.info("Collecting report for task [%s] is done!" % task_name)
|
||||||
|
|
||||||
def collect_and_send_report(self, task_name, task_output):
|
def collect_and_send_report(self, task_name, task_output):
|
||||||
"""
|
"""
|
||||||
@@ -267,7 +255,7 @@ class HealthCheck(object):
|
|||||||
command = "rally task results %s" % task_uuid
|
command = "rally task results %s" % task_uuid
|
||||||
logging.info("[collect_and_send_report] command is %s" % command)
|
logging.info("[collect_and_send_report] command is %s" % command)
|
||||||
|
|
||||||
print "Start to collect report for task [%s]" % task_name
|
logging.info("Start to collect report for task [%s]" % task_name)
|
||||||
return_code, task_result, err = self.exec_cli(command)
|
return_code, task_result, err = self.exec_cli(command)
|
||||||
if return_code > 0:
|
if return_code > 0:
|
||||||
raise HealthException(err, report_url)
|
raise HealthException(err, report_url)
|
||||||
@@ -300,7 +288,7 @@ class HealthCheck(object):
|
|||||||
errors = self._get_total_errors(output)
|
errors = self._get_total_errors(output)
|
||||||
report['total_errors'] = errors
|
report['total_errors'] = errors
|
||||||
|
|
||||||
logging.info("task [%s] report is: %s" % (task_name, report))
|
logging.debug("task [%s] report is: %s" % (task_name, report))
|
||||||
|
|
||||||
final_report = {"results": report, "raw_output": output}
|
final_report = {"results": report, "raw_output": output}
|
||||||
self.send_report(final_report, report_url)
|
self.send_report(final_report, report_url)
|
||||||
@@ -428,13 +416,17 @@ class HealthCheck(object):
|
|||||||
total_errors = report['results']['total_errors']
|
total_errors = report['results']['total_errors']
|
||||||
exec_num = report['raw_output']['key']['kw']['runner']['times']
|
exec_num = report['raw_output']['key']['kw']['runner']['times']
|
||||||
|
|
||||||
if total_errors >= exec_num or total_errors == 0 and exec_num > 0:
|
if total_errors >= exec_num:
|
||||||
|
# All actions in the scenarios are failed.
|
||||||
payload['state'] = 'error'
|
payload['state'] = 'error'
|
||||||
payload['error_message'] = "Actions in this scenario are failed."
|
payload['error_message'] = "Actions in this scenario are failed."
|
||||||
|
|
||||||
elif total_errors:
|
elif total_errors:
|
||||||
|
# Some actions failed.
|
||||||
payload['state'] = 'finished'
|
payload['state'] = 'finished'
|
||||||
|
|
||||||
|
logging.info("report state is %s" % payload['state'])
|
||||||
|
|
||||||
resp = requests.put(
|
resp = requests.put(
|
||||||
report_url, data=json.dumps(payload), headers=REQUEST_HEADER
|
report_url, data=json.dumps(payload), headers=REQUEST_HEADER
|
||||||
)
|
)
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
deployment_name = node.name.split('.')[-1]
|
||||||
|
node.tags << 'rally_node' unless node.tags.include?('rally_node')
|
||||||
|
|
||||||
# pull latest rally image
|
# pull latest rally image
|
||||||
docker_image = node['compass']['rally_image']
|
docker_image = node['compass']['rally_image']
|
||||||
@@ -32,6 +34,11 @@ remote_directory "/var/lib/rally-docker/scenarios" do
|
|||||||
action :create_if_missing
|
action :create_if_missing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
directory "/var/lib/rally-docker/#{deployment_name}" do
|
||||||
|
mode "0755"
|
||||||
|
action :create
|
||||||
|
end
|
||||||
|
|
||||||
cookbook_file "check_health.py" do
|
cookbook_file "check_health.py" do
|
||||||
mode "0755"
|
mode "0755"
|
||||||
path "/var/lib/rally-docker/check_health.py"
|
path "/var/lib/rally-docker/check_health.py"
|
||||||
@@ -39,19 +46,19 @@ end
|
|||||||
|
|
||||||
# load variables
|
# load variables
|
||||||
rally_db = node['mysql']['bind_address'] + ":#{node['mysql']['port']}"
|
rally_db = node['mysql']['bind_address'] + ":#{node['mysql']['port']}"
|
||||||
deployment_name = node.name.split('.')[-1]
|
endpoint = node['openstack']['identity']['publicURL'] || node['compass']['hc']['url']
|
||||||
endpoint = node['compass']['hc']['url']
|
admin = node['openstack']['identity']['admin_user'] || node['compass']['hc']['user']
|
||||||
admin = node['openstack']['identity']['admin_user'] || 'admin'
|
pass = node['openstack']['identity']['users'][admin]['password'] || node['compass']['hc']['password']
|
||||||
pass = node['openstack']['identity']['users'][admin]['password']
|
|
||||||
|
|
||||||
template "/var/lib/rally-docker/Dockerfile" do
|
template "/var/lib/rally-docker/Dockerfile" do
|
||||||
source 'Dockerfile.erb'
|
source 'Dockerfile.erb'
|
||||||
variables(
|
variables(
|
||||||
RALLY_DB: rally_db)
|
RALLY_DB: rally_db,
|
||||||
|
deployment_name: deployment_name)
|
||||||
action :create_if_missing
|
action :create_if_missing
|
||||||
end
|
end
|
||||||
|
|
||||||
template "/var/lib/rally-docker/deployment.json" do
|
template "/var/lib/rally-docker/#{deployment_name}/deployment.json" do
|
||||||
source 'deployment.json.erb'
|
source 'deployment.json.erb'
|
||||||
variables(
|
variables(
|
||||||
user: admin,
|
user: admin,
|
||||||
@@ -61,6 +68,16 @@ template "/var/lib/rally-docker/deployment.json" do
|
|||||||
action :create_if_missing
|
action :create_if_missing
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "build running image" do
|
execute "remove existing containers that use the image" do
|
||||||
command "docker build -t #{deployment_name} /var/lib/rally-docker"
|
ignore_failure true
|
||||||
|
command "docker rm -f `docker ps -a|grep #{deployment_name}`"
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "remove existing image with same name" do
|
||||||
|
ignore_failure true
|
||||||
|
command "docker rmi #{deployment_name}"
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "build running image" do
|
||||||
|
command "docker build -t #{deployment_name} /var/lib/rally-docker/"
|
||||||
end
|
end
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
From compassindocker/rally
|
From compassindocker/rally
|
||||||
ADD scenarios /opt/compass/rally/scenarios
|
ADD scenarios /opt/compass/rally/scenarios
|
||||||
ADD check_health.py /opt/compass/rally/check_health.py
|
ADD check_health.py /opt/compass/rally/check_health.py
|
||||||
ADD deployment.json /opt/compass/rally/deployment.json
|
ADD <%= @deployment_name %>/deployment.json /opt/compass/rally/deployment/<%= @deployment_name %>.json
|
||||||
RUN sed 's|#connection=<None>|connection=mysql://rally:rally@'#{RALLY_DB}'/rally|' /etc/rally/rally.conf && \
|
RUN sed 's|#connection=<None>|connection=mysql://rally:rally@"<%= @RALLY_DB %>"/rally|' /etc/rally/rally.conf && \
|
||||||
rally-manage db recreate && \
|
rally-manage db recreate && \
|
||||||
chmod -R go+w /opt/rally/database && \
|
chmod -R go+w /opt/rally/database && \
|
||||||
sleep 200
|
sleep 200
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
},
|
},
|
||||||
"chef_type": "role",
|
"chef_type": "role",
|
||||||
"run_list": [
|
"run_list": [
|
||||||
"recipe[collectd::client]"
|
|
||||||
],
|
],
|
||||||
"env_run_lists": {
|
"env_run_lists": {
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
"run_list": [
|
"run_list": [
|
||||||
"role[os-base]",
|
"role[os-base]",
|
||||||
"role[os-ops-caching]",
|
"role[os-ops-caching]",
|
||||||
|
"role[compass-rally]",
|
||||||
"recipe[openstack-identity::server]",
|
"recipe[openstack-identity::server]",
|
||||||
"recipe[openstack-identity::registration]"
|
"recipe[openstack-identity::registration]"
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user