Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esi node network attach should print API error message #664

Open
larsks opened this issue Dec 6, 2024 · 5 comments
Open

esi node network attach should print API error message #664

larsks opened this issue Dec 6, 2024 · 5 comments
Assignees

Comments

@larsks
Copy link
Member

larsks commented Dec 6, 2024

I had an openstack esi node network attach command fail like this:

Unrecognized schema in response body. (HTTP 400)

Running the command in --debug shows shows that the API is actually providing a useful error message:

RESP: [400] Content-Length: 177 Content-Type: application/json Date: Fri, 06 Dec 2024 22:23:05 GMT Openstack-Request-Id: req-183b734c-e3dc-4481-8e0c-0c1bd0e9e1f8 Server: Apache X-OpenStack-Ironic-API-Maximum-Version: 1.72 X-OpenStack-Ironic-API-Minimum-Version: 1.1 X-OpenStack-Ironic-API-Version: 1.69
RESP BODY: {"error_message": "{\"faultcode\":\"Client\",\"faultstring\":\"Unable to attach VIF 9a651d18-8d9d-4bfd-b283-0d760f800ee1, not enough free physical ports.\",\"debuginfo\":null}"}

We should be returning that error information to the user.

@tzumainn tzumainn self-assigned this Dec 11, 2024
@larsks
Copy link
Member Author

larsks commented Dec 11, 2024

Here's another example of the same problem. Try to specify a network that doesn't exist to ... esi trunk create, and you get:

'NoneType' object has no attribute 'name'

But the API response provides a more useful error message:

RESP BODY: {"NeutronError": {"type": "NetworkNotFound", "message": "Network does-not-exist could not be found.", "detail": ""}}

@tzumainn tzumainn assigned skanthed and unassigned tzumainn Dec 12, 2024
@skanthed
Copy link
Collaborator

@larsks @tzumainn Could you share the exact command you used? I seem to be getting the correct error message instead.

(new-openstack-env) [surbhikanthed@localhost openshift-openstack]$ openstack esi node network attach eb932b4d-2d7c-4890-ac83-03240a1ae3ec --network <network-name>

+-------------+-------------------------------------------+
| Field       | Value                                     |
+-------------+-------------------------------------------+
| Node        | MOC-R4PAC24U37-S1A                        |
| MAC Address | a8:99:69:6f:75:84                         |
| Port        | esi-MOC-R4PAC24U37-S1A-network-name |
| Network     | network-name                        |
| Fixed IP    | fixed ip value                      |
+-------------+-------------------------------------------+
(new-openstack-env) [surbhikanthed@localhost openshift-openstack]$ 
(new-openstack-env) [surbhikanthed@localhost openshift-openstack]$ openstack esi node network attach  eb932b4d-2d7c-4890-ac83-03240a1ae3ec --network <network-name>
Node MOC-R4PAC24U37-S1A has no free ports
(new-openstack-env) [surbhikanthed@localhost openshift-openstack]$ 

I am able to reproduce the second one ...esi trunk create one.

@larsks
Copy link
Member Author

larsks commented Dec 16, 2024

@skanthed I'm working with these versions:

esisdk                    1.3.0
python-esiclient          1.0.0
python-esileapclient      1.0.0

I started with:

$ openstack esi node network list
+--------------------+-------------------+------+---------+----------+------------------+-------------+
| Node               | MAC Address       | Port | Network | Fixed IP | Floating Network | Floating IP |
+--------------------+-------------------+------+---------+----------+------------------+-------------+
| MOC-R4PAC22U31-S1C | e0:d8:48:e5:ae:a9 | None | None    | None     | None             | None        |
| MOC-R4PAC22U31-S1C | e0:d8:48:e5:ae:ac | None | None    | None     | None             | None        |
+--------------------+-------------------+------+---------+----------+------------------+-------------+

The first attach works as expected:

$ openstack esi node network attach --network larsnet0 MOC-R4PAC22U31-S1C
+-------------+---------------------------------+
| Field       | Value                           |
+-------------+---------------------------------+
| Node        | MOC-R4PAC22U31-S1C              |
| MAC Address | e0:d8:48:e5:ae:a9               |
| Port        | esi-MOC-R4PAC22U31-S1C-larsnet0 |
| Network     | larsnet0                        |
| Fixed IP    | 192.168.79.155                  |
+-------------+---------------------------------+

But the second attach attempt fails, and does not produce a useful error message:

$ openstack esi node network attach --network larsnet0 MOC-R4PAC22U31-S1C
Unrecognized schema in response body. (HTTP 409)

If we re-run that command with --debug, we see that there is actually a useful error message available:

RESP BODY: {"error_message": "{\"faultcode\":\"Client\",\"faultstring\":\"Unable to attach VIF because VIF c89563ed-0b39-4b97-801c-808b6b623eb1 is already attached to Ironic Port 2b18e8be-2650-4e53-b3f4-3580f0534501\",\"debuginfo\":null}"}

We can of course successfully perform the second attach by specifying the MAC address:

$ openstack --debug esi node network attach --network larsnet0 --mac-address e0:d8:48:e5:ae:ac MOC-R4PAC22U31-S1C

At this point we have:

$ openstack esi node network list
+--------------------+-------------------+---------------------------------+----------------+----------------+------------------+-------------+
| Node               | MAC Address       | Port                            | Network        | Fixed IP       | Floating Network | Floating IP |
+--------------------+-------------------+---------------------------------+----------------+----------------+------------------+-------------+
| MOC-R4PAC22U31-S1C | e0:d8:48:e5:ae:a9 | esi-MOC-R4PAC22U31-S1C-larsnet0 | larsnet0 (398) | 192.168.79.155 | None             | None        |
| MOC-R4PAC22U31-S1C | e0:d8:48:e5:ae:ac | esi-MOC-R4PAC22U31-S1C-larsnet0 | larsnet0 (398) | 192.168.79.155 | None             | None        |
+--------------------+-------------------+---------------------------------+----------------+----------------+------------------+-------------+

If we try that a second time -- which should trigger a "no free ports" error -- we get:

$ openstack --debug esi node network attach --network larsnet0 --mac-address e0:d8:48:e5:ae:ac MOC-R4PAC22U31-S1C
Unrecognized schema in response body. (HTTP 409)

With --debug we see:

RESP BODY: {"error_message": "{\"faultcode\":\"Client\",\"faultstring\":\"Unable to attach VIF because VIF c89563ed-0b39-4b97-801c-808b6b623eb1 is already attached to Ironic Port 22d5cb31-3481-436f-991e-9c1ffbb3c5ee\",\"debuginfo\":null}"}

@skanthed
Copy link
Collaborator

@larsks I will look into it.

@skanthed
Copy link
Collaborator

This is fix for esi trunk create CCI-MOC/python-esiclient#71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants