@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+11 -233
+5
resources/sql/autopatches/20151110.daemonenvhash.sql
··· 1 + ALTER TABLE {$NAMESPACE}_daemon.daemon_log 2 + DROP COLUMN envHash; 3 + 4 + ALTER TABLE {$NAMESPACE}_daemon.daemon_log 5 + DROP COLUMN envInfo;
-102
src/applications/config/check/PhabricatorDaemonsSetupCheck.php
··· 47 47 } 48 48 49 49 $phd_user = PhabricatorEnv::getEnvConfig('phd.user'); 50 - $environment_hash = PhabricatorEnv::calculateEnvironmentHash(); 51 50 $all_daemons = id(new PhabricatorDaemonLogQuery()) 52 51 ->setViewer(PhabricatorUser::getOmnipotentUser()) 53 52 ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) ··· 90 89 ->setMessage($message) 91 90 ->addCommand('phabricator/ $ ./bin/phd restart'); 92 91 } 93 - } 94 - 95 - if ($daemon->getEnvHash() != $environment_hash) { 96 - $doc_href = PhabricatorEnv::getDocLink( 97 - 'Managing Daemons with phd'); 98 - 99 - $summary = pht( 100 - 'At least one daemon is currently running with different '. 101 - 'configuration than the Phabricator web application.'); 102 - 103 - $list_section = null; 104 - $env_info = $daemon->getEnvInfo(); 105 - if ($env_info) { 106 - $issues = PhabricatorEnv::compareEnvironmentInfo( 107 - PhabricatorEnv::calculateEnvironmentInfo(), 108 - $env_info); 109 - 110 - if ($issues) { 111 - foreach ($issues as $key => $issue) { 112 - $issues[$key] = phutil_tag('li', array(), $issue); 113 - } 114 - 115 - $list_section = array( 116 - pht( 117 - 'The configurations differ in the following %s way(s):', 118 - phutil_count($issues)), 119 - phutil_tag( 120 - 'ul', 121 - array(), 122 - $issues), 123 - ); 124 - } 125 - } 126 - 127 - 128 - $message = pht( 129 - 'At least one daemon is currently running with a different '. 130 - 'configuration (config checksum %s) than the web application '. 131 - '(config checksum %s).'. 132 - "\n\n%s". 133 - 'This usually means that you have just made a configuration change '. 134 - 'from the web UI, but have not yet restarted the daemons. You '. 135 - 'need to restart the daemons after making configuration changes '. 136 - 'so they will pick up the new values: until you do, they will '. 137 - 'continue operating with the old settings.'. 138 - "\n\n". 139 - '(If you plan to make more changes, you can restart the daemons '. 140 - 'once after you finish making all of your changes.)'. 141 - "\n\n". 142 - 'Use %s to restart daemons. You can find a list of running daemons '. 143 - 'in the %s, which will also help you identify which daemon (or '. 144 - 'daemons) have divergent configuration. For more information about '. 145 - 'managing the daemons, see %s in the documentation.'. 146 - "\n\n". 147 - 'This can also happen if you use the %s environmental variable to '. 148 - 'choose a configuration file, but the daemons run with a different '. 149 - 'value than the web application. If restarting the daemons does '. 150 - 'not resolve this issue and you use %s to select configuration, '. 151 - 'check that it is set consistently.'. 152 - "\n\n". 153 - 'A third possible cause is that you run several machines, and '. 154 - 'the %s configuration file differs between them. This file is '. 155 - 'updated when you edit configuration from the CLI with %s. If '. 156 - 'restarting the daemons does not resolve this issue and you '. 157 - 'run multiple machines, check that all machines have identical '. 158 - '%s configuration files.'. 159 - "\n\n". 160 - 'This issue is not severe, but usually indicates that something '. 161 - 'is not configured the way you expect, and may cause the daemons '. 162 - 'to exhibit different behavior than the web application does.', 163 - 164 - phutil_tag('tt', array(), substr($daemon->getEnvHash(), 0, 12)), 165 - phutil_tag('tt', array(), substr($environment_hash, 0, 12)), 166 - $list_section, 167 - phutil_tag('tt', array(), 'bin/phd restart'), 168 - phutil_tag( 169 - 'a', 170 - array( 171 - 'href' => '/daemon/', 172 - 'target' => '_blank', 173 - ), 174 - pht('Daemon Console')), 175 - phutil_tag( 176 - 'a', 177 - array( 178 - 'href' => $doc_href, 179 - 'target' => '_blank', 180 - ), 181 - pht('Managing Daemons with phd')), 182 - phutil_tag('tt', array(), 'PHABRICATOR_ENV'), 183 - phutil_tag('tt', array(), 'PHABRICATOR_ENV'), 184 - phutil_tag('tt', array(), 'phabricator/conf/local/local.json'), 185 - phutil_tag('tt', array(), 'bin/config'), 186 - phutil_tag('tt', array(), 'phabricator/conf/local/local.json')); 187 - 188 - $this->newIssue('daemons.need-restarting') 189 - ->setName(pht('Daemons and Web Have Different Config')) 190 - ->setSummary($summary) 191 - ->setMessage($message) 192 - ->addCommand('phabricator/ $ ./bin/phd restart'); 193 - break; 194 92 } 195 93 } 196 94 }
+4
src/applications/config/check/PhabricatorExtraConfigSetupCheck.php
··· 292 292 'gcdaemon.ttl.task-archive' => $gc_reason, 293 293 'gcdaemon.ttl.general-cache' => $gc_reason, 294 294 'gcdaemon.ttl.conduit-logs' => $gc_reason, 295 + 296 + 'phd.variant-config' => pht( 297 + 'This configuration is no longer relevant because daemons '. 298 + 'restart automatically on configuration changes.'), 295 299 ); 296 300 297 301 return $ancient_config;
-7
src/applications/config/option/PhabricatorPHDConfigOptions.php
··· 73 73 "trace mode. See also '%s'.", 74 74 'phd debug', 75 75 'phd.verbose')), 76 - $this->newOption('phd.variant-config', 'list<string>', array()) 77 - ->setDescription( 78 - pht( 79 - 'Specify config keys that can safely vary between the web tier '. 80 - 'and the daemons. Primarily, this is a way to suppress the '. 81 - '"Daemons and Web Have Different Config" setup issue on a per '. 82 - 'config key basis.')), 83 76 $this->newOption('phd.garbage-collection', 'wild', array()) 84 77 ->setLocked(true) 85 78 ->setLockedMessage(
-8
src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
··· 58 58 } 59 59 60 60 $header->addTag($tag); 61 - $env_hash = PhabricatorEnv::calculateEnvironmentHash(); 62 - if ($log->getEnvHash() != $env_hash) { 63 - $tag = id(new PHUITagView()) 64 - ->setType(PHUITagView::TYPE_STATE) 65 - ->setBackgroundColor(PHUITagView::COLOR_YELLOW) 66 - ->setName(pht('Stale Config')); 67 - $header->addTag($tag); 68 - } 69 61 70 62 $properties = $this->buildPropertyListView($log); 71 63
-2
src/applications/daemon/event/PhabricatorDaemonEventListener.php
··· 42 42 ->setHost(php_uname('n')) 43 43 ->setPID(getmypid()) 44 44 ->setRunningAsUser($current_user['name']) 45 - ->setEnvHash(PhabricatorEnv::calculateEnvironmentHash()) 46 - ->setEnvInfo(PhabricatorEnv::calculateEnvironmentInfo()) 47 45 ->setStatus(PhabricatorDaemonLog::STATUS_RUNNING) 48 46 ->setArgv($event->getValue('argv')) 49 47 ->setExplicitArgv($event->getValue('explicitArgv'))
-4
src/applications/daemon/storage/PhabricatorDaemonLog.php
··· 17 17 protected $runningAsUser; 18 18 protected $argv; 19 19 protected $explicitArgv = array(); 20 - protected $envHash; 21 - protected $envInfo; 22 20 protected $status; 23 21 24 22 protected function getConfiguration() { ··· 26 24 self::CONFIG_SERIALIZATION => array( 27 25 'argv' => self::SERIALIZATION_JSON, 28 26 'explicitArgv' => self::SERIALIZATION_JSON, 29 - 'envInfo' => self::SERIALIZATION_JSON, 30 27 ), 31 28 self::CONFIG_COLUMN_SCHEMA => array( 32 29 'daemon' => 'text255', 33 30 'host' => 'text255', 34 31 'pid' => 'uint32', 35 32 'runningAsUser' => 'text255?', 36 - 'envHash' => 'bytes40', 37 33 'status' => 'text8', 38 34 'daemonID' => 'text64', 39 35 ),
+2 -10
src/applications/daemon/view/PhabricatorDaemonLogListView.php
··· 17 17 throw new PhutilInvalidStateException('setUser'); 18 18 } 19 19 20 - $env_hash = PhabricatorEnv::calculateEnvironmentHash(); 21 20 $list = new PHUIObjectItemListView(); 22 21 $list->setFlush(true); 23 22 foreach ($this->daemonLogs as $log) { ··· 33 32 $status = $log->getStatus(); 34 33 switch ($status) { 35 34 case PhabricatorDaemonLog::STATUS_RUNNING: 36 - if ($env_hash != $log->getEnvHash()) { 37 - $item->setStatusIcon('fa-warning yellow'); 38 - $item->addAttribute(pht( 39 - 'This daemon is running with an out of date configuration and '. 40 - 'should be restarted.')); 41 - } else { 42 - $item->setStatusIcon('fa-rocket green'); 43 - $item->addAttribute(pht('This daemon is running.')); 44 - } 35 + $item->setStatusIcon('fa-rocket green'); 36 + $item->addAttribute(pht('This daemon is running.')); 45 37 break; 46 38 case PhabricatorDaemonLog::STATUS_DEAD: 47 39 $item->setStatusIcon('fa-warning red');
-100
src/infrastructure/env/PhabricatorEnv.php
··· 277 277 return $env; 278 278 } 279 279 280 - public static function calculateEnvironmentHash() { 281 - $keys = self::getKeysForConsistencyCheck(); 282 - 283 - $values = array(); 284 - foreach ($keys as $key) { 285 - $values[$key] = self::getEnvConfigIfExists($key); 286 - } 287 - 288 - return PhabricatorHash::digest(json_encode($values)); 289 - } 290 - 291 - /** 292 - * Returns a summary of non-default configuration settings to allow the 293 - * "daemons and web have different config" setup check to list divergent 294 - * keys. 295 - */ 296 - public static function calculateEnvironmentInfo() { 297 - $keys = self::getKeysForConsistencyCheck(); 298 - 299 - $info = array(); 300 - 301 - $defaults = id(new PhabricatorConfigDefaultSource())->getAllKeys(); 302 - foreach ($keys as $key) { 303 - $current = self::getEnvConfigIfExists($key); 304 - $default = idx($defaults, $key, null); 305 - if ($current !== $default) { 306 - $info[$key] = PhabricatorHash::digestForIndex(json_encode($current)); 307 - } 308 - } 309 - 310 - $keys_hash = array_keys($defaults); 311 - sort($keys_hash); 312 - $keys_hash = implode("\0", $keys_hash); 313 - $keys_hash = PhabricatorHash::digestForIndex($keys_hash); 314 - 315 - return array( 316 - 'version' => 1, 317 - 'keys' => $keys_hash, 318 - 'values' => $info, 319 - ); 320 - } 321 - 322 - 323 - /** 324 - * Compare two environment info summaries to generate a human-readable 325 - * list of discrepancies. 326 - */ 327 - public static function compareEnvironmentInfo(array $u, array $v) { 328 - $issues = array(); 329 - 330 - $uversion = idx($u, 'version'); 331 - $vversion = idx($v, 'version'); 332 - if ($uversion != $vversion) { 333 - $issues[] = pht( 334 - 'The two configurations were generated by different versions '. 335 - 'of Phabricator.'); 336 - 337 - // These may not be comparable, so stop here. 338 - return $issues; 339 - } 340 - 341 - if ($u['keys'] !== $v['keys']) { 342 - $issues[] = pht( 343 - 'The two configurations have different keys. This usually means '. 344 - 'that they are running different versions of Phabricator.'); 345 - } 346 - 347 - $uval = idx($u, 'values', array()); 348 - $vval = idx($v, 'values', array()); 349 - 350 - $all_keys = array_keys($uval + $vval); 351 - 352 - foreach ($all_keys as $key) { 353 - $uv = idx($uval, $key); 354 - $vv = idx($vval, $key); 355 - if ($uv !== $vv) { 356 - if ($uv && $vv) { 357 - $issues[] = pht( 358 - 'The configuration key "%s" is set in both configurations, but '. 359 - 'set to different values.', 360 - $key); 361 - } else { 362 - $issues[] = pht( 363 - 'The configuration key "%s" is set in only one configuration.', 364 - $key); 365 - } 366 - } 367 - } 368 - 369 - return $issues; 370 - } 371 - 372 - private static function getKeysForConsistencyCheck() { 373 - $keys = array_keys(self::getAllConfigKeys()); 374 - sort($keys); 375 - 376 - $skip_keys = self::getEnvConfig('phd.variant-config'); 377 - return array_diff($keys, $skip_keys); 378 - } 379 - 380 280 381 281 /* -( Reading Configuration )---------------------------------------------- */ 382 282