One of the issues here is caused by a try/except when collecting version information for each repository [0]. The logic within the try/except is attempting to assign the version of each repository (expand, migrate, and contract) to a variable. The issue is that with a new installation, not all of those repositories might exist yet, depending on what commands you've issued.
For example, if you run `keystone-manage db_sync --expand` on a fresh database, the legacy migrations will be run and the expand migrations will be run. The data_migration_repo and contract repositories will not exist yet, since those repositories haven't been invoked yet. This causes the `--check` to fail with inaccurate information after the first `--expand` is run because the migration.exception.DbMigrationError is caught and we assume it to mean the legacy repository doesn't exist, which isn't true.
One possible solution is to break that try/except into multiple blocks for each repository and handle them separately.
One of the issues here is caused by a try/except when collecting version information for each repository [0]. The logic within the try/except is attempting to assign the version of each repository (expand, migrate, and contract) to a variable. The issue is that with a new installation, not all of those repositories might exist yet, depending on what commands you've issued.
For example, if you run `keystone-manage db_sync --expand` on a fresh database, the legacy migrations will be run and the expand migrations will be run. The data_migration_repo and contract repositories will not exist yet, since those repositories haven't been invoked yet. This causes the `--check` to fail with inaccurate information after the first `--expand` is run because the migration. exception. DbMigrationErro r is caught and we assume it to mean the legacy repository doesn't exist, which isn't true.
One possible solution is to break that try/except into multiple blocks for each repository and handle them separately.
[0] https:/ /github. com/openstack/ keystone/ blob/45265c0ddf fa399fcb10bed6e ac98069decdf910 /keystone/ cmd/cli. py#L460- L469