Invalid command of "openstack subnet pool unset"

Bug #1670230 reported by jiahui.qiang
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Confirmed
Undecided
Unassigned

Bug Description

when i wanna unset pool-prefix in the command "openstack subnet pool unset", the result is failed. there is something worry in unset pool-prefix.
I copy the commandline of my box:
➜ python-openstackclient git:(func-network-subnet-pool) ✗ openstack subnet pool list
+----------------------------+---------------------------+--------------------+
| ID | Name | Prefixes |
+----------------------------+---------------------------+--------------------+
| 399a1fa7-fa66-4a0f-90cf- | shared-default-subnetpool | fdf2:6718:964::/56 |
| a148ce20d062 | | |
| 3fd08d94-ab67-400c-9522-c9 | test | 10.100.0.0/16 |
| 34cca87776 | | |
| 9b8dbdf0-bc2c- | shared-default-subnetpool | 10.0.0.0/22 |
| 4d85-ac97-a3a0289d3b88 | | |
+----------------------------+---------------------------+--------------------+
➜ python-openstackclient git:(func-network-subnet-pool) ✗ openstack subnet pool set test --pool-prefix 10.111.0.0/16
➜ python-openstackclient git:(func-network-subnet-pool) ✗ openstack subnet pool unset test --pool-prefix 10.111.0.0/16
HttpException: Bad Request

Revision history for this message
Ankur (ankur-gupta-f) wrote :

Can you provide info on which sdk version and OSC version you were using.

Revision history for this message
jiahui.qiang (jiahui.qiang) wrote :

The version is python-openstacksdk==0.9.14, python-openstackclient==3.8.2

Revision history for this message
songminglong (songminglong) wrote :

actually, i have read the part of codes of update_subnetpool(), and subnetpool do not support "openstack subnet pool unset" command. subnetpool just support to enlarge prefies operation:

if new_prefixes is not constants.ATTR_NOT_SPECIFIED:
    orig_ip_set = netaddr.IPSet(orig_pool.prefixes)
    new_ip_set = netaddr.IPSet(new_prefixes)
    if not orig_ip_set.issubset(new_ip_set):
        msg = _("Existing prefixes must be "
                "a subset of the new prefixes")
        raise n_exc.IllegalSubnetPoolPrefixUpdate(msg=msg)
    new_ip_set.compact()
    updated['prefixes'] = [str(prefix.cidr)
                           for prefix in new_ip_set.iter_cidrs()]

orig_ip_set is original prefixes in database which you want to update
new_ip_set is prefixes you input from cli

the operation of updating subnetpool prefixes is just allow you to enlarge range of existing prefixes, for example:
orig_ip_set=['10.0.1.0/24','10.0.2.0/24']
new_ip_set is super set of orig_ip_set, like ['10.0.1.0/24','10.0.2.0/24','10.0.3.0'/24]
so if you want to enlarge subnetpool prefixes:
openstack subnet pool set subnetpool_id --pool-prefix 10.0.1.0/24 --pool-prefix 10.0.2.0/24 --pool-prefix 10.0.3.0/24

it's a little of absurd, haha

Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Confirmed on stable rocky release, the subnet pool update only allows to expand the existing prefixes:
https://github.com/openstack/neutron/blob/13.0.0/neutron/db/db_base_plugin_v2.py#L89

Note that set command automatically merges the included prefixes:
$ openstack subnet pool show testpool
[...]
| prefixes | 10.0.0.0/23, 20.0.0.0/24 |
$ openstack subnet pool set --pool-prefix 10.0.0.0/22 testpool
$ openstack subnet pool show testpool
[...]
| prefixes | 10.0.0.0/22, 20.0.0.0/24 |
$ openstack subnet pool unset --pool-prefix 10.0.0.0/23 testpool
Subnet pool does not contain prefix 10.0.0.0/23

No need to manually clean the inner prefixes.

The code was added in https://review.openstack.org/#/c/306253/ in a general round to add unset commands where missing, but for subnet pools, I would suggest to remove it, as the operation is not supported (and not needed as shown, expanding a subnet merges it in the newer larger one)

Changed in python-openstackclient:
status: New → Confirmed
Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

For reference, fix to get actual error is https://review.openstack.org/#/c/571101/ (Rocky and newer)

Revision history for this message
Bernard Cafarelli (bcafarel) wrote :

Comments moved to storyboard

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.