Page MenuHomePhabricator

Migration to MariaDB operator: Shared environment DB
Closed, ResolvedPublic3 Estimated Story Points

Description

This task tracks the migration for the shared env DB.

This comment T403763#11277682 contains extra details and a link to a PoC

Details

Other Assignee
jeena
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
migrate shared envDB to MariaDB operator: Step 3repos/test-platform/catalyst/catalyst-api!173jnucheT408115-3main
migrate shared envDB to MariaDB operator: Step 2repos/test-platform/catalyst/catalyst-api!172jnucheT408115-2main
migrate shared envDB to MariaDB operator: Step 1repos/test-platform/catalyst/catalyst-api!171jnucheT408115main
Customize query in GitLab

Event Timeline

jnuche updated Other Assignee, added: jeena.
jnuche set the point value for this task to 3.

As usual, we will announce a maintenance window for the migration.

Migration plan
  1. Scale down Patchdemo: kubectl -n patchdemo scale deployment patchdemo --replicas=0
  2. Merge https://gitlab.wikimedia.org/repos/test-platform/catalyst/catalyst-api/-/merge_requests/171 (Deploy operator DB)
  3. Perform Manual migration + checks steps
  4. Copy SHARED_DB_USER_OP CI/CD var into SHARED_DB_USER
  5. Delete SHARED_DB_USER_OP
  6. Merge https://gitlab.wikimedia.org/repos/test-platform/catalyst/catalyst-api/-/merge_requests/172 (Remove bitnami DB)
  7. Scale up Patchdemo: kubectl -n patchdemo scale deployment patchdemo --replicas=1
  8. Verify Catalyst API is healthy
  9. Verify Patchdemo environments that use Catalyst are healthy
  10. Merge https://gitlab.wikimedia.org/repos/test-platform/catalyst/catalyst-api/-/merge_requests/173
  11. Done
Manual migration + checks

Once the operator DB has been deployed and while the bitnami DB is still up and running, we do the following:

PASS=<rootPass>

  1. Dump DBs, users and grants from bitnami:
    • DBs:
      1. wikidbs=$(kubectl -n cat-env exec -it envdb-0 -c mariadb -- bash -c "mariadb -u root -p$PASS -e \"SHOW DATABASES LIKE 'wiki_%';\" -s --skip-column-names" | tr -d '\r' | tr '\n' ' ')
      2. kubectl -n cat-env exec envdb-0 -c mariadb -- mariadb-dump -u root -p"$PASS" --single-transaction --databases $wikidbs >~/dumpEnvDB-DBs.sql
      3. cp ~/dumpEnvDB-DBs.sql ~/dumpEnvDB-DBs.sql.BK
    • Users:
      1. kubectl -n cat-env exec envdb-0 -c mariadb -- bash -c "mariadb -u root -p$PASS -NBe \"SELECT CONCAT('SHOW CREATE USER \'', user, '\'@\'', host, '\';') FROM mysql.user WHERE user LIKE 'wiki_%'\" | mariadb -u root -p$PASS -N" | while read stmt; do echo "$stmt;"; done >~/dumpEnvDB-Users.sql
      2. cp ~/dumpEnvDB-Users.sql ~/dumpEnvDB-Users.sql.BK
    • Grants:
      1. kubectl -n cat-env exec envdb-0 -c mariadb -- bash -c "mariadb -u root -p$PASS -NBe \"SELECT CONCAT('SHOW GRANTS FOR \'', user, '\'@\'', host, '\';') FROM mysql.user WHERE user LIKE 'wiki_%'\" | mariadb -u root -p$PASS -N" | while read stmt; do echo "$stmt;"; done >~/dumpEnvDB-Grants.sql
      2. cp ~/dumpEnvDB-Grants.sql ~/dumpEnvDB-Grants.sql.BK
  2. Import into operator
    • kubectl -n cat-env exec -i envdb-mariadbop-0 -- mariadb -u root -p"$PASS" < ~/dumpEnvDB-DBs.sql
    • kubectl -n cat-env exec -i envdb-mariadbop-0 -- mariadb -u root -p"$PASS" < ~/dumpEnvDB-Users.sql
    • kubectl -n cat-env exec -i envdb-mariadbop-0 -- mariadb -u root -p"$PASS" < ~/dumpEnvDB-Grants.sql
  3. Perform checks: The DBs, users and grants should show up in the mariadb operator
jnuche moved this task from In progress to Done on the Catalyst (Luka Ijo Pimeja Jan) board.