Page MenuHomePhabricator

[Nix] Reconcile missing db config in more granular fashion
ClosedPublic

Authored by jon on Dec 1 2022, 9:29 AM.
Tags
None
Referenced Files
F3516139: D5791.id19443.diff
Sun, Dec 22, 12:26 PM
F3515094: D5791.diff
Sun, Dec 22, 7:27 AM
Unknown Object (File)
Sat, Dec 7, 1:18 PM
Unknown Object (File)
Sat, Dec 7, 1:17 PM
Unknown Object (File)
Sat, Dec 7, 1:17 PM
Unknown Object (File)
Sat, Dec 7, 1:17 PM
Unknown Object (File)
Sat, Dec 7, 1:04 PM
Unknown Object (File)
Nov 22 2024, 6:15 AM
Subscribers

Details

Reviewers
atul
varun
ashoat
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rCOMMfe25f7b03123: [Nix] Reconcile missing db config in more granular fashion
Summary

The logic previously only worked on fresh installs of MariadB.
If the database configuration was lost, or a user was deleted, there was
nothing to reconcile it back to a healthy state.

The logic now checks each individual step to ensure that every assumption
has been placed correctly.

https://linear.app/comm/issue/ENG-2046

Test Plan

This test plan assumes that you're using the mariadb daemon supplied as part of nix develop,
if you have mariadb installed through homebrew, then beware
that the nix supplied socket will be available at
$HOME/.local/share/MariaDB/mysql.sock as opposed to /tmp/mysql.sock.

In theory, this should work on linux and macOS, however, only tested and expected to be ran
on macOS.

# stop previous MariaDB
pkill mariadb

# Break some chain of assumptions, like removing the db config
rm -rf keyserver/secrets/db_config.json

nix develop # should emit that it's starting MariaDB and writing a config

cd keyserver
yarn dev # shouldn't crash when starting DB configuration

Diff Detail

Repository
rCOMM Comm
Branch
jonringer/db_config (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Owners added a reviewer: Restricted Owners Package.Dec 1 2022, 9:29 AM
Harbormaster returned this revision to the author for changes because remote builds failed.Dec 1 2022, 9:32 AM
Harbormaster failed remote builds in B13919: Diff 19074!
varun requested changes to this revision.Dec 9 2022, 8:10 AM

Do we have to assume that devs are using the nix supplied mariadb?

nix/mariadb-up-mac.nix
78
This revision now requires changes to proceed.Dec 9 2022, 8:10 AM

Do we have to assume that devs are using the nix supplied mariadb?

The commands are submitted through the unix socket and uses the host user as the database user, it doesn't have to be the nix provided version, but the nix provided version ensures the related ENV var is set for the unix socket, and the mariadb instance is setup to use the unix socket.

In short, yes, we have to assume they use the nix one, unless they setup mariadb in a particular way.

ashoat requested changes to this revision.Dec 13 2022, 4:08 PM

Can you update your Test Plan to mention testing this on macOS?

This test plan assumes that you're using the nix supplied mariadb
daemon, if you have mariadb installed through homebrew, then beware
that the nix supplied socket will be available at
$HOME/.local/share/MariaDB/mysql.sock as opposed to /tmp/mysql.sock.

Will landing this diff cause any issues for users who have MariaDB installed through Homebrew?

This revision now requires changes to proceed.Dec 13 2022, 4:08 PM

Will landing this diff cause any issues for users who have MariaDB installed through Homebrew?

Shouldn't, the start_comm_daemon.sh will find the other mariadb process and will exit 1, which will then cause this script to exit early.

jon edited the test plan for this revision. (Show Details)

Can you update your Test Plan to mention testing this on macOS?

Updated to mention that macOS is expected platform

This revision is now accepted and ready to land.Dec 16 2022, 9:44 AM