Skip to content

feature: Added management command to find orphaned databases

Description

This adds a find_orphan_dbs management command that searches for databases that exist in a datastore but are not registered in the OCIM database.

I suspect this may happen because of some failure while deprovisioning databases (by either archiving or deleting the respective instances).

Testing instructions

Orphaned MySQL

  1. Create a MySQL database (create database DB_NAME)
  2. ./manage.py find_orphan_dbs mysql --host MYSQL_HOST -u MYSQL_USER -p (will be prompted for password)
  3. Verify that DB_NAME is identified as orphan in stderr
  4. Verify that correct SQL for dropping the database is generated to stdout

Orphaned MongoDB

  1. Create a MongoDB database (use DB_NAME; db.insert({}))
  2. ./manage.py find_orphan_dbs mongo --host MONGO_HOST -u MONGO_HOST -p (will be prompted for password)
  3. Verify that DB_NAME is identified as orphan in stderr
  4. Verify that correct mongo-shell script for dropping the database is generated to stdout

Merge request reports