Skip to content

Defensive checks when setting up CloudSQL instance

Sri Rang requested to merge incubation-cloud-seed-worker-improvements into master

What does this MR do and why?

This tiny MR is the result of this discussion: !92350 (comment 1041486325)

@stanhu suggested and I agreed to make the worker more defensive.

Worker calls SetupCloudsqlInstanceService thus most of the changes are in this file and the Google API client file.

Scenario: User creates CloudSQL instance. Post instance creation, worker checks status of instance and if runnable it sets up database and user for that instance.

Problem: If instance is runnable, database creation succeeds and user creation fails, the worker would retry and try to create the database and user again. The second creation of the database with the same name would error, and worker raises the error and the user never gets created.

Fix: Check existing list of users and database. Proceed with user and database creation only if they don't exist.

Screenshots or screen recordings

None. Pure backend change.

How to set up and validate locally

Pure code review, no functionality to test in app. The controllers / endpoints to test via app are not merged. Please see the explanation above.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sri Rang

Merge request reports