Page MenuHomePhabricator

Deleting ENC projects is broken
Closed, ResolvedPublic

Description

Deleting a Puppet ENC project fails because it tries to resolve the project name for the project ID:

2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc [None req-c331e2dd-7e5a-4ac8-a10c-004eda907d3a novaadmin admin - - default default] Exception on /v1/admin/project/checkuser-beta-wiki [DELETE]: KeyError: 'checkuser-beta-wiki'
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc Traceback (most recent call last):
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/lib/python3/dist-packages/flask/app.py", line 1511, in wsgi_app
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     response = self.full_dispatch_request()
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/lib/python3/dist-packages/flask/app.py", line 919, in full_dispatch_request
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     rv = self.handle_user_exception(e)
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/lib/python3/dist-packages/flask/app.py", line 917, in full_dispatch_request
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     rv = self.dispatch_request()
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/lib/python3/dist-packages/flask/app.py", line 902, in dispatch_request
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/local/lib/python3.13/dist-packages/puppet-enc.py", line 786, in delete_project
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     project_name = project_name_for_id(project)
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc   File "/usr/local/lib/python3.13/dist-packages/puppet-enc.py", line 161, in project_name_for_id
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc     return convertDict[project_id]
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc            ~~~~~~~~~~~^^^^^^^^^^^^
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc KeyError: 'checkuser-beta-wiki'
2026-02-05 12:25:34.708 189710 ERROR uwsgi_file__usr_local_lib_python3_13_dist-packages_puppet-enc

Probably we need to update ENC to store the project ID in a new database table so that mapping is available after a project has been deleted from openstack.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1239965 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: encapi: Store project names in database

https://gerrit.wikimedia.org/r/1239965

taavi triaged this task as Medium priority.Feb 18 2026, 11:55 AM

Change #1239965 merged by Majavah:

[operations/puppet@production] openstack: encapi: Store project names in database

https://gerrit.wikimedia.org/r/1239965

Change #1242291 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] opesntack: encapi: Fix column name

https://gerrit.wikimedia.org/r/1242291

Change #1242291 merged by Majavah:

[operations/puppet@production] opesntack: encapi: Fix column name

https://gerrit.wikimedia.org/r/1242291

After running the backfill script, we're left with the following stale items in the database:

MariaDB [labspuppet]> select * from prefix where prefix_project_id is null;
+-------+-------------------+---------------------------+----------------------------------------------------------+
| id    | prefix_project_id | project                   | prefix                                                   |
+-------+-------------------+---------------------------+----------------------------------------------------------+
|  2086 |              NULL | monitoring                |                                                          |
|  2159 |              NULL | getstarted                |                                                          |
|  8734 |              NULL | clouddb-services          |                                                          |
|  9796 |              NULL | sso                       |                                                          |
| 10970 |              NULL | mwv-apt                   |                                                          |
| 11113 |              NULL | wikilabels                |                                                          |
| 14418 |              NULL | maps-experiments          |                                                          |
| 17062 |              NULL | terraform                 |                                                          |
| 17557 |              NULL | checkuser-beta-wiki       |                                                          |
| 17800 |              NULL | dump-references-processor |                                                          |
| 14498 |              NULL | openocr                   | test                                                     |
| 17073 |              NULL | wikilabels                | wikilabels-03.wikilabels.eqiad1.wikimedia.cloud          |
| 17183 |              NULL | wikilabels                | wikilabels-database-02.wikilabels.eqiad1.wikimedia.cloud |
| 11683 |              NULL | wikilabels                | wikilabels-staging-02.wikilabels.eqiad1.wikimedia.cloud  |
+-------+-------------------+---------------------------+----------------------------------------------------------+
14 rows in set (0.001 sec)

Change #1282878 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: encapi: Always use explicit SQL JOIN syntax

https://gerrit.wikimedia.org/r/1282878

Change #1282879 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: wmcs-enc-cli: Add subcommand to manually delete projects

https://gerrit.wikimedia.org/r/1282879

Change #1282878 merged by Majavah:

[operations/puppet@production] openstack: encapi: Always use explicit SQL JOIN syntax

https://gerrit.wikimedia.org/r/1282878

Change #1282879 merged by Majavah:

[operations/puppet@production] openstack: wmcs-enc-cli: Add subcommand to manually delete projects

https://gerrit.wikimedia.org/r/1282879

Mentioned in SAL (#wikimedia-cloud) [2026-05-05T10:20:31Z] <taavi> taavi@cloudcontrol1007 ~ $ sudo wmcs-enc-cli --openstack-project admin delete_project wikilabels # T416588

Change #1282943 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: puppet-enc: Exclusively read projects table

https://gerrit.wikimedia.org/r/1282943

Change #1282944 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: puppet-enc: Stop writing and drop old project column

https://gerrit.wikimedia.org/r/1282944

Change #1282943 merged by Majavah:

[operations/puppet@production] openstack: puppet-enc: Exclusively read projects table

https://gerrit.wikimedia.org/r/1282943

Change #1282944 merged by Majavah:

[operations/puppet@production] openstack: puppet-enc: Stop writing and drop old project column

https://gerrit.wikimedia.org/r/1282944

Change #1286315 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/puppet@production] openstack: encapi: Make new project column NOT NULL

https://gerrit.wikimedia.org/r/1286315

Change #1286315 merged by Majavah:

[operations/puppet@production] openstack: encapi: Make new project column NOT NULL

https://gerrit.wikimedia.org/r/1286315

This is fixed for future projects. T404425 needs to happen to fix the existing cases in the exported Git data.