Skip to content

Conversation

@larsks
Copy link
Member

@larsks larsks commented May 16, 2025

The port forwarding create command would exit with an error if you attempted to create a forwarding configuration that already exists. This made it difficult to identify actual failures.

This commit updates the port forwarding create command so that it is not an error if the requested forwarding already exists.

The old behavior was:

$ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| 43c96be3-861d-4818-a32a-079a93b6f9c4 |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
$ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
BadRequestException: 400: Client Error for url:
https://esi.massopen.cloud:13696/v2.0/floatingips/be4b2718-ec5f-4722-80b5-485c421e4a72/port_forwardings,
Bad port_forwarding request: A duplicate port forwarding entry with
same attributes already exists, conflicting values are
{'floatingip_id': 'be4b2718-ec5f-4722-80b5-485c421e4a72',
'external_port': 8888, 'protocol': 'tcp'}.

The new behavior looks like this:

$ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| 43c96be3-861d-4818-a32a-079a93b6f9c4 |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
$ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| exists                               |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
| d7d56201-232a-41fe-8ae6-1f6fb88a37d3 |          8889 |          8889 | tcp      | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+

@larsks larsks requested a review from tzumainn May 16, 2025 18:08
@larsks
Copy link
Member Author

larsks commented May 16, 2025

After this merges we should push a new release to pypi.

@larsks
Copy link
Member Author

larsks commented May 16, 2025

Curses, need to update the tests.

@larsks larsks force-pushed the feature/idempotent-forwarding branch from 06f5b07 to 9caf7f0 Compare May 16, 2025 18:29
@larsks
Copy link
Member Author

larsks commented May 16, 2025

Tests are updated!

@larsks larsks enabled auto-merge May 16, 2025 18:52
Copy link
Contributor

@tzumainn tzumainn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well - two minor comments/questions!

@larsks larsks force-pushed the feature/idempotent-forwarding branch from 9caf7f0 to f669899 Compare May 19, 2025 13:45
The `port forwarding create` command would exit with an error
if you attempted to create a forwarding configuration that already exists.
This made it difficult to identify actual failures.

This commit updates the `port forwarding create` command so that it is not
an error if the requested forwarding already exists.

The old behavior was:

    $ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | 43c96be3-861d-4818-a32a-079a93b6f9c4 |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    $ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
    BadRequestException: 400: Client Error for url:
    https://esi.massopen.cloud:13696/v2.0/floatingips/be4b2718-ec5f-4722-80b5-485c421e4a72/port_forwardings,
    Bad port_forwarding request: A duplicate port forwarding entry with
    same attributes already exists, conflicting values are
    {'floatingip_id': 'be4b2718-ec5f-4722-80b5-485c421e4a72',
    'external_port': 8888, 'protocol': 'tcp'}.

The new behavior looks like this:

    $ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | 43c96be3-861d-4818-a32a-079a93b6f9c4 |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    $ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | ID                                   | Internal Port | External Port | Protocol | Internal IP   | External IP   |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
    | exists                               |          8888 |          8888 | tcp      | 192.168.11.31 | 128.31.20.118 |
    | d7d56201-232a-41fe-8ae6-1f6fb88a37d3 |          8889 |          8889 | tcp      | 192.168.11.31 | 128.31.20.118 |
    +--------------------------------------+---------------+---------------+----------+---------------+---------------+
@larsks larsks force-pushed the feature/idempotent-forwarding branch from f669899 to 900d169 Compare May 19, 2025 13:48
Copy link
Contributor

@tzumainn tzumainn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works perfect - thanks!

@larsks larsks merged commit 27f8ee3 into CCI-MOC:master May 19, 2025
6 checks passed
@tzumainn
Copy link
Contributor

new release pushed to pypi

larsks added a commit to larsks/cloudkit-aap that referenced this pull request May 19, 2025
We use the `openstack esi port forwarding` command in the `external_access`
role to configure port forwarding. Previously, this command would fail with
an error when attempting to create a port forwarding that already exists.
This made it difficult to identify legitimate failures.

With CCI-MOC/python-esiclient#89, python-esiclient is now idempotent and
will not emit an error if an existing port forwarding exactly matches the
requested configuration.
larsks added a commit to innabox/cloudkit-aap that referenced this pull request May 19, 2025
We use the `openstack esi port forwarding` command in the `external_access`
role to configure port forwarding. Previously, this command would fail with
an error when attempting to create a port forwarding that already exists.
This made it difficult to identify legitimate failures.

With CCI-MOC/python-esiclient#89, python-esiclient is now idempotent and
will not emit an error if an existing port forwarding exactly matches the
requested configuration.
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

Successfully merging this pull request may close these issues.

2 participants