@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.

Make the "daemons and web have different config" warning more specific

Summary:
I'm hitting this in the cluster and couldn't figure it out after staring at it for a couple minutes. Produce a better error.

This dumps a hash of each configuration key value which is set to a non-default value into the daemon log. This is much more compact than the full config, and doesn't spread secrets around, so it seems like a good balance between providing information and going crazy with it.

Test Plan: {F284139}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11699

+128 -6
+2
resources/sql/autopatches/20150205.daemonenv.sql
··· 1 + ALTER TABLE {$NAMESPACE}_daemon.daemon_log 2 + ADD envInfo LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};
+27 -1
src/applications/config/check/PhabricatorDaemonsSetupCheck.php
··· 92 92 'At least one daemon is currently running with different '. 93 93 'configuration than the Phabricator web application.'); 94 94 95 + $list_section = null; 96 + $env_info = $daemon->getEnvInfo(); 97 + if ($env_info) { 98 + $issues = PhabricatorEnv::compareEnvironmentInfo( 99 + PhabricatorEnv::calculateEnvironmentInfo(), 100 + $env_info); 101 + 102 + if ($issues) { 103 + foreach ($issues as $key => $issue) { 104 + $issues[$key] = phutil_tag('li', array(), $issue); 105 + } 106 + 107 + $list_section = array( 108 + pht( 109 + 'The configurations differ in the following %s way(s):', 110 + new PhutilNumber(count($issues))), 111 + phutil_tag( 112 + 'ul', 113 + array(), 114 + $issues), 115 + ); 116 + } 117 + } 118 + 119 + 95 120 $message = pht( 96 121 'At least one daemon is currently running with a different '. 97 122 'configuration (config checksum %s) than the web application '. 98 123 '(config checksum %s).'. 99 - "\n\n". 124 + "\n\n%s". 100 125 'This usually means that you have just made a configuration change '. 101 126 'from the web UI, but have not yet restarted the daemons. You '. 102 127 'need to restart the daemons after making configuration changes '. ··· 130 155 131 156 phutil_tag('tt', array(), substr($daemon->getEnvHash(), 0, 12)), 132 157 phutil_tag('tt', array(), substr($environment_hash, 0, 12)), 158 + $list_section, 133 159 phutil_tag('tt', array(), 'bin/phd restart'), 134 160 phutil_tag( 135 161 'a',
+1
src/applications/daemon/event/PhabricatorDaemonEventListener.php
··· 42 42 ->setPID(getmypid()) 43 43 ->setRunningAsUser($current_user['name']) 44 44 ->setEnvHash(PhabricatorEnv::calculateEnvironmentHash()) 45 + ->setEnvInfo(PhabricatorEnv::calculateEnvironmentInfo()) 45 46 ->setStatus(PhabricatorDaemonLog::STATUS_RUNNING) 46 47 ->setArgv($event->getValue('argv')) 47 48 ->setExplicitArgv($event->getValue('explicitArgv'))
+2
src/applications/daemon/storage/PhabricatorDaemonLog.php
··· 17 17 protected $argv; 18 18 protected $explicitArgv = array(); 19 19 protected $envHash; 20 + protected $envInfo; 20 21 protected $status; 21 22 22 23 protected function getConfiguration() { ··· 24 25 self::CONFIG_SERIALIZATION => array( 25 26 'argv' => self::SERIALIZATION_JSON, 26 27 'explicitArgv' => self::SERIALIZATION_JSON, 28 + 'envInfo' => self::SERIALIZATION_JSON, 27 29 ), 28 30 self::CONFIG_COLUMN_SCHEMA => array( 29 31 'daemon' => 'text255',
+91 -5
src/infrastructure/env/PhabricatorEnv.php
··· 240 240 } 241 241 242 242 public static function calculateEnvironmentHash() { 243 - $keys = array_keys(self::getAllConfigKeys()); 244 - sort($keys); 245 - 246 - $skip_keys = self::getEnvConfig('phd.variant-config'); 247 - $keys = array_diff($keys, $skip_keys); 243 + $keys = self::getKeysForConsistencyCheck(); 248 244 249 245 $values = array(); 250 246 foreach ($keys as $key) { 251 247 $values[$key] = self::getEnvConfigIfExists($key); 252 248 } 249 + 253 250 return PhabricatorHash::digest(json_encode($values)); 251 + } 252 + 253 + /** 254 + * Returns a summary of non-default configuration settings to allow the 255 + * "daemons and web have different config" setup check to list divergent 256 + * keys. 257 + */ 258 + public static function calculateEnvironmentInfo() { 259 + $keys = self::getKeysForConsistencyCheck(); 260 + 261 + $info = array(); 262 + 263 + $defaults = id(new PhabricatorConfigDefaultSource())->getAllKeys(); 264 + foreach ($keys as $key) { 265 + $current = self::getEnvConfigIfExists($key); 266 + $default = idx($defaults, $key, null); 267 + if ($current !== $default) { 268 + $info[$key] = PhabricatorHash::digestForIndex(json_encode($current)); 269 + } 270 + } 271 + 272 + $keys_hash = array_keys($defaults); 273 + sort($keys_hash); 274 + $keys_hash = implode("\0", $keys_hash); 275 + $keys_hash = PhabricatorHash::digestForIndex($keys_hash); 276 + 277 + return array( 278 + 'version' => 1, 279 + 'keys' => $keys_hash, 280 + 'values' => $info, 281 + ); 282 + } 283 + 284 + 285 + /** 286 + * Compare two environment info summaries to generate a human-readable 287 + * list of discrepancies. 288 + */ 289 + public static function compareEnvironmentInfo(array $u, array $v) { 290 + $issues = array(); 291 + 292 + $uversion = idx($u, 'version'); 293 + $vversion = idx($v, 'version'); 294 + if ($uversion != $vversion) { 295 + $issues[] = pht( 296 + 'The two configurations were generated by different versions '. 297 + 'of Phabricator.'); 298 + 299 + // These may not be comparable, so stop here. 300 + return $issues; 301 + } 302 + 303 + if ($u['keys'] !== $v['keys']) { 304 + $issues[] = pht( 305 + 'The two configurations have different keys. This usually means '. 306 + 'that they are running different versions of Phabricator.'); 307 + } 308 + 309 + $uval = idx($u, 'values', array()); 310 + $vval = idx($v, 'values', array()); 311 + 312 + $all_keys = array_keys($uval + $vval); 313 + 314 + foreach ($all_keys as $key) { 315 + $uv = idx($uval, $key); 316 + $vv = idx($vval, $key); 317 + if ($uv !== $vv) { 318 + if ($uv && $vv) { 319 + $issues[] = pht( 320 + 'The configuration key "%s" is set in both configurations, but '. 321 + 'set to different values.', 322 + $key); 323 + } else { 324 + $issues[] = pht( 325 + 'The configuration key "%s" is set in only one configuration.', 326 + $key); 327 + } 328 + } 329 + } 330 + 331 + return $issues; 332 + } 333 + 334 + private static function getKeysForConsistencyCheck() { 335 + $keys = array_keys(self::getAllConfigKeys()); 336 + sort($keys); 337 + 338 + $skip_keys = self::getEnvConfig('phd.variant-config'); 339 + return array_diff($keys, $skip_keys); 254 340 } 255 341 256 342
+5
src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php
··· 906 906 'You have an unpaid invoice.', 907 907 'You have unpaid invoices.', 908 908 ), 909 + 910 + 'The configurations differ in the following %s way(s):' => array( 911 + 'The configurations differ:', 912 + 'The configurations differ in these ways:', 913 + ), 909 914 ); 910 915 } 911 916