mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Remove daemon envHash and envInfo
Summary: Ref T7053. Remove the `envHash` and `envInfo` fields, which are no longer used now that the daemons restart automagically. Depends on D14458. Test Plan: Saw no more setup issues. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: tycho.tatitscheff, epriestley Maniphest Tasks: T7053 Differential Revision: https://secure.phabricator.com/D14446
This commit is contained in:
parent
a07a8aca24
commit
321c61a853
9 changed files with 11 additions and 233 deletions
5
resources/sql/autopatches/20151110.daemonenvhash.sql
Normal file
5
resources/sql/autopatches/20151110.daemonenvhash.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE {$NAMESPACE}_daemon.daemon_log
|
||||
DROP COLUMN envHash;
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_daemon.daemon_log
|
||||
DROP COLUMN envInfo;
|
|
@ -47,7 +47,6 @@ final class PhabricatorDaemonsSetupCheck extends PhabricatorSetupCheck {
|
|||
}
|
||||
|
||||
$phd_user = PhabricatorEnv::getEnvConfig('phd.user');
|
||||
$environment_hash = PhabricatorEnv::calculateEnvironmentHash();
|
||||
$all_daemons = id(new PhabricatorDaemonLogQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
||||
|
@ -91,107 +90,6 @@ final class PhabricatorDaemonsSetupCheck extends PhabricatorSetupCheck {
|
|||
->addCommand('phabricator/ $ ./bin/phd restart');
|
||||
}
|
||||
}
|
||||
|
||||
if ($daemon->getEnvHash() != $environment_hash) {
|
||||
$doc_href = PhabricatorEnv::getDocLink(
|
||||
'Managing Daemons with phd');
|
||||
|
||||
$summary = pht(
|
||||
'At least one daemon is currently running with different '.
|
||||
'configuration than the Phabricator web application.');
|
||||
|
||||
$list_section = null;
|
||||
$env_info = $daemon->getEnvInfo();
|
||||
if ($env_info) {
|
||||
$issues = PhabricatorEnv::compareEnvironmentInfo(
|
||||
PhabricatorEnv::calculateEnvironmentInfo(),
|
||||
$env_info);
|
||||
|
||||
if ($issues) {
|
||||
foreach ($issues as $key => $issue) {
|
||||
$issues[$key] = phutil_tag('li', array(), $issue);
|
||||
}
|
||||
|
||||
$list_section = array(
|
||||
pht(
|
||||
'The configurations differ in the following %s way(s):',
|
||||
phutil_count($issues)),
|
||||
phutil_tag(
|
||||
'ul',
|
||||
array(),
|
||||
$issues),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$message = pht(
|
||||
'At least one daemon is currently running with a different '.
|
||||
'configuration (config checksum %s) than the web application '.
|
||||
'(config checksum %s).'.
|
||||
"\n\n%s".
|
||||
'This usually means that you have just made a configuration change '.
|
||||
'from the web UI, but have not yet restarted the daemons. You '.
|
||||
'need to restart the daemons after making configuration changes '.
|
||||
'so they will pick up the new values: until you do, they will '.
|
||||
'continue operating with the old settings.'.
|
||||
"\n\n".
|
||||
'(If you plan to make more changes, you can restart the daemons '.
|
||||
'once after you finish making all of your changes.)'.
|
||||
"\n\n".
|
||||
'Use %s to restart daemons. You can find a list of running daemons '.
|
||||
'in the %s, which will also help you identify which daemon (or '.
|
||||
'daemons) have divergent configuration. For more information about '.
|
||||
'managing the daemons, see %s in the documentation.'.
|
||||
"\n\n".
|
||||
'This can also happen if you use the %s environmental variable to '.
|
||||
'choose a configuration file, but the daemons run with a different '.
|
||||
'value than the web application. If restarting the daemons does '.
|
||||
'not resolve this issue and you use %s to select configuration, '.
|
||||
'check that it is set consistently.'.
|
||||
"\n\n".
|
||||
'A third possible cause is that you run several machines, and '.
|
||||
'the %s configuration file differs between them. This file is '.
|
||||
'updated when you edit configuration from the CLI with %s. If '.
|
||||
'restarting the daemons does not resolve this issue and you '.
|
||||
'run multiple machines, check that all machines have identical '.
|
||||
'%s configuration files.'.
|
||||
"\n\n".
|
||||
'This issue is not severe, but usually indicates that something '.
|
||||
'is not configured the way you expect, and may cause the daemons '.
|
||||
'to exhibit different behavior than the web application does.',
|
||||
|
||||
phutil_tag('tt', array(), substr($daemon->getEnvHash(), 0, 12)),
|
||||
phutil_tag('tt', array(), substr($environment_hash, 0, 12)),
|
||||
$list_section,
|
||||
phutil_tag('tt', array(), 'bin/phd restart'),
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/daemon/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
pht('Daemon Console')),
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $doc_href,
|
||||
'target' => '_blank',
|
||||
),
|
||||
pht('Managing Daemons with phd')),
|
||||
phutil_tag('tt', array(), 'PHABRICATOR_ENV'),
|
||||
phutil_tag('tt', array(), 'PHABRICATOR_ENV'),
|
||||
phutil_tag('tt', array(), 'phabricator/conf/local/local.json'),
|
||||
phutil_tag('tt', array(), 'bin/config'),
|
||||
phutil_tag('tt', array(), 'phabricator/conf/local/local.json'));
|
||||
|
||||
$this->newIssue('daemons.need-restarting')
|
||||
->setName(pht('Daemons and Web Have Different Config'))
|
||||
->setSummary($summary)
|
||||
->setMessage($message)
|
||||
->addCommand('phabricator/ $ ./bin/phd restart');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,6 +292,10 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
|
|||
'gcdaemon.ttl.task-archive' => $gc_reason,
|
||||
'gcdaemon.ttl.general-cache' => $gc_reason,
|
||||
'gcdaemon.ttl.conduit-logs' => $gc_reason,
|
||||
|
||||
'phd.variant-config' => pht(
|
||||
'This configuration is no longer relevant because daemons '.
|
||||
'restart automatically on configuration changes.'),
|
||||
);
|
||||
|
||||
return $ancient_config;
|
||||
|
|
|
@ -73,13 +73,6 @@ final class PhabricatorPHDConfigOptions
|
|||
"trace mode. See also '%s'.",
|
||||
'phd debug',
|
||||
'phd.verbose')),
|
||||
$this->newOption('phd.variant-config', 'list<string>', array())
|
||||
->setDescription(
|
||||
pht(
|
||||
'Specify config keys that can safely vary between the web tier '.
|
||||
'and the daemons. Primarily, this is a way to suppress the '.
|
||||
'"Daemons and Web Have Different Config" setup issue on a per '.
|
||||
'config key basis.')),
|
||||
$this->newOption('phd.garbage-collection', 'wild', array())
|
||||
->setLocked(true)
|
||||
->setLockedMessage(
|
||||
|
|
|
@ -58,14 +58,6 @@ final class PhabricatorDaemonLogViewController
|
|||
}
|
||||
|
||||
$header->addTag($tag);
|
||||
$env_hash = PhabricatorEnv::calculateEnvironmentHash();
|
||||
if ($log->getEnvHash() != $env_hash) {
|
||||
$tag = id(new PHUITagView())
|
||||
->setType(PHUITagView::TYPE_STATE)
|
||||
->setBackgroundColor(PHUITagView::COLOR_YELLOW)
|
||||
->setName(pht('Stale Config'));
|
||||
$header->addTag($tag);
|
||||
}
|
||||
|
||||
$properties = $this->buildPropertyListView($log);
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ final class PhabricatorDaemonEventListener extends PhabricatorEventListener {
|
|||
->setHost(php_uname('n'))
|
||||
->setPID(getmypid())
|
||||
->setRunningAsUser($current_user['name'])
|
||||
->setEnvHash(PhabricatorEnv::calculateEnvironmentHash())
|
||||
->setEnvInfo(PhabricatorEnv::calculateEnvironmentInfo())
|
||||
->setStatus(PhabricatorDaemonLog::STATUS_RUNNING)
|
||||
->setArgv($event->getValue('argv'))
|
||||
->setExplicitArgv($event->getValue('explicitArgv'))
|
||||
|
|
|
@ -17,8 +17,6 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
|
|||
protected $runningAsUser;
|
||||
protected $argv;
|
||||
protected $explicitArgv = array();
|
||||
protected $envHash;
|
||||
protected $envInfo;
|
||||
protected $status;
|
||||
|
||||
protected function getConfiguration() {
|
||||
|
@ -26,14 +24,12 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
|
|||
self::CONFIG_SERIALIZATION => array(
|
||||
'argv' => self::SERIALIZATION_JSON,
|
||||
'explicitArgv' => self::SERIALIZATION_JSON,
|
||||
'envInfo' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'daemon' => 'text255',
|
||||
'host' => 'text255',
|
||||
'pid' => 'uint32',
|
||||
'runningAsUser' => 'text255?',
|
||||
'envHash' => 'bytes40',
|
||||
'status' => 'text8',
|
||||
'daemonID' => 'text64',
|
||||
),
|
||||
|
|
|
@ -17,7 +17,6 @@ final class PhabricatorDaemonLogListView extends AphrontView {
|
|||
throw new PhutilInvalidStateException('setUser');
|
||||
}
|
||||
|
||||
$env_hash = PhabricatorEnv::calculateEnvironmentHash();
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setFlush(true);
|
||||
foreach ($this->daemonLogs as $log) {
|
||||
|
@ -33,15 +32,8 @@ final class PhabricatorDaemonLogListView extends AphrontView {
|
|||
$status = $log->getStatus();
|
||||
switch ($status) {
|
||||
case PhabricatorDaemonLog::STATUS_RUNNING:
|
||||
if ($env_hash != $log->getEnvHash()) {
|
||||
$item->setStatusIcon('fa-warning yellow');
|
||||
$item->addAttribute(pht(
|
||||
'This daemon is running with an out of date configuration and '.
|
||||
'should be restarted.'));
|
||||
} else {
|
||||
$item->setStatusIcon('fa-rocket green');
|
||||
$item->addAttribute(pht('This daemon is running.'));
|
||||
}
|
||||
$item->setStatusIcon('fa-rocket green');
|
||||
$item->addAttribute(pht('This daemon is running.'));
|
||||
break;
|
||||
case PhabricatorDaemonLog::STATUS_DEAD:
|
||||
$item->setStatusIcon('fa-warning red');
|
||||
|
|
100
src/infrastructure/env/PhabricatorEnv.php
vendored
100
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -277,106 +277,6 @@ final class PhabricatorEnv extends Phobject {
|
|||
return $env;
|
||||
}
|
||||
|
||||
public static function calculateEnvironmentHash() {
|
||||
$keys = self::getKeysForConsistencyCheck();
|
||||
|
||||
$values = array();
|
||||
foreach ($keys as $key) {
|
||||
$values[$key] = self::getEnvConfigIfExists($key);
|
||||
}
|
||||
|
||||
return PhabricatorHash::digest(json_encode($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a summary of non-default configuration settings to allow the
|
||||
* "daemons and web have different config" setup check to list divergent
|
||||
* keys.
|
||||
*/
|
||||
public static function calculateEnvironmentInfo() {
|
||||
$keys = self::getKeysForConsistencyCheck();
|
||||
|
||||
$info = array();
|
||||
|
||||
$defaults = id(new PhabricatorConfigDefaultSource())->getAllKeys();
|
||||
foreach ($keys as $key) {
|
||||
$current = self::getEnvConfigIfExists($key);
|
||||
$default = idx($defaults, $key, null);
|
||||
if ($current !== $default) {
|
||||
$info[$key] = PhabricatorHash::digestForIndex(json_encode($current));
|
||||
}
|
||||
}
|
||||
|
||||
$keys_hash = array_keys($defaults);
|
||||
sort($keys_hash);
|
||||
$keys_hash = implode("\0", $keys_hash);
|
||||
$keys_hash = PhabricatorHash::digestForIndex($keys_hash);
|
||||
|
||||
return array(
|
||||
'version' => 1,
|
||||
'keys' => $keys_hash,
|
||||
'values' => $info,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare two environment info summaries to generate a human-readable
|
||||
* list of discrepancies.
|
||||
*/
|
||||
public static function compareEnvironmentInfo(array $u, array $v) {
|
||||
$issues = array();
|
||||
|
||||
$uversion = idx($u, 'version');
|
||||
$vversion = idx($v, 'version');
|
||||
if ($uversion != $vversion) {
|
||||
$issues[] = pht(
|
||||
'The two configurations were generated by different versions '.
|
||||
'of Phabricator.');
|
||||
|
||||
// These may not be comparable, so stop here.
|
||||
return $issues;
|
||||
}
|
||||
|
||||
if ($u['keys'] !== $v['keys']) {
|
||||
$issues[] = pht(
|
||||
'The two configurations have different keys. This usually means '.
|
||||
'that they are running different versions of Phabricator.');
|
||||
}
|
||||
|
||||
$uval = idx($u, 'values', array());
|
||||
$vval = idx($v, 'values', array());
|
||||
|
||||
$all_keys = array_keys($uval + $vval);
|
||||
|
||||
foreach ($all_keys as $key) {
|
||||
$uv = idx($uval, $key);
|
||||
$vv = idx($vval, $key);
|
||||
if ($uv !== $vv) {
|
||||
if ($uv && $vv) {
|
||||
$issues[] = pht(
|
||||
'The configuration key "%s" is set in both configurations, but '.
|
||||
'set to different values.',
|
||||
$key);
|
||||
} else {
|
||||
$issues[] = pht(
|
||||
'The configuration key "%s" is set in only one configuration.',
|
||||
$key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $issues;
|
||||
}
|
||||
|
||||
private static function getKeysForConsistencyCheck() {
|
||||
$keys = array_keys(self::getAllConfigKeys());
|
||||
sort($keys);
|
||||
|
||||
$skip_keys = self::getEnvConfig('phd.variant-config');
|
||||
return array_diff($keys, $skip_keys);
|
||||
}
|
||||
|
||||
|
||||
/* -( Reading Configuration )---------------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue