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

Add a setup check for installation on a burstable instance type

Summary: Fixes T11544. Attempt to detect if we're on a tiny, burstable-CPU AWS instance and complain.

Test Plan:
- Completely faked this locally.
- Hit the URI on an EC2 instance to check that it's correct (got back "m3.large", since that was the instance class).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11544

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

+43 -2
+43 -2
src/applications/config/check/PhabricatorWebServerSetupCheck.php
··· 42 42 ->setPath($send_path) 43 43 ->setQueryParam($expect_key, $expect_value); 44 44 45 - $future = id(new HTTPSFuture($base_uri)) 45 + $self_future = id(new HTTPSFuture($base_uri)) 46 46 ->addHeader('X-Phabricator-SelfCheck', 1) 47 47 ->addHeader('Accept-Encoding', 'gzip') 48 48 ->setHTTPBasicAuthCredentials( ··· 50 50 new PhutilOpaqueEnvelope($expect_pass)) 51 51 ->setTimeout(5); 52 52 53 + // Make a request to the metadata service available on EC2 instances, 54 + // to test if we're running on a T2 instance in AWS so we can warn that 55 + // this is a bad idea. Outside of AWS, this request will just fail. 56 + $ec2_uri = 'http://169.254.169.254/latest/meta-data/instance-type'; 57 + $ec2_future = id(new HTTPSFuture($ec2_uri)) 58 + ->setTimeout(1); 59 + 60 + $futures = array( 61 + $self_future, 62 + $ec2_future, 63 + ); 64 + $futures = new FutureIterator($futures); 65 + foreach ($futures as $future) { 66 + // Just resolve the futures here. 67 + } 68 + 69 + 53 70 try { 54 - list($body, $headers) = $future->resolvex(); 71 + list($body) = $ec2_future->resolvex(); 72 + $body = trim($body); 73 + if (preg_match('/^t2/', $body)) { 74 + $message = pht( 75 + 'Phabricator appears to be installed on a very small EC2 instance '. 76 + '(of class "%s") with burstable CPU. This is strongly discouraged. '. 77 + 'Phabricator regularly needs CPU, and these instances are often '. 78 + 'choked to death by CPU throttling. Use an instance with a normal '. 79 + 'CPU instead.', 80 + $body); 81 + 82 + $this->newIssue('ec2.burstable') 83 + ->setName(pht('Installed on Burstable CPU Instance')) 84 + ->setSummary( 85 + pht( 86 + 'Do not install Phabricator on an instance class with '. 87 + 'burstable CPU.')) 88 + ->setMessage($message); 89 + } 90 + } catch (Exception $ex) { 91 + // If this fails, just continue. We're probably not running in EC2. 92 + } 93 + 94 + try { 95 + list($body, $headers) = $self_future->resolvex(); 55 96 } catch (Exception $ex) { 56 97 // If this fails for whatever reason, just ignore it. Hopefully, the 57 98 // error is obvious and the user can correct it on their own, but we