diff --git a/resources/sql/autopatches/20151110.daemonenvhash.sql b/resources/sql/autopatches/20151110.daemonenvhash.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20151110.daemonenvhash.sql @@ -0,0 +1,5 @@ +ALTER TABLE {$NAMESPACE}_daemon.daemon_log + DROP COLUMN envHash; + +ALTER TABLE {$NAMESPACE}_daemon.daemon_log + DROP COLUMN envInfo; diff --git a/src/applications/config/check/PhabricatorDaemonsSetupCheck.php b/src/applications/config/check/PhabricatorDaemonsSetupCheck.php --- a/src/applications/config/check/PhabricatorDaemonsSetupCheck.php +++ b/src/applications/config/check/PhabricatorDaemonsSetupCheck.php @@ -47,7 +47,6 @@ } $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 @@ ->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; - } } } diff --git a/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php b/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php --- a/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php +++ b/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php @@ -292,6 +292,10 @@ '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; diff --git a/src/applications/config/option/PhabricatorPHDConfigOptions.php b/src/applications/config/option/PhabricatorPHDConfigOptions.php --- a/src/applications/config/option/PhabricatorPHDConfigOptions.php +++ b/src/applications/config/option/PhabricatorPHDConfigOptions.php @@ -73,13 +73,6 @@ "trace mode. See also '%s'.", 'phd debug', 'phd.verbose')), - $this->newOption('phd.variant-config', 'list', 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( diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php --- a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php @@ -58,14 +58,6 @@ } $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); diff --git a/src/applications/daemon/event/PhabricatorDaemonEventListener.php b/src/applications/daemon/event/PhabricatorDaemonEventListener.php --- a/src/applications/daemon/event/PhabricatorDaemonEventListener.php +++ b/src/applications/daemon/event/PhabricatorDaemonEventListener.php @@ -42,8 +42,6 @@ ->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')) diff --git a/src/applications/daemon/storage/PhabricatorDaemonLog.php b/src/applications/daemon/storage/PhabricatorDaemonLog.php --- a/src/applications/daemon/storage/PhabricatorDaemonLog.php +++ b/src/applications/daemon/storage/PhabricatorDaemonLog.php @@ -17,8 +17,6 @@ protected $runningAsUser; protected $argv; protected $explicitArgv = array(); - protected $envHash; - protected $envInfo; protected $status; protected function getConfiguration() { @@ -26,14 +24,12 @@ 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', ), diff --git a/src/applications/daemon/view/PhabricatorDaemonLogListView.php b/src/applications/daemon/view/PhabricatorDaemonLogListView.php --- a/src/applications/daemon/view/PhabricatorDaemonLogListView.php +++ b/src/applications/daemon/view/PhabricatorDaemonLogListView.php @@ -17,7 +17,6 @@ throw new PhutilInvalidStateException('setUser'); } - $env_hash = PhabricatorEnv::calculateEnvironmentHash(); $list = new PHUIObjectItemListView(); $list->setFlush(true); foreach ($this->daemonLogs as $log) { @@ -33,15 +32,8 @@ $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'); diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -277,106 +277,6 @@ 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 )---------------------------------------------- */