<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 9, 2022, 05:51 Gk Gk <<a href="mailto:ygk.kmr@gmail.com" target="_blank" rel="noreferrer">ygk.kmr@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks Melanie for the reply. I am able to use pdb successfully for the trace. But I am observing a strange behaviour with the python source files. Whenever I make any changes to the source files</div><div>, for example, insert a pdb statement in servers.py, it is taking a minute or more for the changes to take effect. For example, after the change, if I run the uwsgi command at the terminal manually with --honour-stdin option,  then immediately if I fire the nova list command, it is not taking effect. Only after a minute or so of making the change, it is taking effect. Somewhat strange.</div><div><br></div><div>My next question is, inside the nova-api container, I am trying to trace how nova-api service starts. The systemd file has this content:</div><div>---</div><div>ExecStart = /openstack/venvs/uwsgi-20.2.1-python3/bin/uwsgi --autoload --ini /etc/uwsgi/nova-api-os-compute.ini</div><div>---- <br></div><div>So I have checked the file /etc/uwsgi/nova-api-os-compute.ini , which has the below content:</div><div>---</div><div>wsgi-file = /openstack/venvs/nova-20.2.1/bin/nova-api-wsgi</div><div>--</div><div><br></div><div>Is the above file '/openstack/venvs/nova-20.2.1/bin/nova-api-wsgi' the one from which the nova-api service starts at all ?</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That is correct. The nova-api-wsgi and nova-metadata-wsgi entry points read nova.conf and api-paste.ini to generate the required WSGI application.</div><div dir="auto"><br></div><div dir="auto">Those scripts are just python entry points so you should be able to follow along there, barring some setuptools magic invoked.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div><br></div><div>Thanks</div><div>Kumar<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 9, 2022 at 5:39 AM melanie witt <<a href="mailto:melwittt@gmail.com" rel="noreferrer noreferrer" target="_blank">melwittt@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue Nov 08 2022 03:03:18 GMT-0800 (Pacific Standard Time), Gk Gk <br>
<<a href="mailto:ygk.kmr@gmail.com" rel="noreferrer noreferrer" target="_blank">ygk.kmr@gmail.com</a>> wrote:<br>
> Hi All,<br>
> <br>
> I have a OSA setup. I am trying to trace the control flow of nova-api <br>
> using pdb in the file<br>
> "/openstack/venvs/nova-20.2.1/lib/python3.6/site-packages/nova/objects/instance.py".<br>
> <br>
> My goal is to trace the flow for "nova list --all" command. I am <br>
> launching the nova-api service  manually from the command line as follows:<br>
> <br>
> #/openstack/venvs/uwsgi-20.2.1-python3/bin/uwsgi --ini <br>
> /etc/uwsgi/nova-api-os-compute.ini   --workers 1<br>
> <br>
> I am executing "nova list --all" command in another terminal.  I have <br>
> inserted pdb in instance.py as follows:<br>
> <br>
> ----<br>
>      @base.remotable_classmethod<br>
>      def get_all(cls, context, expected_attrs=None):<br>
>          import pdb; pdb.set_trace()<br>
>          """Returns all instances on all nodes."""<br>
>          db_instances = db.instance_get_all(<br>
>                  context, columns_to_join=_expected_cols(expected_attrs))<br>
>          return _make_instance_list(context, cls(), db_instances,<br>
>                                     expected_attrs)<br>
> ---<br>
> <br>
> But when I fire the nova list --all command, I see no pdb prompt being <br>
> shown in the nova-api window. Can anyone help me how to use the pdb to <br>
> trace the flow of control  for "nova list --all" command ?<br>
<br>
It looks like running nova-api that way is still running as a background <br>
process:<br>
<br>
<a href="https://stackoverflow.com/questions/34914704/bdbquit-raised-when-debugging-python-with-pdb" rel="noreferrer noreferrer noreferrer" target="_blank">https://stackoverflow.com/questions/34914704/bdbquit-raised-when-debugging-python-with-pdb</a><br>
<br>
I got that result ^ when I tried it locally.<br>
<br>
I was however able to get success with remote pdb:<br>
<br>
<a href="https://docs.openstack.org/devstack/latest/systemd.html#using-remote-pdb" rel="noreferrer noreferrer noreferrer" target="_blank">https://docs.openstack.org/devstack/latest/systemd.html#using-remote-pdb</a><br>
<br>
so maybe give that a try. Note that the code where you set the trace in <br>
nova/objects/instance.py is not actually hit when doing a server list. <br>
You may have instead meant:<br>
<br>
<a href="https://github.com/openstack/nova/blob/c97507dfcd57cce9d76670d3b0d48538900c00e9/nova/compute/api.py#L2991" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/openstack/nova/blob/c97507dfcd57cce9d76670d3b0d48538900c00e9/nova/compute/api.py#L2991</a><br>
<br>
Also note that as a community we're trying to get away from using the <br>
legacy 'nova' command and recommend using the openstackclient instead:<br>
<br>
<a href="https://docs.openstack.org/python-openstackclient/latest/cli/command-objects/server.html#server-list" rel="noreferrer noreferrer noreferrer" target="_blank">https://docs.openstack.org/python-openstackclient/latest/cli/command-objects/server.html#server-list</a><br>
<br>
The 'nova' CLI is no longer being maintained and we're adding to the <br>
novaclient python bindings only when necessary.<br>
<br>
HTH,<br>
-melwitt<br>
<br>
<br>
<br>
</blockquote></div>
</blockquote></div></div></div>