Blame SOURCES/sos-bz1620048-etcd-kube-osp-3-10.patch

fce3c4
From 6372a7f7f09511d864aa6bd894109d937f4fda65 Mon Sep 17 00:00:00 2001
fce3c4
From: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
Date: Thu, 12 Jul 2018 12:36:25 -0400
fce3c4
Subject: [PATCH 1/3] [kubernetes|etcd] Support OpenShift 3.10 deployments
fce3c4
fce3c4
The 3.10 version of OCP changes the deployment configurations for etcd
fce3c4
and kubernetes components, and additionally changes the way the etcdctl
fce3c4
command is called when running in a static pod. Update these plugins to
fce3c4
support this new deployment style.
fce3c4
fce3c4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/etcd.py       |  11 ++-
fce3c4
 sos/plugins/kubernetes.py | 148 +++++++++++++++++++-------------------
fce3c4
 2 files changed, 83 insertions(+), 76 deletions(-)
fce3c4
fce3c4
diff --git a/sos/plugins/etcd.py b/sos/plugins/etcd.py
fce3c4
index c343f750..c8ee3849 100644
fce3c4
--- a/sos/plugins/etcd.py
fce3c4
+++ b/sos/plugins/etcd.py
fce3c4
@@ -10,6 +10,7 @@
fce3c4
 # See the LICENSE file in the source distribution for further information.
fce3c4
 
fce3c4
 from sos.plugins import Plugin, RedHatPlugin
fce3c4
+from os import path
fce3c4
 
fce3c4
 
fce3c4
 class etcd(Plugin, RedHatPlugin):
fce3c4
@@ -19,10 +20,14 @@ class etcd(Plugin, RedHatPlugin):
fce3c4
     plugin_name = 'etcd'
fce3c4
     packages = ('etcd',)
fce3c4
     profiles = ('container', 'system', 'services', 'cluster')
fce3c4
-
fce3c4
-    cmd = 'etcdctl'
fce3c4
+    files = ('/etc/origin/node/pods/etcd.yaml',)
fce3c4
 
fce3c4
     def setup(self):
fce3c4
+        if path.exists('/etc/origin/node/pods/etcd.yaml'):
fce3c4
+            etcd_cmd = 'master-exec etcd etcd etcdctl'
fce3c4
+        else:
fce3c4
+            etcd_cmd = 'etcdctl'
fce3c4
+
fce3c4
         etcd_url = self.get_etcd_url()
fce3c4
 
fce3c4
         self.add_forbidden_path('/etc/etcd/ca')
fce3c4
@@ -35,7 +40,7 @@ class etcd(Plugin, RedHatPlugin):
fce3c4
            'ls --recursive',
fce3c4
         ]
fce3c4
 
fce3c4
-        self.add_cmd_output(['%s %s' % (self.cmd, sub) for sub in subcmds])
fce3c4
+        self.add_cmd_output(['%s %s' % (etcd_cmd, sub) for sub in subcmds])
fce3c4
 
