Skip to content
Permalink
Browse files
Add the support for maintenance mode
https://bugs.webkit.org/show_bug.cgi?id=154072

Reviewed by Chris Dumez.

Added the crude support for maintenance mode whereby which the reports are stored in the filesystem
instead of the database.

* config.json: Added maintenanceMode and maintenanceDirectory as well as forgotten siteTitle and
remoteServer.httpdMutexDir.
* public/api/report.php:
(main): Don't connect to the database or modify database when maintenanceMode is set.
* public/include/json-header.php:
(ensure_privileged_api_data): Exit with InMaintenanceMode when maintenanceMode is set. This prevents
privileged API such as creating analysis tasks and new A/B testing groups from modifying the database.


Canonical link: https://commits.webkit.org/172187@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196386 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Feb 10, 2016
1 parent 8e265d8 commit 36cb9c6cbb663fc408877066114622a0548d9038
@@ -1,3 +1,21 @@
2016-02-10 Ryosuke Niwa <rniwa@webkit.org>

Add the support for maintenance mode
https://bugs.webkit.org/show_bug.cgi?id=154072

Reviewed by Chris Dumez.

Added the crude support for maintenance mode whereby which the reports are stored in the filesystem
instead of the database.

* config.json: Added maintenanceMode and maintenanceDirectory as well as forgotten siteTitle and
remoteServer.httpdMutexDir.
* public/api/report.php:
(main): Don't connect to the database or modify database when maintenanceMode is set.
* public/include/json-header.php:
(ensure_privileged_api_data): Exit with InMaintenanceMode when maintenanceMode is set. This prevents
privileged API such as creating analysis tasks and new A/B testing groups from modifying the database.

2016-02-09 Ryosuke Niwa <rniwa@webkit.org>

Analysis task page on v3 show progression as regressions
@@ -1,4 +1,5 @@
{
"siteTitle": "WebKit Performance Dashboard",
"debug": true,
"jsonCacheMaxAge": 600,
"dataDirectory": "public/data/",
@@ -9,6 +10,8 @@
"password": "password",
"name": "webkit-perf-db"
},
"maintenanceMode": false,
"maintenanceDirectory": "reported/",
"testServer": {
"hostname": "localhost",
"port": 80
@@ -20,7 +23,8 @@
"httpdConfig": "tools/remote-server-relay.conf",
"httpdPID": "tools/remote-server-relay.pid",
"httpdErrorLog": "tools/remote-server-relay.log",
"url": "http://perf.webkit.org",
"httpdMutexDir": "/tmp/org.webkit.perf.remote/",
"url": "https://perf-safari.apple.com",
"basicAuth": {
"username": "username",
"password": "password"
@@ -7,8 +7,12 @@
function main($post_data) {
set_exit_detail('failureStored', false);

$maintenance_mode = config('maintenanceMode');
if ($maintenance_mode && !config('maintenanceDirectory'))
exit_with_error('MaintenanceDirectoryNotSet');

$db = new Database;
if (!$db->connect())
if (!$maintenance_mode && !$db->connect())
exit_with_error('DatabaseConnectionFailure');

// Convert all floating points to strings to avoid parsing them in PHP.
@@ -19,16 +23,29 @@ function main($post_data) {

set_exit_detail('processedRuns', 0);
foreach ($parsed_json as $i => $report) {
$processor = new ReportProcessor($db);
$processor->process($report);
if (!$maintenance_mode) {
$processor = new ReportProcessor($db);
$processor->process($report);
}
set_exit_detail('processedRuns', $i + 1);
}

$generator = new ManifestGenerator($db);
if (!$generator->generate())
exit_with_error('FailedToGenerateManifest');
else if (!$generator->store())
exit_with_error('FailedToStoreManifest');
if ($maintenance_mode) {
$files = scandir(config_path('maintenanceDirectory', ''));
$i = 0;
$filename = '';
do {
$i++;
$filename = "$i.json";
} while (in_array($filename, $files));
file_put_contents(config_path('maintenanceDirectory', $filename), $post_data, LOCK_EX);
} else {
$generator = new ManifestGenerator($db);
if (!$generator->generate())
exit_with_error('FailedToGenerateManifest');
else if (!$generator->store())
exit_with_error('FailedToStoreManifest');
}

exit_with_success();
}
@@ -92,6 +92,9 @@ function require_existence_of($array, $list_of_arguments, $prefix = '') {
function ensure_privileged_api_data() {
global $HTTP_RAW_POST_DATA;

if (config('maintenanceMode'))
exit_with_error('InMaintenanceMode');

if ($_SERVER['REQUEST_METHOD'] != 'POST')
exit_with_error('InvalidRequestMethod');

0 comments on commit 36cb9c6

Please sign in to comment.