<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:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:tax="http://schemas.microsoft.com/sharepoint/taxonomy/soap/" xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/recordsrepository/" xmlns:spsup="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:st="" 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 14 (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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Intel Clear";}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Intel Clear";
        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.EmailStyle20
        {mso-style-type:personal;
        font-family:"Intel Clear";
        color:#1F497D;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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="color:#1F497D">Thanks Tingjie. Using kubectl for prototyping is OK, but when you are submitting code for review, please extend the KubeOperator to support the APIs you require.<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 0cm 0cm 0cm">
<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 [mailto:tingjie.chen@intel.com]
<br>
<b>Sent:</b> January 14, 2020 8:27 AM<br>
<b>To:</b> Wensley, Barton; starlingx-discuss@lists.starlingx.io<br>
<b>Subject:</b> RE: 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";color:#1F497D">Thanks Barton,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";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";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";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";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D">Tingjie<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<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 0cm 0cm 0cm">
<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"">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">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"">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"">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"">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""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">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""><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Intel Clear"">Piece of code:<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">        execute_process = subprocess.Popen(command,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">            stdout=subprocess.PIPE, stderr=sys.stderr)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">        objects = yaml.safe_load(execute_process.stdout)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">        if execute_process.wait() != 0:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">            raise ApiError<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear";color:#0070C0">        return objects<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear""><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Intel Clear"">Following is the output:<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">-----------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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"">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""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">Tingjie<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">SSP NST Storage<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">Tel: +86(21)88216699<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear"">Mobile: 15901876439<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>