fce3c4
         urls = [
fce3c4
             '/v2/stats/leader',
fce3c4
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
fce3c4
index e75c7a37..21cb51df 100644
fce3c4
--- a/sos/plugins/kubernetes.py
fce3c4
+++ b/sos/plugins/kubernetes.py
fce3c4
@@ -18,11 +18,16 @@ class kubernetes(Plugin, RedHatPlugin):
fce3c4
     """Kubernetes plugin
fce3c4
     """
fce3c4
 
fce3c4
-    # Red Hat Atomic Platform and OpenShift Enterprise use the
fce3c4
-    # atomic-openshift-master package to provide kubernetes
fce3c4
+    # OpenShift Container Platform uses the atomic-openshift-master package
fce3c4
+    # to provide kubernetes
fce3c4
     packages = ('kubernetes', 'kubernetes-master', 'atomic-openshift-master')
fce3c4
     profiles = ('container',)
fce3c4
-    files = ("/etc/origin/master/master-config.yaml",)
fce3c4
+    # use files only for masters, rely on package list for nodes
fce3c4
+    files = (
fce3c4
+        "/var/run/kubernetes/apiserver.key",
fce3c4
+        "/etc/origin/master/",
fce3c4
+        "/etc/origin/node/pods/master-config.yaml"
fce3c4
+    )
fce3c4
 
fce3c4
     option_list = [
fce3c4
         ("all", "also collect all namespaces output separately",
fce3c4
@@ -33,12 +38,7 @@ class kubernetes(Plugin, RedHatPlugin):
fce3c4
     ]
fce3c4
 
fce3c4
     def check_is_master(self):
fce3c4
-        if any([
fce3c4
-            path.exists("/var/run/kubernetes/apiserver.key"),
fce3c4
-            path.exists("/etc/origin/master/master-config.yaml")
fce3c4
-        ]):
fce3c4
-            return True
fce3c4
-        return False
fce3c4
+        return any([path.exists(f) for f in self.files])
fce3c4
 
fce3c4
     def setup(self):
fce3c4
         self.add_copy_spec("/etc/kubernetes")
fce3c4
@@ -56,74 +56,76 @@ class kubernetes(Plugin, RedHatPlugin):
fce3c4
             self.add_journal(units=svc)
fce3c4
 
fce3c4
         # We can only grab kubectl output from the master
fce3c4
-        if self.check_is_master():
fce3c4
-            kube_cmd = "kubectl "
fce3c4
-            if path.exists('/etc/origin/master/admin.kubeconfig'):
fce3c4
-                kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
fce3c4
-
fce3c4
-            kube_get_cmd = "get -o json "
fce3c4
-            for subcmd in ['version', 'config view']:
fce3c4
-                self.add_cmd_output('%s %s' % (kube_cmd, subcmd))
fce3c4
-
fce3c4
-            # get all namespaces in use
fce3c4
-            kn = self.get_command_output('%s get namespaces' % kube_cmd)
fce3c4
-            knsps = [n.split()[0] for n in kn['output'].splitlines()[1:] if n]
fce3c4
-
fce3c4
-            resources = [
fce3c4
-                'limitrange',
fce3c4
-                'pods',
fce3c4
-                'pvc',
fce3c4
-                'rc',
fce3c4
-                'resourcequota',
fce3c4
-                'services'
fce3c4
-            ]
fce3c4
-
fce3c4
-            # nodes and pvs are not namespaced, must pull separately.
fce3c4
-            # Also collect master metrics
fce3c4
-            self.add_cmd_output([
fce3c4
-                "{} get -o json nodes".format(kube_cmd),
fce3c4
-                "{} get -o json pv".format(kube_cmd),
fce3c4
-                "{} get --raw /metrics".format(kube_cmd)
fce3c4
-            ])
fce3c4
-
fce3c4
-            for n in knsps:
fce3c4
-                knsp = '--namespace=%s' % n
fce3c4
-                if self.get_option('all'):
fce3c4
-                    k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
fce3c4
-
fce3c4
-                    self.add_cmd_output('%s events' % k_cmd)
fce3c4
+        if not self.check_is_master():
fce3c4
+            return
fce3c4
+
fce3c4
+        kube_cmd = "kubectl "
fce3c4
+        if path.exists('/etc/origin/master/admin.kubeconfig'):
fce3c4
+            kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
fce3c4
+
fce3c4
+        kube_get_cmd = "get -o json "
fce3c4
+        for subcmd in ['version', 'config view']:
fce3c4
+            self.add_cmd_output('%s %s' % (kube_cmd, subcmd))
fce3c4
+
fce3c4
+        # get all namespaces in use
fce3c4
+        kn = self.get_command_output('%s get namespaces' % kube_cmd)
fce3c4
+        knsps = [n.split()[0] for n in kn['output'].splitlines()[1:] if n]
fce3c4
+
fce3c4
+        resources = [
fce3c4
+            'limitrange',
fce3c4
+            'pods',
fce3c4
+            'pvc',
fce3c4
+            'rc',
fce3c4
+            'resourcequota',
fce3c4
+            'services'
fce3c4
+        ]
fce3c4
+
fce3c4
+        # nodes and pvs are not namespaced, must pull separately.
fce3c4
+        # Also collect master metrics
fce3c4
+        self.add_cmd_output([
fce3c4
+            "{} get -o json nodes".format(kube_cmd),
fce3c4
+            "{} get -o json pv".format(kube_cmd),
fce3c4
+            "{} get --raw /metrics".format(kube_cmd)
fce3c4
+        ])
fce3c4
+
fce3c4
+        for n in knsps:
fce3c4
+            knsp = '--namespace=%s' % n
fce3c4
+            if self.get_option('all'):
fce3c4
+                k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
fce3c4
+
fce3c4
+                self.add_cmd_output('%s events' % k_cmd)
fce3c4
 
fce3c4
-                    for res in resources:
fce3c4
-                        self.add_cmd_output('%s %s' % (k_cmd, res))
fce3c4
-
fce3c4
-                    if self.get_option('describe'):
fce3c4
-                        # need to drop json formatting for this
fce3c4
-                        k_cmd = '%s get %s' % (kube_cmd, knsp)
fce3c4
-                        for res in resources:
fce3c4
-                            r = self.get_command_output(
fce3c4
-                                '%s %s' % (k_cmd, res))
fce3c4
-                            if r['status'] == 0:
fce3c4
-                                k_list = [k.split()[0] for k in
fce3c4
-                                          r['output'].splitlines()[1:]]
fce3c4
-                                for k in k_list:
fce3c4
-                                    k_cmd = '%s %s' % (kube_cmd, knsp)
fce3c4
-                                    self.add_cmd_output(
fce3c4
-                                        '%s describe %s %s' % (k_cmd, res, k))
fce3c4
-
fce3c4
-                if self.get_option('podlogs'):
fce3c4
-                    k_cmd = '%s %s' % (kube_cmd, knsp)
fce3c4
-                    r = self.get_command_output('%s get pods' % k_cmd)
fce3c4
-                    if r['status'] == 0:
fce3c4
-                        pods = [p.split()[0] for p in
fce3c4
-                                r['output'].splitlines()[1:]]
fce3c4
-                        for pod in pods:
fce3c4
-                            self.add_cmd_output('%s logs %s' % (k_cmd, pod))
fce3c4
-
fce3c4
-            if not self.get_option('all'):
fce3c4
-                k_cmd = '%s get --all-namespaces=true' % kube_cmd
fce3c4
                 for res in resources:
fce3c4
                     self.add_cmd_output('%s %s' % (k_cmd, res))
fce3c4
 
fce3c4
+                if self.get_option('describe'):
fce3c4
+                    # need to drop json formatting for this
fce3c4
+                    k_cmd = '%s get %s' % (kube_cmd, knsp)
fce3c4
+                    for res in resources:
fce3c4
+                        r = self.get_command_output(
fce3c4
+                            '%s %s' % (k_cmd, res))
fce3c4
+                        if r['status'] == 0:
fce3c4
+                            k_list = [k.split()[0] for k in
fce3c4
+                                      r['output'].splitlines()[1:]]
fce3c4
+                            for k in k_list:
fce3c4
+                                k_cmd = '%s %s' % (kube_cmd, knsp)
fce3c4
+                                self.add_cmd_output(
fce3c4
+                                    '%s describe %s %s' % (k_cmd, res, k))
fce3c4
+
fce3c4
+            if self.get_option('podlogs'):
fce3c4
+                k_cmd = '%s %s' % (kube_cmd, knsp)
fce3c4
+                r = self.get_command_output('%s get pods' % k_cmd)
fce3c4
+                if r['status'] == 0:
fce3c4
+                    pods = [p.split()[0] for p in
fce3c4
+                            r['output'].splitlines()[1:]]
fce3c4
+                    for pod in pods:
fce3c4
+                        self.add_cmd_output('%s logs %s' % (k_cmd, pod))
fce3c4
+
fce3c4
+        if not self.get_option('all'):
fce3c4
+            k_cmd = '%s get --all-namespaces=true' % kube_cmd
fce3c4
+            for res in resources:
fce3c4
+                self.add_cmd_output('%s %s' % (k_cmd, res))
fce3c4
+
fce3c4
     def postproc(self):
fce3c4
         # First, clear sensitive data from the json output collected.
fce3c4
         # This will mask values when the "name" looks susceptible of
fce3c4
-- 
fce3c4
2.17.1
fce3c4
fce3c4
fce3c4
From 63ad6c251ab88ab2f0e07ae9e3f1b2771d5e90ca Mon Sep 17 00:00:00 2001
fce3c4
From: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
Date: Thu, 12 Jul 2018 13:07:34 -0400
fce3c4
Subject: [PATCH 2/3] [kubernetes] Correct config option syntax
fce3c4
fce3c4
Versions of kubernetes after 1.5 use --kubeconfig instead of --config to
fce3c4
specify a configuration file to use for kubectl commands. Update the
fce3c4
kubernetes plugin to use the proper syntax.
fce3c4
fce3c4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/kubernetes.py | 2 +-
fce3c4
 1 file changed, 1 insertion(+), 1 deletion(-)
fce3c4
fce3c4
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
fce3c4
index 21cb51df..c14e078e 100644
fce3c4
--- a/sos/plugins/kubernetes.py
fce3c4
+++ b/sos/plugins/kubernetes.py
fce3c4
@@ -61,7 +61,7 @@ class kubernetes(Plugin, RedHatPlugin):
fce3c4
 
fce3c4
         kube_cmd = "kubectl "
fce3c4
         if path.exists('/etc/origin/master/admin.kubeconfig'):
fce3c4
-            kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
fce3c4
+            kube_cmd += "--kubeconfig=/etc/origin/master/admin.kubeconfig"
fce3c4
 
fce3c4
         kube_get_cmd = "get -o json "
fce3c4
         for subcmd in ['version', 'config view']:
fce3c4
-- 
fce3c4
2.17.1
fce3c4
fce3c4
fce3c4
From 46fffd469f4f3d07337dc335cfc24341e836f23b Mon Sep 17 00:00:00 2001
fce3c4
From: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
Date: Thu, 12 Jul 2018 13:11:44 -0400
fce3c4
Subject: [PATCH 3/3] [origin] Collect statistics information
fce3c4
fce3c4
Adds collection of 'oc adm top' output for images and imagestreams.
fce3c4
fce3c4
Resolves: #1165
fce3c4
Closes: #1383
fce3c4
fce3c4
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/origin.py | 26 ++++++++++++++++++++------
fce3c4
 1 file changed, 20 insertions(+), 6 deletions(-)
fce3c4
fce3c4
diff --git a/sos/plugins/origin.py b/sos/plugins/origin.py
fce3c4
index 02bc047a..0e384117 100644
fce3c4
--- a/sos/plugins/origin.py
fce3c4
+++ b/sos/plugins/origin.py
fce3c4
@@ -124,14 +124,28 @@ class OpenShiftOrigin(Plugin):
fce3c4
             #
fce3c4
             # Note: Information about nodes, events, pods, and services
fce3c4
             # is already collected by the Kubernetes plugin
fce3c4
+
fce3c4
+            subcmds = [
fce3c4
+                "describe projects",
fce3c4
+                "adm top images",
fce3c4
+                "adm top imagestreams"
fce3c4
+            ]
fce3c4
+
fce3c4
             self.add_cmd_output([
fce3c4
-                "%s describe projects" % oc_cmd_admin,
fce3c4
-                "%s get -o json hostsubnet" % oc_cmd_admin,
fce3c4
-                "%s get -o json clusternetwork" % oc_cmd_admin,
fce3c4
-                "%s get -o json netnamespaces" % oc_cmd_admin,
fce3c4
-                # Registry and router configs are typically here
fce3c4
-                "%s get -o json dc -n default" % oc_cmd_admin,
fce3c4
+                '%s %s' % (oc_cmd_admin, subcmd) for subcmd in subcmds
fce3c4
             ])
fce3c4
+
fce3c4
+            jcmds = [
fce3c4
+                "hostsubnet",
fce3c4
+                "clusternetwork",
fce3c4
+                "netnamespaces",
fce3c4
+                "dc -n default"
fce3c4
+            ]
fce3c4
+
fce3c4
+            self.add_cmd_output([
fce3c4
+                '%s get -o json %s' % (oc_cmd_admin, jcmd) for jcmd in jcmds
fce3c4
+            ])
fce3c4
+
fce3c4
             if self.get_option('diag'):
fce3c4
                 diag_cmd = "%s adm diagnostics -l 0" % oc_cmd_admin
fce3c4
                 if self.get_option('diag-prevent'):
fce3c4
-- 
fce3c4
2.17.1
fce3c4