To insert data into DB 'glance-manage db load_metadefs' uses IDs for namespaces which are generated by built-in function in Python - enumerate:
for namespace_id, json_schema_file in enumerate(json_schema_files, start=1):
For empty database it works fine, but this causes problems when there are already metadata namespaces in database. The problem is that when there are already metadata definitions in DB then every invoke of glance-manage db load_metadefs leads to IntegrityErrors because of duplicated IDs.
There are two approaches to fix this:
1. Ask for a namespace just after inserting it. Unfortunately in current implementation we need to do one more query.
2. When this go live - https://review.openstack.org/#/c/120414/ - then we won't need to do another query, because ID is available just after inserting a namespace to DB (namespace.save(session=session)).
Fix proposed to branch: master /review. openstack. org/120432
Review: https:/