stackhpc / stackhpc/openstack-config

KeyError when assigning quotas

Open
#58 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jinja
Stars
5
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When attempting to assign quotas to a project if the quotas changes it will cause a KeyError: 'project_id'.

TASK [stackhpc.openstack.os_projects : Ensure quotas are set] ****************************************************************************************************************************************************************************************************************************************
Friday 22 August 2025  12:49:34 +0000 (0:00:01.327)       0:00:22.558 *********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'project_id'
failed: [localhost] (item=demo) => changed=false
  ansible_loop_var: item
  item:
    description: OpenStack demo project
    keypairs:
    - name: id_ed25519
      public_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICKx4TMa8vtpOe3qHeMX4Z7JZyucBcqlfv8iFY6dZkzB
    name: demo
    project_domain: default
    quotas:
      backup_gigabytes: -1
      backups: -1
      cores: -1
      floatingip: -1
      gigabytes: -1
      injected_file_size: -1
      injected_files: -1
      instances: -1
      key_pairs: -1
      per_volume_gigabytes: -1
      ram: -1
      security_group: -1
      security_group_rule: -1
      snapshots: -1
      volumes: -1
    user_domain: default
    users:
    - description: StackHPC Demo user
      email: demo@stackhpc.com
      name: demo
      password: *****
      roles:
      - member
      - reader
  module_stderr: |-
    Traceback (most recent call last):
      File "/home/stack/.ansible/tmp/ansible-tmp-1755866974.7532272-708515-178033976670647/AnsiballZ_quota.py", line 107, in <module>
        _ansiballz_main()
      File "/home/stack/.ansible/tmp/ansible-tmp-1755866974.7532272-708515-178033976670647/AnsiballZ_quota.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/stack/.ansible/tmp/ansible-tmp-1755866974.7532272-708515-178033976670647/AnsiballZ_quota.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.openstack.cloud.plugins.modules.quota', init_globals=dict(_module_fqn='ansible_collections.openstack.cloud.plugins.modules.quota', _modlib_path=modlib_path),
      File "/usr/lib64/python3.9/runpy.py", line 225, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_openstack.cloud.quota_payload_85q5nn83/ansible_openstack.cloud.quota_payload.zip/ansible_collections/openstack/cloud/plugins/modules/quota.py", line 560, in <module>
      File "/tmp/ansible_openstack.cloud.quota_payload_85q5nn83/ansible_openstack.cloud.quota_payload.zip/ansible_collections/openstack/cloud/plugins/modules/quota.py", line 556, in main
      File "/tmp/ansible_openstack.cloud.quota_payload_85q5nn83/ansible_openstack.cloud.quota_payload.zip/ansible_collections/openstack/cloud/plugins/module_utils/openstack.py", line 417, in __call__
      File "/tmp/ansible_openstack.cloud.quota_payload_85q5nn83/ansible_openstack.cloud.quota_payload.zip/ansible_collections/openstack/cloud/plugins/modules/quota.py", line 536, in run
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/openstack/block_storage/v3/_proxy.py", line 1741, in update_quota_set
        return res.commit(self, **query)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/openstack/resource.py", line 1793, in commit
        request = self._prepare_request(
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/openstack/resource.py", line 1251, in _prepare_request
        uri = base_path % self._uri.attributes
    KeyError: 'project_id'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the quota module at ansible_collections/openstack/cloud/plugins/modules/quota.py around run line 536, then inspect the openstack block_storage v3 update_quota_set call shown in the traceback. Reproduce the Ensure quotas are set task with changed quotas. Done means quota assignment completes without the KeyError: 'project_id' failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible, python
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.