mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
In Harbormaster, record byte length on the build logs
Summary: Depends on D19135. Ref T13088. Denormalize the total log size onto the log itself. This makes reasoning about the log at display time easier, and we don't need to fish around in the database as much to figure out what we're dealing with. Test Plan: Ran `bin/harbormaster rebuild-log`, saw an existing log populate. Ran `bin/harbormaster write-log`, saw new log write with proper length information. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13088 Differential Revision: https://secure.phabricator.com/D19136
This commit is contained in:
parent
d152bd5836
commit
57e3d607f5
3 changed files with 35 additions and 13 deletions
2
resources/sql/autopatches/20180223.log.01.bytelength.sql
Normal file
2
resources/sql/autopatches/20180223.log.01.bytelength.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildlog
|
||||||
|
ADD byteLength BIGINT UNSIGNED NOT NULL;
|
|
@ -12,6 +12,7 @@ final class HarbormasterBuildLog
|
||||||
protected $duration;
|
protected $duration;
|
||||||
protected $live;
|
protected $live;
|
||||||
protected $filePHID;
|
protected $filePHID;
|
||||||
|
protected $byteLength;
|
||||||
|
|
||||||
private $buildTarget = self::ATTACHABLE;
|
private $buildTarget = self::ATTACHABLE;
|
||||||
private $rope;
|
private $rope;
|
||||||
|
@ -42,7 +43,8 @@ final class HarbormasterBuildLog
|
||||||
return id(new HarbormasterBuildLog())
|
return id(new HarbormasterBuildLog())
|
||||||
->setBuildTargetPHID($build_target->getPHID())
|
->setBuildTargetPHID($build_target->getPHID())
|
||||||
->setDuration(null)
|
->setDuration(null)
|
||||||
->setLive(1);
|
->setLive(1)
|
||||||
|
->setByteLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleRebuild($force) {
|
public function scheduleRebuild($force) {
|
||||||
|
@ -70,6 +72,7 @@ final class HarbormasterBuildLog
|
||||||
|
|
||||||
'live' => 'bool',
|
'live' => 'bool',
|
||||||
'filePHID' => 'phid?',
|
'filePHID' => 'phid?',
|
||||||
|
'byteLength' => 'uint64',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'key_buildtarget' => array(
|
'key_buildtarget' => array(
|
||||||
|
@ -341,6 +344,7 @@ final class HarbormasterBuildLog
|
||||||
$append_data = $rope->getPrefixBytes($data_limit);
|
$append_data = $rope->getPrefixBytes($data_limit);
|
||||||
$data_size = strlen($append_data);
|
$data_size = strlen($append_data);
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
if ($append_id) {
|
if ($append_id) {
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn_w,
|
$conn_w,
|
||||||
|
@ -353,12 +357,15 @@ final class HarbormasterBuildLog
|
||||||
$this->writeChunk($encoding_text, $data_size, $append_data);
|
$this->writeChunk($encoding_text, $data_size, $append_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->byteLength += $data_size;
|
||||||
|
$this->save();
|
||||||
|
$this->saveTransaction();
|
||||||
|
|
||||||
$rope->removeBytesFromHead($data_size);
|
$rope->removeBytesFromHead($data_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,19 @@ final class HarbormasterLogWorker extends HarbormasterWorker {
|
||||||
$data = $this->getTaskData();
|
$data = $this->getTaskData();
|
||||||
$is_force = idx($data, 'force');
|
$is_force = idx($data, 'force');
|
||||||
|
|
||||||
|
if (!$log->getByteLength() || $is_force) {
|
||||||
|
$iterator = $log->newChunkIterator()
|
||||||
|
->setAsString(true);
|
||||||
|
|
||||||
|
$byte_length = 0;
|
||||||
|
foreach ($iterator as $block) {
|
||||||
|
$byte_length += strlen($block);
|
||||||
|
}
|
||||||
|
$log
|
||||||
|
->setByteLength($byte_length)
|
||||||
|
->save();
|
||||||
|
}
|
||||||
|
|
||||||
if ($log->canCompressLog()) {
|
if ($log->canCompressLog()) {
|
||||||
$log->compressLog();
|
$log->compressLog();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue