From 4d1e5ffd2e6e4e9b4d4509af212c11a9ead58740 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Thu, 12 Oct 2017 14:22:55 +0200
Subject: [PATCH] [openstack_[glance|heat]] run commands only if service is
running
Collect "glance-manage db_version" and similar commands from the
two plugins only if the relevant services are running. Otherwise
the commands get stuck and timeout.
Resolves: #1124
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/plugins/openstack_glance.py | 29 +++++++++++++++++------------
sos/plugins/openstack_heat.py | 40 +++++++++++++++++++++++-----------------
2 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py
index 0a2bdc1bb..642b4593a 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -31,12 +31,6 @@ class OpenStackGlance(Plugin):
var_puppet_gen = "/var/lib/config-data/puppet-generated/glance_api"
def setup(self):
- # Glance
- self.add_cmd_output(
- "glance-manage db_version",
- suggest_filename="glance_db_version"
- )
-
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
self.add_copy_spec([
@@ -64,12 +58,23 @@ def setup(self):
vars_any = [p in os.environ for p in [
'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
- if not (all(vars_all) and any(vars_any)):
- self.soslog.warning("Not all environment variables set. Source "
- "the environment file for the user intended "
- "to connect to the OpenStack environment.")
- else:
- self.add_cmd_output("openstack image list --long")
+ # collect commands output only if the openstack-glance-api service
+ # is running
+ service_status = self.get_command_output(
+ "systemctl status openstack-glance-api.service"
+ )
+ if service_status['status'] == 0:
+ self.add_cmd_output(
+ "glance-manage db_version",
+ suggest_filename="glance_db_version"
+ )
+ if not (all(vars_all) and any(vars_any)):
+ self.soslog.warning("Not all environment variables set. "
+ "Source the environment file for the user "
+ "intended to connect to the OpenStack "
+ "environment.")
+ else:
+ self.add_cmd_output("openstack image list --long")
def postproc(self):
protect_keys = [
diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py
index a73916b25..66a7f4109 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -29,24 +29,30 @@ class OpenStackHeat(Plugin):
var_puppet_gen = "/var/lib/config-data/puppet-generated/heat"
def setup(self):
- # Heat
- self.add_cmd_output(
- "heat-manage db_version",
- suggest_filename="heat_db_version"
- )
-
- vars_all = [p in os.environ for p in [
- 'OS_USERNAME', 'OS_PASSWORD']]
- vars_any = [p in os.environ for p in [
- 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
-
- if not (all(vars_all) and any(vars_any)):
- self.soslog.warning("Not all environment variables set. Source "
- "the environment file for the user intended "
- "to connect to the OpenStack environment.")
- else:
- self.add_cmd_output("openstack stack list")
+ # collect commands output only if the openstack-heat-api service
+ # is running
+ service_status = self.get_command_output("systemctl status "
+ "openstack-heat-api.service")
+ if service_status['status'] == 0:
+ self.add_cmd_output(
+ "heat-manage db_version",
+ suggest_filename="heat_db_version"
+ )
+
+ vars_all = [p in os.environ for p in [
+ 'OS_USERNAME', 'OS_PASSWORD']]
+
+ vars_any = [p in os.environ for p in [
+ 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
+
+ if not (all(vars_all) and any(vars_any)):
+ self.soslog.warning("Not all environment variables set. "
+ "Source the environment file for the user "
+ "intended to connect to the OpenStack "
+ "environment.")
+ else:
+ self.add_cmd_output("openstack stack list")
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
From d5ac6cd768acbd6a8d2d1de2ec26f127272089f2 Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Wed, 18 Oct 2017 15:50:23 +0200
Subject: [PATCH] [openstack_*, logrotate] Tripleo additional directories
Tripleo Pike opinionated config+log paths to be collected
for services, when running in containers.
This is an addition to #1054 where a couple of things got missed
Fixes: #1130
Signed-off-by: Martin Schuppert <mschuppe@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/plugins/gnocchi.py | 6 ++++--
sos/plugins/logrotate.py | 6 +++++-
sos/plugins/openstack_cinder.py | 34 ++++++++++++++++++++++++-------
sos/plugins/openstack_glance.py | 6 ++++--
sos/plugins/openstack_heat.py | 8 ++++++--
sos/plugins/openstack_horizon.py | 6 ++++--
sos/plugins/openstack_ironic.py | 43 +++++++++++++++++++++++++++++++--------
sos/plugins/openstack_keystone.py | 6 ++++--
sos/plugins/openstack_manila.py | 12 ++++++++---
sos/plugins/openstack_neutron.py | 10 ++++++---
sos/plugins/openstack_nova.py | 19 ++++++++++++++---
sos/plugins/openstack_swift.py | 6 ++++--
13 files changed, 160 insertions(+), 43 deletions(-)
diff --git a/sos/plugins/gnocchi.py b/sos/plugins/gnocchi.py
index c7a97097c..d2eda47ea 100644
--- a/sos/plugins/gnocchi.py
+++ b/sos/plugins/gnocchi.py
@@ -49,13 +49,15 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/gnocchi/*",
- "/var/log/containers/gnocchi/*"],
+ "/var/log/containers/gnocchi/*",
+ "/var/log/containers/httpd/gnocchi-api/*"],
sizelimit=self.limit
)
else:
self.add_copy_spec([
"/var/log/gnocchi/*.log",
- "/var/log/containers/gnocchi/*.log"],
+ "/var/log/containers/gnocchi/*.log",
+ "/var/log/containers/httpd/gnocchi-api/*log"],
sizelimit=self.limit
)
diff --git a/sos/plugins/logrotate.py b/sos/plugins/logrotate.py
index c811192f0..c12cf1bb4 100644
--- a/sos/plugins/logrotate.py
+++ b/sos/plugins/logrotate.py
@@ -22,12 +22,16 @@ class LogRotate(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
plugin_name = 'logrotate'
profiles = ('system',)
+ var_puppet_gen = "/var/lib/config-data/puppet-generated/crond"
+
def setup(self):
self.add_cmd_output("logrotate --debug /etc/logrotate.conf",
suggest_filename="logrotate_debug")
self.add_copy_spec([
"/etc/logrotate*",
- "/var/lib/logrotate.status"
+ "/var/lib/logrotate.status",
+ self.var_puppet_gen + "/etc/logrotate-crond.conf",
+ self.var_puppet_gen + "/var/spool/cron/root"
])
# vim: set et ts=4 sw=4 :
diff --git a/sos/plugins/openstack_cinder.py b/sos/plugins/openstack_cinder.py
index ffec62b53..abfd267bb 100644
--- a/sos/plugins/openstack_cinder.py
+++ b/sos/plugins/openstack_cinder.py
@@ -30,23 +30,39 @@ class OpenStackCinder(Plugin):
option_list = [("db", "gathers openstack cinder db version", "slow",
False)]
+ var_puppet_gen = "/var/lib/config-data/puppet-generated/cinder"
+
def setup(self):
if self.get_option("db"):
self.add_cmd_output(
"cinder-manage db version",
suggest_filename="cinder_db_version")
- self.add_copy_spec(["/etc/cinder/"])
+ self.add_copy_spec([
+ "/etc/cinder/",
+ self.var_puppet_gen + "/etc/cinder/",
+ self.var_puppet_gen + "/etc/httpd/conf/",
+ self.var_puppet_gen + "/etc/httpd/conf.d/",
+ self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
+ self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
+ self.var_puppet_gen + "/etc/sysconfig/",
+ ])
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
- self.add_copy_spec(["/var/log/cinder/",
- "/var/log/containers/cinder/"],
- sizelimit=self.limit)
+ self.add_copy_spec([
+ "/var/log/cinder/",
+ "/var/log/httpd/cinder*",
+ "/var/log/containers/cinder/",
+ "/var/log/containers/httpd/cinder-api/"
+ ], sizelimit=self.limit)
else:
- self.add_copy_spec(["/var/log/cinder/*.log",
- "/var/log/containers/cinder/*.log"],
- sizelimit=self.limit)
+ self.add_copy_spec([
+ "/var/log/cinder/*.log",
+ "/var/log/httpd/cinder*.log",
+ "/var/log/containers/cinder/*.log",
+ "/var/log/containers/httpd/cinder-api/*log"
+ ], sizelimit=self.limit)
if self.get_option("verify"):
self.add_cmd_output("rpm -V %s" % ' '.join(self.packages))
@@ -67,6 +83,10 @@ def postproc(self):
regexp = r"((?m)^\s*(%s)\s*=\s*)(.*)" % "|".join(protect_keys)
self.do_path_regex_sub("/etc/cinder/*", regexp, r"\1*********")
+ self.do_path_regex_sub(
+ self.var_puppet_gen + "/etc/cinder/*",
+ regexp, r"\1*********"
+ )
class DebianCinder(OpenStackCinder, DebianPlugin, UbuntuPlugin):
diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py
index 642b4593a..fdd789a81 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -35,12 +35,14 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/glance/",
- "/var/log/containers/glance/"
+ "/var/log/containers/glance/",
+ "/var/log/containers/httpd/glance-api/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/glance/*.log",
- "/var/log/containers/glance/*.log"
+ "/var/log/containers/glance/*.log",
+ "/var/log/containers/httpd/glance-api/*log"
], sizelimit=self.limit)
self.add_copy_spec([
diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py
index 66a7f4109..de34ed155 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -58,12 +58,16 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/heat/",
- "/var/log/containers/heat/"
+ "/var/log/containers/heat/",
+ "/var/log/containers/httpd/heat-api/",
+ "/var/log/containers/httpd/heat-api-cfn"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/heat/*.log",
- "/var/log/containers/heat/*.log"
+ "/var/log/containers/heat/*.log",
+ "/var/log/containers/httpd/heat-api/*log",
+ "/var/log/containers/httpd/heat-api-cfn/*log"
], sizelimit=self.limit)
self.add_copy_spec([
diff --git a/sos/plugins/openstack_horizon.py b/sos/plugins/openstack_horizon.py
index a9a7fab3b..d4f457115 100644
--- a/sos/plugins/openstack_horizon.py
+++ b/sos/plugins/openstack_horizon.py
@@ -35,12 +35,14 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/horizon/",
- "/var/log/containers/horizon/"
+ "/var/log/containers/horizon/",
+ "/var/log/containers/httpd/horizon/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/horizon/*.log",
- "/var/log/containers/horizon/*.log"
+ "/var/log/containers/horizon/*.log",
+ "/var/log/containers/httpd/horizon/*log"
], sizelimit=self.limit)
self.add_copy_spec([
diff --git a/sos/plugins/openstack_ironic.py b/sos/plugins/openstack_ironic.py
index 0396cc639..f4e0a97d3 100644
--- a/sos/plugins/openstack_ironic.py
+++ b/sos/plugins/openstack_ironic.py
@@ -25,21 +25,48 @@ class OpenStackIronic(Plugin):
plugin_name = "openstack_ironic"
profiles = ('openstack', 'openstack_undercloud')
+ var_puppet_gen = "/var/lib/config-data/puppet-generated/ironic"
+
def setup(self):
- self.conf_list = ['/etc/ironic/*']
- self.add_copy_spec('/etc/ironic/')
+ self.conf_list = [
+ "/etc/ironic/*",
+ self.var_puppet_gen + "/etc/ironic/*",
+ self.var_puppet_gen + "_api/etc/ironic/*"
+ ]
+ self.add_copy_spec([
+ "/etc/ironic/",
+ self.var_puppet_gen + "/etc/xinetd.conf",
+ self.var_puppet_gen + "/etc/xinetd.d/",
+ self.var_puppet_gen + "/etc/ironic/",
+ self.var_puppet_gen + "/etc/httpd/conf/",
+ self.var_puppet_gen + "/etc/httpd/conf.d/",
+ self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
+ self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
+ self.var_puppet_gen + "_api/etc/ironic/",
+ self.var_puppet_gen + "_api/etc/httpd/conf/",
+ self.var_puppet_gen + "_api/etc/httpd/conf.d/",
+ self.var_puppet_gen + "_api/etc/httpd/conf.modules.d/*.conf",
+ self.var_puppet_gen + "_api/etc/my.cnf.d/tripleo.cnf"
+ ])
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
- self.add_copy_spec(["/var/log/ironic/",
- "/var/log/containers/ironic/"],
- sizelimit=self.limit)
+ self.add_copy_spec([
+ "/var/log/ironic/",
+ "/var/log/containers/ironic/",
+ "/var/log/containers/httpd/ironic-api/"
+ ], sizelimit=self.limit)
else:
- self.add_copy_spec(["/var/log/ironic/*.log",
- "/var/log/containers/ironic/*.log"],
- sizelimit=self.limit)
+ self.add_copy_spec([
+ "/var/log/ironic/*.log",
+ "/var/log/containers/ironic/*.log",
+ "/var/log/containers/httpd/ironic-api/*log"
+ ], sizelimit=self.limit)
self.add_cmd_output('ls -laRt /var/lib/ironic/')
+ self.add_cmd_output(
+ 'ls -laRt ' + self.var_puppet_gen + '/var/lib/ironic/'
+ )
if self.get_option("verify"):
self.add_cmd_output("rpm -V %s" % ' '.join(self.packages))
diff --git a/sos/plugins/openstack_keystone.py b/sos/plugins/openstack_keystone.py
index d0b144323..72c7f8e2a 100644
--- a/sos/plugins/openstack_keystone.py
+++ b/sos/plugins/openstack_keystone.py
@@ -47,12 +47,14 @@ class OpenStackKeystone(Plugin):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/keystone/",
- "/var/log/containers/keystone/"
+ "/var/log/containers/keystone/",
+ "/var/log/containers/httpd/keystone/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/keystone/*.log",
- "/var/log/containers/keystone/*.log"
+ "/var/log/containers/keystone/*.log",
+ "/var/log/containers/httpd/keystone/*log"
], sizelimit=self.limit)
if self.get_option("verify"):
diff --git a/sos/plugins/openstack_manila.py b/sos/plugins/openstack_manila.py
index 92bca6fa8..e29859367 100644
--- a/sos/plugins/openstack_manila.py
+++ b/sos/plugins/openstack_manila.py
@@ -29,19 +29,25 @@ class OpenStackManila(Plugin):
def setup(self):
self.add_copy_spec([
"/etc/manila/",
- self.var_puppet_gen + "/etc/manila/"
+ self.var_puppet_gen + "/etc/manila/",
+ self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
+ self.var_puppet_gen + "/etc/httpd/conf/",
+ self.var_puppet_gen + "/etc/httpd/conf.d/",
+ self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
])
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/manila/*",
- "/var/log/containers/manila/*"
+ "/var/log/containers/manila/*",
+ "/var/log/containers/httpd/manila-api/*"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/manila/*.log",
- "/var/log/containers/manila/*.log"
+ "/var/log/containers/manila/*.log",
+ "/var/log/containers/httpd/manila-api/*log"
], sizelimit=self.limit)
def postproc(self):
diff --git a/sos/plugins/openstack_neutron.py b/sos/plugins/openstack_neutron.py
index b6116c731..522686606 100644
--- a/sos/plugins/openstack_neutron.py
+++ b/sos/plugins/openstack_neutron.py
@@ -33,17 +33,21 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/neutron/",
- "/var/log/containers/neutron/"
+ "/var/log/containers/neutron/",
+ "/var/log/containers/httpd/neutron-api/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/neutron/*.log",
- "/var/log/containers/neutron/*.log"
+ "/var/log/containers/neutron/*.log",
+ "/var/log/containers/httpd/neutron-api/*log"
], sizelimit=self.limit)
self.add_copy_spec([
"/etc/neutron/",
- self.var_puppet_gen + "/etc/neutron/"
+ self.var_puppet_gen + "/etc/neutron/",
+ self.var_puppet_gen + "/etc/default/neutron-server",
+ self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf"
])
self.add_copy_spec("/var/lib/neutron/")
if self.get_option("verify"):
diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py
index 75dd37255..1fbfa76a8 100644
--- a/sos/plugins/openstack_nova.py
+++ b/sos/plugins/openstack_nova.py
@@ -71,12 +71,16 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/nova/",
- "/var/log/containers/nova/"
+ "/var/log/containers/nova/",
+ "/var/log/containers/httpd/nova-api/",
+ "/var/log/containers/httpd/nova-placement/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/nova/*.log",
- "/var/log/containers/nova/*.log"
+ "/var/log/containers/nova/*.log",
+ "/var/log/containers/httpd/nova-api/*log",
+ "/var/log/containers/httpd/nova-placement/*log"
], sizelimit=self.limit)
self.add_copy_spec([
@@ -89,7 +93,12 @@ def setup(self):
self.var_puppet_gen + "_placement/etc/httpd/conf.d/",
self.var_puppet_gen + "_placement/etc/httpd/conf.modules.d/*.conf",
self.var_puppet_gen + "_placement/etc/my.cnf.d/tripleo.cnf",
- self.var_puppet_gen + "/../memcached/etc/sysconfig/memcached"
+ self.var_puppet_gen + "/../memcached/etc/sysconfig/memcached",
+ self.var_puppet_gen + "_libvirt/etc/libvirt/",
+ self.var_puppet_gen + "_libvirt/etc/my.cnf.d/tripleo.cnf",
+ self.var_puppet_gen + "_libvirt/etc/nova/migration/"
+ "authorized_keys",
+ self.var_puppet_gen + "_libvirt/var/lib/nova/.ssh/config",
])
if self.get_option("verify"):
@@ -115,6 +124,10 @@ def postproc(self):
self.var_puppet_gen + "_placement/etc/nova/*",
regexp, r"\1*********"
)
+ self.do_path_regex_sub(
+ self.var_puppet_gen + "_libvirt/etc/nova/*",
+ regexp, r"\1*********"
+ )
class DebianNova(OpenStackNova, DebianPlugin, UbuntuPlugin):
diff --git a/sos/plugins/openstack_swift.py b/sos/plugins/openstack_swift.py
index 1cfff2b88..1688112f5 100644
--- a/sos/plugins/openstack_swift.py
+++ b/sos/plugins/openstack_swift.py
@@ -35,12 +35,14 @@ def setup(self):
if self.get_option("all_logs"):
self.add_copy_spec([
"/var/log/swift/",
- "/var/log/containers/swift/"
+ "/var/log/containers/swift/",
+ "/var/log/containers/httpd/swift-proxy/"
], sizelimit=self.limit)
else:
self.add_copy_spec([
"/var/log/swift/*.log",
- "/var/log/containers/swift/*.log"
+ "/var/log/containers/swift/*.log",
+ "/var/log/containers/httpd/swift-proxy/*log"
], sizelimit=self.limit)
self.add_copy_spec([
From e63c17d902f99d96cbd4cb2a06d9cbbf8a4d4c18 Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Tue, 7 Nov 2017 18:07:47 +0100
Subject: [PATCH] [openstack_nova] added missing nova container config
Tripleo Pike opinionated config+log paths to be collected
for services, when running in containers.
The nova configuration for the nova and placement container
was included, but the nova configuration libvirt container
was missing. Also the httpd configs for the nova contaier
were added.
This is a change to #1130
Signed-off-by: Martin Schuppert mschuppe@redhat.com
---
sos/plugins/openstack_nova.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py
index 1fbfa76a8..cdd297608 100644
--- a/sos/plugins/openstack_nova.py
+++ b/sos/plugins/openstack_nova.py
@@ -87,7 +87,10 @@ def setup(self):
"/etc/nova/",
self.var_puppet_gen + "/etc/nova/",
self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
- self.var_puppet_gen + "_placement/var/spool/cron/nova",
+ self.var_puppet_gen + "/var/spool/cron/nova",
+ self.var_puppet_gen + "/etc/httpd/conf/",
+ self.var_puppet_gen + "/etc/httpd/conf.d/",
+ self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
self.var_puppet_gen + "_placement/etc/nova/",
self.var_puppet_gen + "_placement/etc/httpd/conf/",
self.var_puppet_gen + "_placement/etc/httpd/conf.d/",
@@ -96,6 +99,7 @@ def setup(self):
self.var_puppet_gen + "/../memcached/etc/sysconfig/memcached",
self.var_puppet_gen + "_libvirt/etc/libvirt/",
self.var_puppet_gen + "_libvirt/etc/my.cnf.d/tripleo.cnf",
+ self.var_puppet_gen + "_libvirt/etc/nova/",
self.var_puppet_gen + "_libvirt/etc/nova/migration/"
"authorized_keys",
self.var_puppet_gen + "_libvirt/var/lib/nova/.ssh/config",
From 410733862a1f5ea1f9666d1fa41a7b5d3390e3c6 Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Wed, 8 Nov 2017 17:57:54 +0100
Subject: [PATCH] [openstack_[glance|heat|cinder|nova]] limit command run
Collect "glance-manage db_version" and similar commands from the
four plugins only if the relevant services or containers are
running. Otherwise the commands get stuck and timeout.
This is an enhancement to #1124 to check for containers + do the
same for nova + cinder.
Signed-off-by: Martin Schuppert mschuppe@redhat.com
Edited to remove use of shell syntax.
Fixes: #1139
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/plugins/openstack_cinder.py | 30 ++++++++++---
sos/plugins/openstack_glance.py | 33 +++++++++++----
sos/plugins/openstack_heat.py | 23 ++++++++--
sos/plugins/openstack_nova.py | 94 +++++++++++++++++++++++++++--------------
4 files changed, 129 insertions(+), 51 deletions(-)
diff --git a/sos/plugins/openstack_cinder.py b/sos/plugins/openstack_cinder.py
index abfd267bb..a023105c8 100644
--- a/sos/plugins/openstack_cinder.py
+++ b/sos/plugins/openstack_cinder.py
@@ -27,16 +27,34 @@ class OpenStackCinder(Plugin):
plugin_name = "openstack_cinder"
profiles = ('openstack', 'openstack_controller')
- option_list = [("db", "gathers openstack cinder db version", "slow",
- False)]
-
var_puppet_gen = "/var/lib/config-data/puppet-generated/cinder"
def setup(self):
- if self.get_option("db"):
+
+ # collect commands output only if the openstack-cinder-api service
+ # is running
+ service_status = self.get_command_output(
+ "systemctl status openstack-cinder-api.service"
+ )
+
+ container_status = self.get_command_output("docker ps")
+ in_container = False
+ if container_status['status'] == 0:
+ for line in container_status['output'].splitlines():
+ if line.endswith("cinder_api"):
+ in_container = True
+
+ if (service_status['status'] == 0) or in_container:
+ cinder_config = ""
+ # if containerized we need to pass the config to the cont.
+ if in_container:
+ cinder_config = "--config-dir " + self.var_puppet_gen + \
+ "/etc/cinder/"
+
self.add_cmd_output(
- "cinder-manage db version",
- suggest_filename="cinder_db_version")
+ "cinder-manage " + cinder_config + " db version",
+ suggest_filename="cinder_db_version"
+ )
self.add_copy_spec([
"/etc/cinder/",
diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py
index fdd789a81..4cdc6dc62 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -54,22 +54,37 @@ def setup(self):
if self.get_option("verify"):
self.add_cmd_output("rpm -V %s" % ' '.join(self.packages))
- vars_all = [p in os.environ for p in [
- 'OS_USERNAME', 'OS_PASSWORD']]
-
- vars_any = [p in os.environ for p in [
- 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
-
# collect commands output only if the openstack-glance-api service
# is running
service_status = self.get_command_output(
- "systemctl status openstack-glance-api.service"
+ "systemctl status openstack-glance-api.service"
)
- if service_status['status'] == 0:
+
+ container_status = self.get_command_output("docker ps")
+ in_container = False
+ if container_status['status'] == 0:
+ for line in container_status['output'].splitlines():
+ if line.endswith("cinder_api"):
+ in_container = True
+
+ if (service_status['status'] == 0) or in_container:
+ glance_config = ""
+ # if containerized we need to pass the config to the cont.
+ if in_container:
+ glance_config = "--config-dir " + self.var_puppet_gen + \
+ "/etc/glance/"
+
self.add_cmd_output(
- "glance-manage db_version",
+ "glance-manage " + glance_config + " db_version",
suggest_filename="glance_db_version"
)
+
+ vars_all = [p in os.environ for p in [
+ 'OS_USERNAME', 'OS_PASSWORD']]
+
+ vars_any = [p in os.environ for p in [
+ 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
+
if not (all(vars_all) and any(vars_any)):
self.soslog.warning("Not all environment variables set. "
"Source the environment file for the user "
diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py
index de34ed155..e3395fabd 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -32,11 +32,26 @@ def setup(self):
# collect commands output only if the openstack-heat-api service
# is running
- service_status = self.get_command_output("systemctl status "
- "openstack-heat-api.service")
- if service_status['status'] == 0:
+ service_status = self.get_command_output(
+ "systemctl status openstack-heat-api.service"
+ )
+
+ container_status = self.get_command_output("docker ps")
+ in_container = False
+ if container_status['status'] == 0:
+ for line in container_status['output'].splitlines():
+ if line.endswith("cinder_api"):
+ in_container = True
+
+ if (service_status['status'] == 0) or in_container:
+ heat_config = ""
+ # if containerized we need to pass the config to the cont.
+ if in_container:
+ heat_config = "--config-dir " + self.var_puppet_gen + \
+ "_api/etc/heat/"
+
self.add_cmd_output(
- "heat-manage db_version",
+ "heat-manage " + heat_config + " db_version",
suggest_filename="heat_db_version"
)
diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py
index cdd297608..e8839a2a6 100644
--- a/sos/plugins/openstack_nova.py
+++ b/sos/plugins/openstack_nova.py
@@ -32,40 +32,70 @@ class OpenStackNova(Plugin):
var_puppet_gen = "/var/lib/config-data/puppet-generated/nova"
def setup(self):
- # commands we do not need to source the environment file
- self.add_cmd_output("nova-manage db version")
- self.add_cmd_output("nova-manage fixed list")
- self.add_cmd_output("nova-manage floating list")
- vars_all = [p in os.environ for p in [
- 'OS_USERNAME', 'OS_PASSWORD']]
-
- vars_any = [p in os.environ for p in [
- 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
+ # collect commands output only if the openstack-nova-api service
+ # is running
+ service_status = self.get_command_output(
+ "systemctl status openstack-nova-api.service"
+ )
- if not (all(vars_all) and any(vars_any)):
- self.soslog.warning("Not all environment variables set. Source "
- "the environment file for the user intended "
- "to connect to the OpenStack environment.")
- else:
- self.add_cmd_output("nova service-list")
- self.add_cmd_output("openstack flavor list --long")
- self.add_cmd_output("nova network-list")
- self.add_cmd_output("nova list")
- self.add_cmd_output("nova agent-list")
- self.add_cmd_output("nova version-list")
- self.add_cmd_output("nova host-list")
- self.add_cmd_output("openstack quota show")
- self.add_cmd_output("openstack hypervisor stats show")
- # get details for each nova instance
- cmd = "openstack server list -f value"
- nova_instances = self.call_ext_prog(cmd)['output']
- for instance in nova_instances.splitlines():
- instance = instance.split()[0]
- cmd = "openstack server show %s" % (instance)
- self.add_cmd_output(
- cmd,
- suggest_filename="instance-" + instance + ".log")
+ container_status = self.get_command_output("docker ps")
+ in_container = False
+ if container_status['status'] == 0:
+ for line in container_status['output'].splitlines():
+ if line.endswith("cinder_api"):
+ in_container = True
+
+ if (service_status['status'] == 0) or in_container:
+ nova_config = ""
+ # if containerized we need to pass the config to the cont.
+ if in_container:
+ nova_config = "--config-dir " + self.var_puppet_gen + \
+ "/etc/nova/"
+
+ self.add_cmd_output(
+ "nova-manage " + nova_config + " db version",
+ suggest_filename="nova-manage_db_version"
+ )
+ self.add_cmd_output(
+ "nova-manage " + nova_config + " fixed list",
+ suggest_filename="nova-manage_fixed_list"
+ )
+ self.add_cmd_output(
+ "nova-manage " + nova_config + " floating list",
+ suggest_filename="nova-manage_floating_list"
+ )
+
+ vars_all = [p in os.environ for p in [
+ 'OS_USERNAME', 'OS_PASSWORD']]
+
+ vars_any = [p in os.environ for p in [
+ 'OS_TENANT_NAME', 'OS_PROJECT_NAME']]
+
+ if not (all(vars_all) and any(vars_any)):
+ self.soslog.warning("Not all environment variables set. "
+ "Source the environment file for the user "
+ "intended to connect to the OpenStack "
+ "environment.")
+ else:
+ self.add_cmd_output("nova service-list")
+ self.add_cmd_output("openstack flavor list --long")
+ self.add_cmd_output("nova network-list")
+ self.add_cmd_output("nova list")
+ self.add_cmd_output("nova agent-list")
+ self.add_cmd_output("nova version-list")
+ self.add_cmd_output("nova hypervisor-list")
+ self.add_cmd_output("openstack quota show")
+ self.add_cmd_output("openstack hypervisor stats show")
+ # get details for each nova instance
+ cmd = "openstack server list -f value"
+ nova_instances = self.call_ext_prog(cmd)['output']
+ for instance in nova_instances.splitlines():
+ instance = instance.split()[0]
+ cmd = "openstack server show %s" % (instance)
+ self.add_cmd_output(
+ cmd,
+ suggest_filename="instance-" + instance + ".log")
self.limit = self.get_option("log_size")
if self.get_option("all_logs"):
From 2140b1611565078c4a6536782c013a525722e0da Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Thu, 21 Dec 2017 08:00:41 +0100
Subject: [PATCH] [openstack_glance|heat|nova] fix api container names
Container names of glance, heat and nova api was not correct
when verify if a the container is running.
Signed-off-by: Martin Schuppert <mschuppe@redhat.com>
---
sos/plugins/openstack_glance.py | 2 +-
sos/plugins/openstack_heat.py | 2 +-
sos/plugins/openstack_nova.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sos/plugins/openstack_glance.py b/sos/plugins/openstack_glance.py
index 4cdc6dc62..d7588abe0 100644
--- a/sos/plugins/openstack_glance.py
+++ b/sos/plugins/openstack_glance.py
@@ -64,7 +64,7 @@ def setup(self):
in_container = False
if container_status['status'] == 0:
for line in container_status['output'].splitlines():
- if line.endswith("cinder_api"):
+ if line.endswith("glance_api"):
in_container = True
if (service_status['status'] == 0) or in_container:
diff --git a/sos/plugins/openstack_heat.py b/sos/plugins/openstack_heat.py
index e3395fabd..0cf7c8595 100644
--- a/sos/plugins/openstack_heat.py
+++ b/sos/plugins/openstack_heat.py
@@ -40,7 +40,7 @@ def setup(self):
in_container = False
if container_status['status'] == 0:
for line in container_status['output'].splitlines():
- if line.endswith("cinder_api"):
+ if line.endswith("heat_api"):
in_container = True
if (service_status['status'] == 0) or in_container:
diff --git a/sos/plugins/openstack_nova.py b/sos/plugins/openstack_nova.py
index e8839a2a6..951e69cba 100644
--- a/sos/plugins/openstack_nova.py
+++ b/sos/plugins/openstack_nova.py
@@ -43,7 +43,7 @@ def setup(self):
in_container = False
if container_status['status'] == 0:
for line in container_status['output'].splitlines():
- if line.endswith("cinder_api"):
+ if line.endswith("nova_api"):
in_container = True
if (service_status['status'] == 0) or in_container:
From 8ce70c4d3683ce977f1243c56b7d4f4b6782c0df Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Fri, 29 Dec 2017 09:20:33 +0100
Subject: [PATCH] [openstack_cinder] check for api service running via
cinder_wsgi
With OSP11 cinder api changed to run via https wsgi. To check for
running cinder-manage command we also need to take this situation.
The change checks for cinder_wsgi process.
Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
---
sos/plugins/openstack_cinder.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/sos/plugins/openstack_cinder.py b/sos/plugins/openstack_cinder.py
index a023105c8..6b292d279 100644
--- a/sos/plugins/openstack_cinder.py
+++ b/sos/plugins/openstack_cinder.py
@@ -37,14 +37,23 @@ def setup(self):
"systemctl status openstack-cinder-api.service"
)
+ ps_status = self.get_command_output("ps -ef")
+ in_ps = False
+ if ps_status['status'] == 0:
+ for line in ps_status['output'].splitlines():
+ if "cinder_wsgi" in line:
+ in_ps = True
+ break
+
container_status = self.get_command_output("docker ps")
in_container = False
if container_status['status'] == 0:
for line in container_status['output'].splitlines():
if line.endswith("cinder_api"):
in_container = True
+ break
- if (service_status['status'] == 0) or in_container:
+ if (service_status['status'] == 0) or in_container or in_ps:
cinder_config = ""
# if containerized we need to pass the config to the cont.
if in_container: