Skip to content

Commit

Permalink
feat: ensure that projects have consistent ids (#8)
Browse files Browse the repository at this point in the history
This change adjusts how shadow projects are stored in the database.
When a project is created, it is looked up using the name and when
not found keystone would normally assign it a random UUID. This
ensures that all projects have a consistent hash when being assigned
which will ensure that project IDs remain consistent between regions.

Signed-off-by: Kevin Carter <[email protected]>
  • Loading branch information
cloudnull authored Feb 1, 2025
1 parent 319811a commit 3207641
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions keystone_rxt/rackspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ def _handle_projects_from_mapping(
},
)
project_ref = {
"id": mapped.uuid.uuid4().hex,
"id": hashlib.sha224(
shadow_project["name"].encode("utf-8")
).hexdigest(),
"name": shadow_project["name"],
"domain_id": shadow_project["domain"]["id"],
}
Expand Down Expand Up @@ -328,8 +330,8 @@ def _handle_projects_from_mapping(

metadata = shadow_project.get("metadata", list())
for item in metadata:
if item['key'] not in project:
project[item['key']] = item['value']
if item["key"] not in project:
project[item["key"]] = item["value"]
update_needed = True

if update_needed:
Expand Down

0 comments on commit 3207641

Please sign in to comment.