SUSE-Enceladus / public-cloud-info-service

Find IPs of service endpoints, and information about published images.
Apache License 2.0
5 stars 8 forks source link

IP Addresses must be unique per region #112

Closed rtamalin closed 2 years ago

rtamalin commented 2 years ago

Previously we defined new partial unique indices to ensure that IP addresses were uniquely specified in the Amazon, Google and Microsoft servers tables, though we allowed for them being unique per region in the case of Microsoft.

However, we sometimes temporarily specify the update servers from an existing region as the update servers for a newly created region until the update infrastructure for the new region is in place.

To address this operational requirement we need to include the region field in the partial unique indices for all servers tables, not just the Microsoft servers table.

Update the adhoc_db duplicate_servers test to reflect the fact that all servers tables, rather than just the Microsoft servers table, should have the second region with the repeated IP address entry added to them.

Cleanup some comments in the report_duplicates() helper method and extend it to take as argument the index of the field to be counted, defaulting to the first field, rather than being hardcoded to use the first field.

Closes: #100 (again)

rtamalin commented 2 years ago

Testing against a DB seeded with the current pint-data XML (which includes the temporary duplicated server for a recently created Amazon region) content this now works, rather than failing due to detecting a duplicate:

% ../bin/schema_upgrade.sh --host pdm-dev --user snotty --password MasterSlobs --database postgres upgrade
INFO:__main__:Creating version control
INFO:__main__:Upgrading schema
INFO:alembic.runtime.migration:Context impl PostgresqlImpl.
INFO:alembic.runtime.migration:Will assume transactional DDL.
INFO:alembic.runtime.migration:Running upgrade 8c5fc3cd9b18 -> 14ae3b1b5e81, image dates validation
INFO:alembic.runtime.migration:Running upgrade 14ae3b1b5e81 -> e937749e3f8b, servers partial unique keys
Pint database schema migration successfully completed.
smarlowucf commented 2 years ago

:+1: