<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Intel Clear";
panose-1:2 11 6 4 2 2 3 2 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Intel Clear",sans-serif;
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Intel Clear",sans-serif;
color:#1F497D;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D">Thanks Barton,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D">I think it is the reason for the failure
</span><span style="font-family:Wingdings;color:#1F497D">J</span><span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D">Yes, It is a better way to use Kubernetes.client API to communicate with Kubernetes cluster, but the interface in sysinv/common/Kubernetes.py is not enough to support the
Ceph plugin, so I have made a simple kube Api to verify the functionality and it will be better to extend the interface in Kubernetes.py to support Ceph plugin further, for example:
</span><a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#connect_get_namespaced_pod_exec">https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#connect_get_namespaced_pod_exec</a>
<span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D">Tingjie<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Wensley, Barton <Barton.Wensley@windriver.com> <br>
<b>Sent:</b> Tuesday, January 14, 2020 8:58 PM<br>
<b>To:</b> Chen, Tingjie <tingjie.chen@intel.com>; starlingx-discuss@lists.starlingx.io<br>
<b>Subject:</b> RE: About execute bash command in sysinv conductor<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">Tingjie,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">It looks like you are missing the --kubeconfig parameter for kubectl, which should point to the /etc/kubernetes/admin.conf file which contains the authentication credentials.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">However, it is better to use the python-kubernetes API instead of kubectl - take a look at the KubeOperator class in sysinv/common/kubernetes.py - that is our preferred way to communicate with the kubernetes
API.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Bart<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma",sans-serif">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma",sans-serif"> Chen, Tingjie [<a href="mailto:tingjie.chen@intel.com">mailto:tingjie.chen@intel.com</a>]
<br>
<b>Sent:</b> January 14, 2020 5:47 AM<br>
<b>To:</b> <a href="mailto:starlingx-discuss@lists.starlingx.io">starlingx-discuss@lists.starlingx.io</a><br>
<b>Subject:</b> [Starlingx-discuss] About execute bash command in sysinv conductor<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">I have met an issue when add a new plugin which called by sysinv,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">The plugin is to execute some bash commands, such as kubectl to get information, but it seems I have tried by using:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Subprocess.Popen() and subprocess.check_output() it return failed with non-zero exit status 1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">But I tried on my local Ubuntu environment, the result is OK.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Is there any audit or privilege or some audit in Sysinv Service?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Intel Clear",sans-serif">Piece of code:<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> execute_process = subprocess.Popen(command,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> stdout=subprocess.PIPE, stderr=sys.stderr)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> objects = yaml.safe_load(execute_process.stdout)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> if execute_process.wait() != 0:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> raise ApiError<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif;color:#0070C0"> return objects<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Intel Clear",sans-serif">Following is the output:<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">-----------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">sysinv 2020-01-14 10:31:20.038 1172858 INFO sysinv.common.ceph [-] ceph osd crush rule ls<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">sysinv 2020-01-14 10:31:20.038 1172858 ERROR rook_client_kubeapi [-] ['/usr/bin/kubectl', 'get', '--namespace', 'kube-system', 'pod', '-l', 'app=rook-ceph-tools', '-o', 'jsonpath="{.items[0].metadata.name}"']<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">sysinv 2020-01-14 10:31:20.038 1172858 INFO rook_client_kubeapi [-] Get pod command: ['/usr/bin/kubectl', 'get', '--namespace', 'kube-system', 'pod', '-l', 'app=rook-ceph-tools', '-o',
'jsonpath="{.items[0].metadata.name}"']<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">sysinv 2020-01-14 10:31:45.026 1172858 ERROR sysinv.common.ceph [-] Exception in ls crush rule: Command '['/usr/bin/kubectl', 'get', '--namespace', 'kube-system', 'pod', '-l', 'app=rook-ceph-tools',
'-o', 'jsonpath="{.items[0].metadata.name}"']' returned non-zero exit status 1: CalledProcessError: Command '['/usr/bin/kubectl', 'get', '--namespace', 'kube-system', 'pod', '-l', 'app=rook-ceph-tools', '-o', 'jsonpath="{.items[0].metadata.name}"']' returned
non-zero exit status 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">sysinv 2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp [-] Exception during message handling: CephFailure: OSD crush rule ls failed. Command '['/usr/bin/kubectl',
'get', '--namespace', 'kube-system', 'pod', '-l', 'app=rook-ceph-tools', '-o', 'jsonpath="{.items[0].metadata.name}"']' returned non-zero exit status 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp Traceback (most recent call last):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp File "/usr/lib64/python2.7/site-packages/sysinv/openstack/common/rpc/amqp.py", line 437, in _process_data<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp **args)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp File "/usr/lib64/python2.7/site-packages/sysinv/openstack/common/rpc/dispatcher.py", line 172, in dispatch<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp File "/usr/lib64/python2.7/site-packages/sysinv/conductor/manager.py", line 4405, in iplatform_update_by_ihost<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp cceph.fix_crushmap(self.dbapi)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp File "/usr/lib64/python2.7/site-packages/sysinv/common/ceph.py", line 947, in fix_crushmap<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp rule_is_present, __, __ = _operator._crush_rule_status(default_ceph_tier_name)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp File "/usr/lib64/python2.7/site-packages/sysinv/common/ceph.py", line 67, in _crush_rule_status<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">2020-01-14 10:31:45.027 1172858 ERROR sysinv.openstack.common.rpc.amqp raise exception.CephFailure("OSD crush rule ls failed. %s" %str(e))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Tingjie<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">SSP NST Storage<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Tel: +86(21)88216699<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Mobile: 15901876439<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>