When cluster.databases is configured, read the master connection from it
Summary: Ref T4571. Ref T10759. Ref T10758. This isn't complete, but gets most of the job done: - When `cluster.databases` is set up, most things ignore `mysql.host` now. - You can `bin/storage upgrade` and stuff works. - You can browse around in the web UI and stuff works. There's still a lot of weird tricky stuff to navigate, and this has real no advantages over configuring a single server yet (no automatic failover, etc). Test Plan: - Configured `cluster.databases` to point at my `t1.micro` hosts in EC2 (master + replica). - Ran `bin/storage upgrade`, got a new install setup on them properly. - Survived setup warnings, browsed around. - Switched back to local config, ran `bin/storage upgrade`, browsed around, went through setup checks. - Intentionally broke config (bad hosts, no masters) and things seemed to react reasonably well. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4571, T10758, T10759 Differential Revision: https://secure.phabricator.com/D15668
This commit is contained in:
@@ -19,13 +19,6 @@ EOHELP
|
||||
);
|
||||
$args->parseStandardArguments();
|
||||
|
||||
$conf = PhabricatorEnv::newObjectFromConfig(
|
||||
'mysql.configuration-provider',
|
||||
array($dao = null, 'w'));
|
||||
|
||||
$default_user = $conf->getUser();
|
||||
$default_host = $conf->getHost();
|
||||
$default_port = $conf->getPort();
|
||||
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
|
||||
|
||||
try {
|
||||
@@ -41,10 +34,8 @@ try {
|
||||
'name' => 'user',
|
||||
'short' => 'u',
|
||||
'param' => 'username',
|
||||
'default' => $default_user,
|
||||
'help' => pht(
|
||||
"Connect with __username__ instead of the configured default ('%s').",
|
||||
$default_user),
|
||||
'Connect with __username__ instead of the configured default.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'password',
|
||||
@@ -84,11 +75,21 @@ try {
|
||||
// First, test that the Phabricator configuration is set up correctly. After
|
||||
// we know this works we'll test any administrative credentials specifically.
|
||||
|
||||
$ref = PhabricatorDatabaseRef::getMasterDatabaseRef();
|
||||
if (!$ref) {
|
||||
throw new Exception(
|
||||
pht('No database master is configured.'));
|
||||
}
|
||||
|
||||
$default_user = $ref->getUser();
|
||||
$default_host = $ref->getHost();
|
||||
$default_port = $ref->getPort();
|
||||
|
||||
$test_api = id(new PhabricatorStorageManagementAPI())
|
||||
->setUser($default_user)
|
||||
->setHost($default_host)
|
||||
->setPort($default_port)
|
||||
->setPassword($conf->getPassword())
|
||||
->setPassword($ref->getPass())
|
||||
->setNamespace($args->getArg('namespace'));
|
||||
|
||||
try {
|
||||
@@ -120,15 +121,20 @@ try {
|
||||
|
||||
if ($args->getArg('password') === null) {
|
||||
// This is already a PhutilOpaqueEnvelope.
|
||||
$password = $conf->getPassword();
|
||||
$password = $ref->getPass();
|
||||
} else {
|
||||
// Put this in a PhutilOpaqueEnvelope.
|
||||
$password = new PhutilOpaqueEnvelope($args->getArg('password'));
|
||||
PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));
|
||||
}
|
||||
|
||||
$selected_user = $args->getArg('user');
|
||||
if ($selected_user === null) {
|
||||
$selected_user = $default_user;
|
||||
}
|
||||
|
||||
$api = id(new PhabricatorStorageManagementAPI())
|
||||
->setUser($args->getArg('user'))
|
||||
->setUser($selected_user)
|
||||
->setHost($default_host)
|
||||
->setPort($default_port)
|
||||
->setPassword($password)
|
||||
|
||||
Reference in New Issue
Block a user