Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ windowskey 2, ldap 6, oidc 8, capone 2, subnetgroup 1 -- are declared in
core's map and applied by a step in each plugin's own `schema()` in
`FOGProject/fog-plugins`.

**126 of the map's 141 relationships are declared.** The other 15 are not
**127 of the map's 143 relationships are declared.** The other 16 are not
pending work: they carry action `none`, which the map's docblock defines as a
decision rather than an omission. Nine are audit rows, which MUST NOT
decision rather than an omission. Ten are audit rows, which MUST NOT
constrain the thing they record (ADR 0021, `schema.php` step 341); six are
polymorphic columns whose target table is chosen by a sibling column, where
no constraint is expressible at all. Nothing in the map is waiting on a
Expand Down
2 changes: 1 addition & 1 deletion docs/development/foreign-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ half-converted column.
## Phase D — plugins, and the direction rule

18 plugin tables ship in `FOGProject/fog-plugins`. All 18 clone cleanly into
the survey and 29 of the map's 141 relationships live in them.
the survey and 29 of the map's 143 relationships live in them.

### Direction is the whole rule

Expand Down
5 changes: 5 additions & 0 deletions packages/web/commons/schema-constraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@
['child' => 'hostSoftware', 'column' => 'hsHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
['child' => 'hostUserSession', 'column' => 'husHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
['child' => 'hostFactState', 'column' => 'hfsHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
// Performance Test results (fos#55). A satellite of the host: CASCADE.
// The task id is audit, like taskLog.taskID: a result records something
// that happened and must not constrain the task row.
['child' => 'hostPerfTests', 'column' => 'hptHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
['child' => 'hostPerfTests', 'column' => 'hptTaskID', 'parent' => 'tasks', 'pcolumn' => 'taskID', 'class' => 'audit', 'action' => 'none'],
['child' => 'hostDirectory', 'column' => 'hdHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
['child' => 'hostPrinter', 'column' => 'hpHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
['child' => 'hostSpooler', 'column' => 'hspHostID', 'parent' => 'hosts', 'pcolumn' => 'hostID', 'class' => 'satellite', 'action' => 'CASCADE', 'enabled' => true, 'group' => 14],
Expand Down
19 changes: 19 additions & 0 deletions packages/web/commons/schema-expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,25 @@
'hnObservedAt' => 'datetime DEFAULT NULL',
],
],
'hostPerfTests' => [
'create' => 'CREATE TABLE IF NOT EXISTS `hostPerfTests` ( `hptID` int(11) NOT NULL AUTO_INCREMENT, `hptHostID` int(11) NOT NULL, `hptTaskID` int(11) NOT NULL DEFAULT 0, `hptDateTime` datetime DEFAULT NULL, `hptDisk` varchar(64) NOT NULL DEFAULT \'\', `hptDiskMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptNetMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptCpuMBps` int(10) unsigned NOT NULL DEFAULT 0, `hptRatio` int(10) unsigned NOT NULL DEFAULT 0, `hptFormat` varchar(8) NOT NULL DEFAULT \'\', `hptSample` varchar(255) NOT NULL DEFAULT \'\', `hptBottleneck` varchar(16) NOT NULL DEFAULT \'\', `hptKernel` varchar(64) NOT NULL DEFAULT \'\', `hptInit` varchar(32) NOT NULL DEFAULT \'\', PRIMARY KEY (`hptID`), KEY `hptHostID` (`hptHostID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC',
'columns' => [
'hptID' => 'int(11) NOT NULL',
'hptHostID' => 'int(11) NOT NULL',
'hptTaskID' => 'int(11) NOT NULL DEFAULT 0',
'hptDateTime' => 'datetime DEFAULT NULL',
'hptDisk' => 'varchar(64) NOT NULL DEFAULT \'\'',
'hptDiskMBps' => 'int(10) unsigned NOT NULL DEFAULT 0',
'hptNetMBps' => 'int(10) unsigned NOT NULL DEFAULT 0',
'hptCpuMBps' => 'int(10) unsigned NOT NULL DEFAULT 0',
'hptRatio' => 'int(10) unsigned NOT NULL DEFAULT 0',
'hptFormat' => 'varchar(8) NOT NULL DEFAULT \'\'',
'hptSample' => 'varchar(255) NOT NULL DEFAULT \'\'',
'hptBottleneck' => 'varchar(16) NOT NULL DEFAULT \'\'',
'hptKernel' => 'varchar(64) NOT NULL DEFAULT \'\'',
'hptInit' => 'varchar(32) NOT NULL DEFAULT \'\'',
],
],
'hostPrinter' => [
'create' => 'CREATE TABLE IF NOT EXISTS `hostPrinter` ( `hpID` int(11) NOT NULL AUTO_INCREMENT, `hpHostID` int(11) NOT NULL, `hpName` varchar(255) NOT NULL DEFAULT \'\', `hpURI` varchar(1024) NOT NULL DEFAULT \'\', `hpDriver` varchar(255) NOT NULL DEFAULT \'\', `hpDefault` tinyint(1) NOT NULL DEFAULT 0, `hpShared` tinyint(1) NOT NULL DEFAULT 0, `hpObservedAt` datetime DEFAULT NULL, PRIMARY KEY (`hpID`), UNIQUE KEY `hpHostName` (`hpHostID`,`hpName`), KEY `hpName` (`hpName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC',
'columns' => [
Expand Down
48 changes: 48 additions & 0 deletions packages/web/commons/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -11998,3 +11998,51 @@ function () {
. "JOIN `groupModuleAssoc` g ON g.`gmaGroupID` = gm.`gmGroupID` "
. "WHERE gm.`gmHostID` = h.`hostID` AND g.`gmaModuleID` = m.`id`)",
];

// 444
$this->schema[] = [
// The Performance Test task type (fos#55). FOS boots with
// mode=perftest, times the disk, the network and decompression, and
// reports the result to service/perftest.php. The task changes
// nothing on the disk.
//
// ttID 27 is the next free id (26 is the Secure Boot test task).
// Deleted ids are not reused. ttIsAdvanced '1': a diagnostic, not a
// fleet operation, so it sits behind the Advanced toggle. It needs no
// image, so getTasking() treats it like the wipes.
"INSERT IGNORE INTO `taskTypes` "
. "(`ttID`,`ttName`,`ttDescription`,`ttIcon`,`ttKernel`,"
. "`ttKernelArgs`,`ttType`,`ttIsAdvanced`,`ttIsAccess`) "
. "VALUES "
. "(27,'Performance Test','Times the disk, network and decompression "
. "speed of the client to find what limits imaging. It changes nothing "
. "on the disk.','gauge-high','','mode=perftest','fog','1','both')",
// One row per reported run, newest first on the host page.
//
// hptHostID is a satellite of the host: the rows go with the host
// (CASCADE in commons/schema-constraints.php, group 14, like
// hostUserSession). hptTaskID is an audit reference: a result records
// something that happened and must not constrain the task row, the
// same as taskLog.taskID.
//
// A rate of 0 means FOS did not measure it. hptRatio is the
// compression ratio times 100, so 250 is 2.50:1.
"CREATE TABLE IF NOT EXISTS `hostPerfTests` ( "
. "`hptID` int(11) NOT NULL AUTO_INCREMENT, "
. "`hptHostID` int(11) NOT NULL, "
. "`hptTaskID` int(11) NOT NULL DEFAULT 0, "
. "`hptDateTime` datetime DEFAULT NULL, "
. "`hptDisk` varchar(64) NOT NULL DEFAULT '', "
. "`hptDiskMBps` int(10) unsigned NOT NULL DEFAULT 0, "
. "`hptNetMBps` int(10) unsigned NOT NULL DEFAULT 0, "
. "`hptCpuMBps` int(10) unsigned NOT NULL DEFAULT 0, "
. "`hptRatio` int(10) unsigned NOT NULL DEFAULT 0, "
. "`hptFormat` varchar(8) NOT NULL DEFAULT '', "
. "`hptSample` varchar(255) NOT NULL DEFAULT '', "
. "`hptBottleneck` varchar(16) NOT NULL DEFAULT '', "
. "`hptKernel` varchar(64) NOT NULL DEFAULT '', "
. "`hptInit` varchar(32) NOT NULL DEFAULT '', "
. "PRIMARY KEY (`hptID`), "
. "KEY `hptHostID` (`hptHostID`) "
. ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=DYNAMIC",
];
39 changes: 39 additions & 0 deletions packages/web/management/js/fog/host/fog.host.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,45 @@
}
});

// ---------------------------------------------------------------
// PERFORMANCE TAB (read only)
//
// One row per Performance Test run, newest first. The server formats the
// rates and the ratio (getPerfTests), so every column only escapes. The
// empty-state sentence is translated server side and handed over in a
// hidden element.
var hostPerfTestTable = $('#host-perftest-table').registerTable(null, {
columns: [
$.escapedColumn('date'),
$.escapedColumn('disk'),
$.escapedColumn('diskMBps'),
$.escapedColumn('netMBps'),
$.escapedColumn('cpuMBps'),
$.escapedColumn('ratio'),
$.escapedColumn('format'),
$.escapedColumn('bottleneck'),
$.escapedColumn('kernel'),
$.escapedColumn('init')
],
order: [
[0, 'desc']
],
rowId: 'id',
processing: true,
serverSide: true,
select: false,
language: {
emptyTable: $('#host-perftest-empty').text()
},
ajax: {
url: '../management/index.php?node='
+ Common.node
+ '&sub=getPerfTests&id='
+ Common.id,
type: 'post'
}
});

// FOG CLIENT AREA
// ---------------------------------------------------------------
// CLIENT SETTINGS TAB
Expand Down
92 changes: 92 additions & 0 deletions packages/web/service/perftest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* FOS reports what a Performance Test measured.
*
* PHP version 7.4+
*
* @category Performance_Test_Report
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/

use FOG\Base\FOGBase;
use FOG\Base\FOGCore;
use FOG\Items\HostPerfTest;

/**
* FOS reports what a Performance Test measured.
*
* FOS boots with mode=perftest, times the disk, the network and
* decompression, and posts the result here before it completes the task.
* Each run adds one row to hostPerfTests. The host page shows them.
*
* ADVISORY, like every other machine entry point. Nothing reads a row as a
* security control. It is still narrowed: the host must have a Performance
* Test task in flight, and every field is checked. The rules are in
* HostPerfTest::refusal(), so a test can drive them without a database.
*
* FOS treats a body of exactly `##` as success. Any other body is shown on
* the client screen as the reason for the failure. So a refusal answers 200
* with the reason as plain text. A non-2xx is invisible to the caller and
* reads as a transport failure.
*
* @category Performance_Test_Report
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
/*
* A machine entry point: the caller is FOS, which cannot present a
* credential. Declared per file -- see Authorization::_hasNoPrincipal().
*/
define('FOG_MACHINE_REQUEST', true);

require '../commons/base.inc.php';

header('Content-type: text/plain');

/**
* Say what happened and stop.
*
* @param string $msg the body to send
*
* @return void
*/
$done = function ($msg) {
echo $msg . "\n";
exit;
};

$in = [];
foreach (
[
'mac', 'disk', 'diskmbps', 'netmbps', 'cpumbps', 'ratio', 'format',
'sample', 'bottleneck', 'kernel', 'initversion'
] as $key
) {
$in[$key] = (string)filter_input(INPUT_POST, $key);
}

FOGCore::getHostItem(false, false, true, false, false, $in['mac']);
$Host = FOGBase::$Host;

$row = [];
$reason = HostPerfTest::refusal($Host, $in, $row);
if ('' !== $reason) {
$done($reason);
}

$row['dateTime'] = FOGBase::niceDate()->format('Y-m-d H:i:s');
$Result = new HostPerfTest();
foreach ($row as $field => $value) {
$Result->set($field, $value);
}
if (!$Result->save()) {
$done('The result could not be stored');
}

// FOS looks for exactly this and nothing else.
echo '##';
2 changes: 1 addition & 1 deletion packages/web/src/Base/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __construct()
// 1.5.x carried count does, see SchemaReconciler's docstring -- is
// permanently "up to date" from the updater's point of view and will
// never run another indexed step, whatever this constant says.
define('FOG_SCHEMA', 443);
define('FOG_SCHEMA', 444);
define('FOG_BCACHE_VER', 370);
define('FOG_CLIENT_VERSION', '0.13.0');
// GH-959: iPXE lives in FOGProject/fog-ipxe and its binaries arrive as
Expand Down
Loading
Loading