Changing the Unified Limits limit value to 0 does not work

Bug #2159619 reported by Kacper Sulimowicz
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
In Progress
Undecided
Udayendu Kar
python-openstackclient
In Progress
Undecided
Udayendu Kar

Bug Description

There is an issue when setting the Unified Limits resource_limit value to 0.

The problem is caused by the following condition:

if parsed_args.resource_limit:
    kwargs["resource_limit"] = parsed_args.resource_limit

Since 0 evaluates to False, the value is skipped and is not passed to update_limit(). The condition should check for None instead.

https://github.com/openstack/python-openstackclient/blob/master/openstackclient/identity/v3/limit.py

description: updated
Revision history for this message
Udayendu Kar (uskar88) wrote :

Thanks Kacper. I will test and give a patch.

Changed in python-openstackclient:
assignee: nobody → Udayendu Kar (uskar88)
Revision history for this message
Udayendu Kar (uskar88) wrote :
Download full text (3.8 KiB)

This is interesting. Its just not the limit.py in identity but in the keytone backend as well.

I am able to reproduce this issue:

(kolla-venv) root@uskar-dev-node:~# diff -u /root/kolla-venv/lib/python3.11/site-packages/openstackclient/identity/v3/limit.py /root/kolla-venv/lib/python3.11/site-packages/openstackclient/identity/v3/limit.py.orig
--- /root/kolla-venv/lib/python3.11/site-packages/openstackclient/identity/v3/limit.py 2026-07-28 21:35:14.042927672 -0700
+++ /root/kolla-venv/lib/python3.11/site-packages/openstackclient/identity/v3/limit.py.orig 2026-07-28 20:34:59.378907800 -0700
@@ -244,7 +244,7 @@
         kwargs = {}
         if parsed_args.description:
             kwargs["description"] = parsed_args.description
- if parsed_args.resource_limit is not None:
+ if parsed_args.resource_limit:
             kwargs["resource_limit"] = parsed_args.resource_limit
         limit = identity_client.update_limit(parsed_args.limit_id, **kwargs)

(kolla-venv) root@uskar-dev-node:~# docker exec -it keystone bash
(keystone)[root@uskar-dev-node /]# cp /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py.orig
(keystone)[root@uskar-dev-node /]# vim /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py
(keystone)[root@uskar-dev-node /]# diff -u /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py.orig
--- /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py 2026-07-28 21:28:15.194783229 -0700
+++ /var/lib/kolla/venv/lib/python3.11/site-packages/keystone/limit/backends/sql.py.orig 2026-07-28 21:27:00.182045808 -0700
@@ -283,7 +283,7 @@
     def update_limit(self, limit_id, limit):
         with sql.session_for_write() as session:
             ref = self._get_limit(session, limit_id)
- if limit.get('resource_limit') is not None:
+ if limit.get('resource_limit'):
                 ref.resource_limit = limit['resource_limit']
             if limit.get('description'):
                 ref.description = limit['description']
(keystone)[root@uskar-dev-node /]#
exit

(kolla-venv) root@uskar-dev-node:~# docker restart keystone
(kolla-venv) root@uskar-dev-node:~# openstack limit set --resource-limit 0 2f92e83b008d4adfb28b949bae7306a8
+----------------+----------------------------------+
| Field | Value |
+----------------+----------------------------------+
| description | None |
| id | 2f92e83b008d4adfb28b949bae7306a8 |
| project_id | 6455f7fd62634287832009f70e52a07e |
| region_id | None |
| resource_limit | 0 |
| resource_name | cores |
| service_id | 0fa9044d90e24ab584eb8f9b2b447c21 |
+----------------+----------------------------------+

(kolla-venv) root@uskar-dev-node:~# openstack limit show 2f92e83b008d4adfb28b949bae7306a8
+----------------+---------------------...

Read more...

Changed in python-openstackclient:
status: New → In Progress
Udayendu Kar (uskar88)
Changed in keystone:
assignee: nobody → Udayendu Kar (uskar88)
status: New → In Progress
Revision history for this message
Udayendu Kar (uskar88) wrote :

Hi Kacper,

Quick question(may be a stupid one):

> Why do you want to create a project but with 0 resource limit ?

Revision history for this message
Kacper Sulimowicz (ksulimowicz) wrote :

Hi Udayendu,

I’ve just tested updating the limits to zero with both changes, and everything seems to be working correctly now.

As for the reason we want to create a project with a limit of 0: we’d like to have the ability to prevent users within a specific project from creating any new resources. While this could technically be achieved by setting the registered limits to 0 and then removing the project-specific limit, that approach doesn’t align with our requirements. We need to be able to configure a project directly with a limit of 0.

Revision history for this message
Udayendu Kar (uskar88) wrote :

Okay, thanks for the update. I will give the patch in some time.

Revision history for this message
Udayendu Kar (uskar88) wrote :
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.