diff --git a/www/controllers/Common.php b/www/controllers/Common.php index 0d6314e9b..399ecf698 100644 --- a/www/controllers/Common.php +++ b/www/controllers/Common.php @@ -219,7 +219,7 @@ public function randomColor() } /** - * Convertit une durée microtime au format HHhMMmSSs + * Converts a microtime duration to a time format HHhMMmSSs */ public static function convertMicrotime(string $duration) { @@ -239,9 +239,21 @@ public static function convertMicrotime(string $duration) $time .= $seconds . 's'; } + if (empty($time)) { + $time = '0s'; + } + return $time; } + /** + * Converts a microtime to a time format + */ + public static function microtimeToTime(string $microtime) + { + return date('H:i:s', $microtime); + } + /** * Tri un array par la valeur de clé spécifiée */ diff --git a/www/controllers/Logging/Step.php b/www/controllers/Logging/Step.php index ffb62dc4b..460120d7f 100644 --- a/www/controllers/Logging/Step.php +++ b/www/controllers/Logging/Step.php @@ -46,7 +46,7 @@ public function completed(string|null $message = null) $content['steps'][$name]['end'] = microtime(true); // Set duration - $content['steps'][$name]['duration'] = \Controllers\Common::convertMicrotime(microtime(true) - $content['steps'][$name]['start']); + $content['steps'][$name]['duration'] = microtime(true) - $content['steps'][$name]['start']; // Set message if any if (!empty($message)) { @@ -75,21 +75,21 @@ public function error(string $message) $content['steps'][$name]['end'] = microtime(true); // Set duration - $content['steps'][$name]['duration'] = \Controllers\Common::convertMicrotime(microtime(true) - $content['steps'][$name]['start']); + $content['steps'][$name]['duration'] = microtime(true) - $content['steps'][$name]['start']; - // Set error-message if not already set - if (empty($content['steps'][$name]['error-message'])) { - $content['steps'][$name]['error-message'] = $message; - } + // Set error-message + $content['steps'][$name]['error-message'] = 'Failed'; - // Also set latest sub step on error, unless it has 'completed' status + // Also set latest sub step on error $subStepName = array_key_last($content['steps'][$name]['substeps']); if (isset($content['steps'][$name]['substeps'][$subStepName]['status'])) { - if ($content['steps'][$name]['substeps'][$subStepName]['status'] !== 'completed') { - $content['steps'][$name]['substeps'][$subStepName]['status'] = 'error'; - $content['steps'][$name]['substeps'][$subStepName]['error-message'] = $message; - } + $content['steps'][$name]['substeps'][$subStepName]['status'] = 'error'; + $content['steps'][$name]['substeps'][$subStepName]['output'][] = [ + 'time' => microtime(true), + 'type' => 'error', + 'message' => $message + ]; } file_put_contents($this->logFile, json_encode($content)); diff --git a/www/controllers/Logging/SubStep.php b/www/controllers/Logging/SubStep.php index 5e5caba01..9f81c0258 100644 --- a/www/controllers/Logging/SubStep.php +++ b/www/controllers/Logging/SubStep.php @@ -18,6 +18,9 @@ public function new(string $identifier, array $data) 'title' => '', 'note' => '', 'status' => '', + 'start' => microtime(true), + 'end' => '', + 'duration' => '', 'output' => [] ]; @@ -53,6 +56,12 @@ public function completed(string|null $message = '') // Set status to completed $content['steps'][$name]['substeps'][$subName]['status'] = 'completed'; + // Set end date + $content['steps'][$name]['substeps'][$subName]['end'] = microtime(true); + + // Set duration + $content['steps'][$name]['substeps'][$subName]['duration'] = microtime(true) - $content['steps'][$name]['substeps'][$subName]['start']; + file_put_contents($this->logFile, json_encode($content)); unset($content); @@ -63,6 +72,8 @@ public function completed(string|null $message = '') */ public function warning(string $message) { + $this->output($message, 'warning'); + $content = $this->getContent(); // Get latest step key name @@ -74,8 +85,11 @@ public function warning(string $message) // Set status to warning $content['steps'][$name]['substeps'][$subName]['status'] = 'warning'; - // Set message - $content['steps'][$name]['substeps'][$subName]['message'] = $message; + // Set end date + $content['steps'][$name]['substeps'][$subName]['end'] = microtime(true); + + // Set duration + $content['steps'][$name]['substeps'][$subName]['duration'] = microtime(true) - $content['steps'][$name]['substeps'][$subName]['start']; file_put_contents($this->logFile, json_encode($content)); diff --git a/www/controllers/Repo/Mirror/Deb.php b/www/controllers/Repo/Mirror/Deb.php index e2353b10d..ef2657be8 100644 --- a/www/controllers/Repo/Mirror/Deb.php +++ b/www/controllers/Repo/Mirror/Deb.php @@ -42,10 +42,10 @@ private function downloadReleaseFile() * Print an error and quit if no Release file has been found */ if (!file_exists($this->workingDir . '/InRelease') and !file_exists($this->workingDir . '/Release') and !file_exists($this->workingDir . '/Release.gpg')) { - throw new Exception('No InRelease or Release file has been found in the source repository ' . $this->url . '/dists/' . $this->dist . '/ (looked for InRelease, Release and Release.gpg). Is the URL of the repository correct?', 'Release file not found'); + throw new Exception('No InRelease or Release file has been found in the source repository ' . $this->url . '/dists/' . $this->dist . '/ (looked for InRelease, Release and Release.gpg). Is the URL of the repository correct?'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -129,7 +129,7 @@ private function parseReleaseFile() $this->packagesIndicesLocation[] = array('location' => $location, 'checksum' => $checksum); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); /** * Then ignore all next Packages.xx/Sources.xx indices file from the same arch as at least one has been found @@ -143,10 +143,10 @@ private function parseReleaseFile() * If no Packages.xx/Sources.xx file has been found for this arch, throw an error */ if ($arch == 'src') { - throw new Exception('No ' . $arch . ' Sources indices file has been found in the ' . $this->validReleaseFile . ' file.', 'Cannot retrieve ' . $arch . ' Packages indices file'); + throw new Exception('No ' . $arch . ' Sources indices file has been found in the ' . $this->validReleaseFile . ' file.'); } if ($arch != 'src') { - throw new Exception('No ' . $arch . ' Packages indices file has been found in the ' . $this->validReleaseFile . ' file.', 'Cannot retrieve ' . $arch . ' Packages indices file'); + throw new Exception('No ' . $arch . ' Packages indices file has been found in the ' . $this->validReleaseFile . ' file.'); } } @@ -154,10 +154,10 @@ private function parseReleaseFile() * Throw an error if no Packages indices file location has been found */ if (empty($this->packagesIndicesLocation)) { - throw new Exception('No Packages indices file location has been found.', 'Cannot retrieve Packages indices file'); + throw new Exception('No Packages indices file location has been found.'); } if (in_array('src', $this->arch) and empty($this->sourcesIndicesLocation)) { - throw new Exception('No Sources indices file location has been found.', 'Cannot retrieve Sources indices file'); + throw new Exception('No Sources indices file location has been found.'); } /** @@ -198,10 +198,10 @@ private function parseReleaseFile() * Throw an error if no Translation file location has been found */ if (empty($this->translationsLocation)) { - throw new Exception('No Translation file location has been found. There may have no translation available for this repository.', 'Cannot retrieve translations files'); + throw new Exception('No Translation file location has been found. There may have no translation available for this repository.'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } unset($content); @@ -227,14 +227,14 @@ private function parsePackagesIndiceFile() * Download Packages.xx file using its location */ if (!$this->download($this->url . '/dists/' . $this->dist . '/' . $packageIndicesLocation, $this->workingDir . '/' . $packageIndicesName)) { - throw new Exception('Error while downloading ' . $packageIndicesName . ' indices file: ' . $this->url . '/' . $packageIndicesLocation . '', 'Could not download ' . $packageIndicesName . ' indices file'); + throw new Exception('Error while downloading ' . $packageIndicesName . ' indices file: ' . $this->url . '/' . $packageIndicesLocation . ''); } /** * Then check that the Packages.xx file's checksum matches the one that what specified in Release file */ if (!$this->checksum($this->workingDir . '/' . $packageIndicesName, $packageIndicesChecksum)) { - throw new Exception('' . $packageIndicesName . ' indices file\'s checksum does not match the checksum specified in the Release file ' . $packageIndicesChecksum, 'Could not verify Packages indices file'); + throw new Exception('' . $packageIndicesName . ' indices file\'s checksum does not match the checksum specified in the Release file ' . $packageIndicesChecksum); } /** @@ -244,14 +244,14 @@ private function parsePackagesIndiceFile() try { \Controllers\Common::gunzip($this->workingDir . '/' . $packageIndicesName); } catch (Exception $e) { - throw new Exception($e, 'Error while uncompressing ' . $packageIndicesName . ''); + throw new Exception('Error while uncompressing ' . $packageIndicesName . ''); } } if (preg_match('/.xz$/i', $packageIndicesName)) { try { \Controllers\Common::xzUncompress($this->workingDir . '/' . $packageIndicesName); } catch (Exception $e) { - throw new Exception($e, 'Error while uncompressing ' . $packageIndicesName . ''); + throw new Exception('Error while uncompressing ' . $packageIndicesName . ''); } } @@ -299,7 +299,7 @@ private function parsePackagesIndiceFile() throw new Exception('No packages found in Packages indices file'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -329,14 +329,14 @@ private function parseSourcesIndiceFile() * Download Sources file using its location */ if (!$this->download($this->url . '/dists/' . $this->dist . '/' . $sourcesIndicesLocation, $this->workingDir . '/' . $sourcesIndicesName)) { - throw new Exception('Error while downloading ' . $sourcesIndicesName . ' indices file: ' . $this->url . '/dists/' . $this->dist . '/' . $sourcesIndicesLocation . '', 'Could not download Sources indices file'); + throw new Exception('Error while downloading ' . $sourcesIndicesName . ' indices file: ' . $this->url . '/dists/' . $this->dist . '/' . $sourcesIndicesLocation . ''); } /** * Then check that the Sources.xx file's checksum matches the one that what specified in Release file */ if (!$this->checksum($this->workingDir . '/' . $sourcesIndicesName, $sourcesIndexChecksum)) { - throw new Exception('' . $sourcesIndicesName . ' indices file\'s checksum does not match the checksum specified in the Release file ' . $packageIndicesChecksum, 'Could not verify Packages indices file'); + throw new Exception('' . $sourcesIndicesName . ' indices file\'s checksum does not match the checksum specified in the Release file ' . $packageIndicesChecksum); } /** @@ -346,14 +346,14 @@ private function parseSourcesIndiceFile() try { \Controllers\Common::gunzip($this->workingDir . '/' . $sourcesIndicesName); } catch (Exception $e) { - throw new Exception($e, 'Error while uncompressing ' . $sourcesIndicesName . ''); + throw new Exception('Error while uncompressing ' . $sourcesIndicesName . ''); } } if (preg_match('/.xz$/i', $sourcesIndicesName)) { try { \Controllers\Common::xzUncompress($this->workingDir . '/' . $sourcesIndicesName); } catch (Exception $e) { - throw new Exception($e, 'Error while uncompressing ' . $sourcesIndicesName . ''); + throw new Exception('Error while uncompressing ' . $sourcesIndicesName . ''); } } @@ -457,7 +457,7 @@ private function parseSourcesIndiceFile() throw new Exception('No packages found in Sources indices file'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -496,7 +496,7 @@ private function checkReleaseGPGSignature() * If no valid Release file has been found, throw an error */ if (empty($this->validReleaseFile)) { - throw new Exception('No valid InRelease or Release file found. Please ensure that the remote repository is correctly built.', 'Release file check fail'); + throw new Exception('No valid InRelease or Release file found. Please ensure that the remote repository is correctly built.'); } return; @@ -532,7 +532,7 @@ private function checkReleaseGPGSignature() break; } catch (Exception $e) { if (DEB_INVALID_SIGNATURE == 'error') { - throw new Exception($e->getMessage(), 'GPG signature check failed'); + throw new Exception('GPG signature check failed: ' . $e->getMessage()); } if (DEB_INVALID_SIGNATURE == 'ignore') { @@ -546,7 +546,7 @@ private function checkReleaseGPGSignature() * If no valid Release file has been found, throw an error */ if (empty($this->validReleaseFile)) { - throw new Exception('No InRelease or Release file found with a valid GPG signature. Please check that you have imported the GPG key used to sign the repository.', 'GPG signature check failed'); + throw new Exception('No InRelease or Release file found with a valid GPG signature. Please check that you have imported the GPG key used to sign the repository.'); } } @@ -627,7 +627,7 @@ private function downloadDebPackages($url) */ if (!is_dir($absoluteDir)) { if (!mkdir($absoluteDir, 0770, true)) { - throw new Exception('Cannot create directory: ' . $absoluteDir . '', 'Error while creating target directory'); + throw new Exception('Cannot create directory: ' . $absoluteDir . ''); } } @@ -667,7 +667,7 @@ private function downloadDebPackages($url) * Before downloading package, check if there is enough disk space left (2GB minimum) */ if (disk_free_space(REPOS_DIR) < 2000000000) { - throw new Exception('Repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.', 'Low disk space'); + throw new Exception('Low disk space: repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.'); } /** @@ -764,7 +764,7 @@ private function downloadDebPackages($url) * Create hard link to the package */ if (!link($this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $debPackageName, $absoluteDir . '/' . $debPackageName)) { - throw new Exception('Cannot create hard link to package: ' . $this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $debPackageName, 'Error while creating hard link'); + throw new Exception('Cannot create hard link to package: ' . $this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $debPackageName); } $this->loggingSubStepController->completed('Linked to previous snapshot'); @@ -777,14 +777,14 @@ private function downloadDebPackages($url) * Download */ if (!$this->download($url . '/' . $debPackageLocation, $absoluteDir . '/' . $debPackageName, 3)) { - throw new Exception('error', 'Error while retrieving packages'); + throw new Exception('Error while downloading package'); } /** * Check that downloaded deb package's sha256 matches the sha256 specified by the Packages file */ if (!$this->checksum($absoluteDir . '/' . $debPackageName, $debPackageChecksum)) { - throw new Exception('Checksum of the downloaded package does not match the checksum indicated by the source repository metadata', 'Error while retrieving packages'); + throw new Exception('Checksum of the downloaded package does not match the checksum indicated by the source repository metadata'); } /** @@ -818,7 +818,7 @@ private function downloadDebSourcesPackages($url) */ if (!is_dir($absoluteDir)) { if (!mkdir($absoluteDir, 0770, true)) { - throw new Exception('Cannot create directory: ' . $absoluteDir . '', 'Error while creating target directory'); + throw new Exception('Cannot create directory: ' . $absoluteDir . ''); } } @@ -858,7 +858,7 @@ private function downloadDebSourcesPackages($url) * Before downloading package, check if there is enough disk space left (2GB minimum) */ if (disk_free_space(REPOS_DIR) < 2000000000) { - throw new Exception('Repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.', 'Low disk space'); + throw new Exception('Low disk space: repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.'); } /** @@ -874,14 +874,14 @@ private function downloadDebSourcesPackages($url) * Download */ if (!$this->download($url . '/' . $sourcePackageLocation, $absoluteDir . '/' . $sourcePackageName)) { - throw new Exception('error', 'Error while retrieving sources packages'); + throw new Exception('Error while doawnloading sources package'); } /** * Check that downloaded source package's md5 matches the md5sum specified by the Sources indices file */ if (md5_file($absoluteDir . '/' . $sourcePackageName) != $sourcePackageMd5) { - throw new Exception('Checksum of the file does not match ' . $sourcePackageMd5, 'Error while retrieving sources packages'); + throw new Exception('Checksum of the file does not match ' . $sourcePackageMd5); } /** @@ -932,14 +932,14 @@ private function downloadTranslation() * Download */ if (!$this->download($translationUrl, $this->workingDir . '/translations/' . $translationName)) { - throw new Exception('error', 'Error while retrieving packages'); + throw new Exception('Error while downloading translation'); } /** * Check that downloaded deb package's md5 matches the md5sum specified by the Release file */ if (md5_file($this->workingDir . '/translations/' . $translationName) != $translationMd5) { - throw new Exception('MD5 sum does not match', 'Error while retrieving packages'); + throw new Exception('Checksum of the file does not match ' . $translationMd5); } /** diff --git a/www/controllers/Repo/Mirror/Rpm.php b/www/controllers/Repo/Mirror/Rpm.php index ff730c261..3bc816e30 100644 --- a/www/controllers/Repo/Mirror/Rpm.php +++ b/www/controllers/Repo/Mirror/Rpm.php @@ -23,7 +23,7 @@ private function downloadRepomd(string $url) throw new Exception('Could not download repomd.xml'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -47,7 +47,7 @@ private function downloadPrimary(string $url) throw new Exception('primary.xml.gz checksum does not match provided checksum'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -78,7 +78,7 @@ private function downloadComps(string $url) throw new Exception('comps.xml checksum does not match provided checksum'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -181,7 +181,7 @@ private function downloadModules(string $url) } } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -276,7 +276,7 @@ private function downloadUpdateInfo(string $url) } } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } /** @@ -298,7 +298,7 @@ private function parseRepoMd() $jsonArray = json_decode(json_encode($xml), true); unset($xml); } catch (Exception $e) { - throw new Exception('Could not parse ' . $this->workingDir . '/repomd.xml: ' . $e->getMessage(), 'Could not retrieve package list'); + throw new Exception('Could not parse ' . $this->workingDir . '/repomd.xml: ' . $e->getMessage()); } gc_collect_cycles(); @@ -425,7 +425,7 @@ private function parseRepoMd() throw new Exception('Could not find location of the package list file'); } - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); unset($jsonArray, $data); } @@ -499,7 +499,7 @@ private function parsePrimaryPackagesList(string $primaryFile) $jsonArray = json_decode(json_encode($xml), true); unset($xml); } catch (Exception $e) { - throw new Exception('Could not parse ' . $primaryFile . ': ' . $e->getMessage(), 'Could not retrieve package list'); + throw new Exception('Could not parse ' . $primaryFile . ': ' . $e->getMessage()); } gc_collect_cycles(); @@ -531,7 +531,7 @@ private function parsePrimaryPackagesList(string $primaryFile) * If package checksum is not found then it can not be retrieved */ if (empty($jsonArray['package']['checksum'])) { - $this->loggingSubStepController->warning('Could not find checksum value for package ' . $packageLocation); + throw new Exception('Could not find checksum value for package ' . $packageLocation); $error++; } else { $packageChecksum = $jsonArray['package']['checksum']; @@ -566,7 +566,7 @@ private function parsePrimaryPackagesList(string $primaryFile) * If package arch is not found then it can not be retrieved */ if (empty($data['arch'])) { - throw new Exception('Could not find architecture value for package ' . $packageLocation . ' in primary.xml file', 'Could not find architecture for package'); + throw new Exception('Could not find architecture value for package ' . $packageLocation . ' in primary.xml file'); } $packageArch = $data['arch']; @@ -575,7 +575,7 @@ private function parsePrimaryPackagesList(string $primaryFile) * If package checksum is not found then it can not be retrieved */ if (empty($data['checksum'])) { - throw new Exception('Could not find checksum value for package ' . $packageLocation . ' in primary.xml file', 'Could not find checksum for package'); + throw new Exception('Could not find checksum value for package ' . $packageLocation . ' in primary.xml file'); } $packageChecksum = $data['checksum']; @@ -599,7 +599,7 @@ private function parsePrimaryPackagesList(string $primaryFile) * Print OK if there was no warning */ if ($error == 0) { - $this->loggingSubStepController->completed('Done'); + $this->loggingSubStepController->completed(); } unset($jsonArray, $data); @@ -666,7 +666,7 @@ private function downloadRpmPackages(string $url) * Before downloading package, check if there is enough disk space left (2GB minimum) */ if (disk_free_space(REPOS_DIR) < 2000000000) { - throw new Exception('Repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.', 'Low disk space'); + throw new Exception('Low disk space: repository storage has reached 2GB (minimum) of free space left. Task automatically stopped.'); } /** @@ -717,14 +717,14 @@ private function downloadRpmPackages(string $url) * Check that package architecture is valid */ if (!in_array($rpmPackageArch, RPM_ARCHS)) { - throw new Exception('Package architecture is not valid: ' . $rpmPackageArch . ' for package: ' . $rpmPackageLocation, 'Package architecture is not valid'); + throw new Exception('Invalid package architecture: ' . $rpmPackageArch . ' for package ' . $rpmPackageLocation); } /** * If no package arch has been found when parsing primary.xml file, throw an error */ if (empty($rpmPackageArch)) { - throw new Exception('An empty package architecture has been retrieved from distant repository metadata for package: ' . $rpmPackageLocation, 'Package architecture is not valid'); + throw new Exception('Invalid package architecture: an empty package architecture has been retrieved from distant repository metadata for package ' . $rpmPackageLocation); } /** @@ -750,7 +750,7 @@ private function downloadRpmPackages(string $url) */ if (!is_dir($absoluteDir)) { if (!mkdir($absoluteDir, 0770, true)) { - throw new Exception('Cannot create directory: ' . $absoluteDir, 'Error while creating target directory'); + throw new Exception('Cannot create directory: ' . $absoluteDir); } } @@ -773,7 +773,7 @@ private function downloadRpmPackages(string $url) * Create hard link to the package */ if (!link($this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $rpmPackageName, $absoluteDir . '/' . $rpmPackageName)) { - throw new Exception('Cannot create hard link to package: ' . $this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $rpmPackageName, 'Error while creating hard link'); + throw new Exception('Cannot create hard link to package: ' . $this->previousSnapshotDirPath . '/' . $relativeDir . '/' . $rpmPackageName); } $this->loggingSubStepController->completed('Linked to previous snapshot'); @@ -786,14 +786,14 @@ private function downloadRpmPackages(string $url) * Download package if it does not already exist */ if (!$this->download($url . '/' . $rpmPackageLocation, $absoluteDir . '/' . $rpmPackageName, 3)) { - throw new Exception('error', 'Error while retrieving packages'); + throw new Exception('Error while downloading package'); } /** * Check that downloaded rpm package matches the checksum specified by the primary.xml file */ if (!$this->checksum($absoluteDir . '/' . $rpmPackageName, $rpmPackageChecksum)) { - throw new Exception('Checksum of the downloaded package does not match the checksum indicated by the source repository metadata (tested sha512, sha256 and sha1)', 'Error while retrieving packages'); + throw new Exception('Checksum of the downloaded package does not match the checksum indicated by the source repository metadata (tested sha512, sha256 and sha1)'); } /** @@ -810,7 +810,7 @@ private function downloadRpmPackages(string $url) * Throw an error if there are no known GPG public keys because it is impossible to check for signature then */ if (empty($knownPublicKeys)) { - throw new Exception('Cannot check for signature because there is no GPG public keys imported in Repomanager\'s keyring', 'Cannot check packages signature'); + throw new Exception('Cannot check for package signature because there is no GPG public keys imported in Repomanager\'s keyring'); } /** @@ -833,7 +833,7 @@ private function downloadRpmPackages(string $url) * If RPM_MISSING_SIGNATURE is set to 'error', then throw an error */ if (RPM_MISSING_SIGNATURE == 'error') { - throw new Exception('This package has no GPG signature (GPG signing key ID not found in the package header)', 'GPG signature check failed'); + throw new Exception('This package has no GPG signature (GPG signing key ID not found in the package header)'); } /** @@ -846,7 +846,7 @@ private function downloadRpmPackages(string $url) * Delete package */ if (!unlink($absoluteDir . '/' . $rpmPackageName)) { - throw new Exception('Error while deleting package ' . $absoluteDir. '/' . $rpmPackageName . '', 'Error while deleting package'); + throw new Exception('Error while deleting package ' . $absoluteDir. '/' . $rpmPackageName . ''); } continue; @@ -890,7 +890,7 @@ private function downloadRpmPackages(string $url) * If RPM_INVALID_SIGNATURE is set to 'error', then throw an error */ if (RPM_INVALID_SIGNATURE == 'error') { - throw new Exception('GPG signature check failed (unknown GPG signing key ID: ' . $keyId . ')', 'GPG signature check failed'); + throw new Exception('GPG signature check failed (unknown GPG signing key ID: ' . $keyId . ')'); } /** @@ -903,7 +903,7 @@ private function downloadRpmPackages(string $url) * Delete package */ if (!unlink($absoluteDir. '/' . $rpmPackageName)) { - throw new Exception('Error while deleting package ' . $absoluteDir. '/' . $rpmPackageName . '', 'Error while deleting package'); + throw new Exception('Error while deleting package ' . $absoluteDir. '/' . $rpmPackageName . ''); } continue; @@ -1056,16 +1056,18 @@ public function mirror() $errorUrlsString .= '

Error details: ' . $errorUrl['error'] . '

'; } - throw new Exception('No reachable URL found. The source repository URL might be incorrect, unreachable, require SSL authentication, has IP filtering or is non-existent. Tested URLs:
' . $errorUrlsString, 'No reachable URL found'); + throw new Exception('No reachable URL found. The source repository URL might be incorrect, unreachable, require SSL authentication, has IP filtering or is non-existent. Tested URLs:
' . $errorUrlsString); } /** * If there was no error, print the URLs that will be used to retrieve packages */ foreach ($this->archUrls as $url) { - $this->loggingSubStepController->output('retrieve-metadata', ' 🠶 ' . $url . ''); + $this->loggingSubStepController->output(' 🠶 ' . $url . ''); } + $this->loggingSubStepController->completed(); + /** * Retrieve packages for each URLs */ diff --git a/www/controllers/Task/Repo/Create.php b/www/controllers/Task/Repo/Create.php index 5f790b0fb..576b8f09e 100644 --- a/www/controllers/Task/Repo/Create.php +++ b/www/controllers/Task/Repo/Create.php @@ -177,13 +177,13 @@ private function mirror() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** @@ -395,13 +395,13 @@ private function local() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/Delete.php b/www/controllers/Task/Repo/Delete.php index a6e315472..669ead598 100644 --- a/www/controllers/Task/Repo/Delete.php +++ b/www/controllers/Task/Repo/Delete.php @@ -160,13 +160,13 @@ public function execute() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (\Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/Duplicate.php b/www/controllers/Task/Repo/Duplicate.php index bc426185d..35f288d62 100644 --- a/www/controllers/Task/Repo/Duplicate.php +++ b/www/controllers/Task/Repo/Duplicate.php @@ -288,13 +288,13 @@ public function execute() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/Env.php b/www/controllers/Task/Repo/Env.php index 7878fadbf..7bb212b29 100644 --- a/www/controllers/Task/Repo/Env.php +++ b/www/controllers/Task/Repo/Env.php @@ -340,13 +340,13 @@ public function execute() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/Rebuild.php b/www/controllers/Task/Repo/Rebuild.php index 2b066d07e..ce23cc005 100644 --- a/www/controllers/Task/Repo/Rebuild.php +++ b/www/controllers/Task/Repo/Rebuild.php @@ -124,13 +124,13 @@ public function execute() // Set snapshot metadata rebuild state in database $this->repo->snapSetRebuild($this->repo->getSnapId(), 'failed'); - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/RemoveEnv.php b/www/controllers/Task/Repo/RemoveEnv.php index 199db35c2..963f13c7f 100644 --- a/www/controllers/Task/Repo/RemoveEnv.php +++ b/www/controllers/Task/Repo/RemoveEnv.php @@ -125,13 +125,13 @@ public function execute() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (\Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error $this->task->setStatus('error'); $this->task->updateStatus($this->task->getId(), 'error'); - $this->task->setError($e->getMessage()); + $this->task->setError('Failed'); } /** diff --git a/www/controllers/Task/Repo/Update.php b/www/controllers/Task/Repo/Update.php index ff93d1e29..dc4e9939f 100644 --- a/www/controllers/Task/Repo/Update.php +++ b/www/controllers/Task/Repo/Update.php @@ -15,7 +15,6 @@ class Update private $sourceRepo; private $repo; private $task; - // private $loggingController; private $loggingStepController; private $packagesToSign = null; @@ -24,7 +23,6 @@ public function __construct(string $taskId) $this->sourceRepo = new \Controllers\Repo\Repo(); $this->repo = new \Controllers\Repo\Repo(); $this->task = new \Controllers\Task\Task(); - // $this->loggingController = new \Controllers\Logging\Logging($taskId); $this->loggingStepController = new \Controllers\Logging\Step($taskId); $this->loggingSubStepController = new \Controllers\Logging\SubStep($taskId); @@ -101,11 +99,6 @@ public function __construct(string $taskId) */ $this->task->generatePid(); - /** - * Generate log file - */ - // $this->loggingController->generate(); - /** * Set PID */ @@ -159,7 +152,7 @@ public function execute() $this->task->setStatus('done'); $this->task->updateStatus($this->task->getId(), 'done'); } catch (Exception $e) { - // Set stop error message + // Set step error message $this->loggingStepController->error($e->getMessage()); // Set task status to error diff --git a/www/controllers/Task/Task.php b/www/controllers/Task/Task.php index 43d5408ab..ee6057f04 100644 --- a/www/controllers/Task/Task.php +++ b/www/controllers/Task/Task.php @@ -489,7 +489,6 @@ public function execute(array $tasksParams) */ public function executeId(int $id) { - // TODO debug $myprocess = new \Controllers\Process('/usr/bin/php ' . ROOT . '/tasks/execute.php --id="' . $id . '" >/dev/null 2>/dev/null &'); $myprocess->execute(); $myprocess->close(); diff --git a/www/public/resources/styles/run.css b/www/public/resources/styles/run.css index e492fbb94..237c84a6e 100644 --- a/www/public/resources/styles/run.css +++ b/www/public/resources/styles/run.css @@ -138,4 +138,14 @@ column-gap: 10px; padding: 20px; border-radius: 8px; +} + +.task-sub-step-container { + display: grid; + grid-template-columns: minmax(20px, 20px) auto; + column-gap: 10px; + border: 1px solid #24405c; + padding: 10px; + margin-bottom: 10px; + border-radius: 8px; } \ No newline at end of file diff --git a/www/views/includes/containers/header/menu.inc.php b/www/views/includes/containers/header/menu.inc.php index 9542eb357..62fe5c31f 100644 --- a/www/views/includes/containers/header/menu.inc.php +++ b/www/views/includes/containers/header/menu.inc.php @@ -17,7 +17,7 @@
-
+
REPOSITORIES
@@ -37,7 +37,7 @@
-
+
TASKS
@@ -125,7 +125,7 @@ if (MANAGE_HOSTS == "true") : ?>
@@ -49,7 +70,7 @@ $substep) : $status = $substep['status']; ?> -
+
'; + } + + if ($status == 'error') { + echo ''; } ?>
-
-
+
+
+
- ' . $substep['note'] . '

'; - } + ' . $substep['note'] . '

'; + } - if (!empty($substep['output'])) { - foreach ($substep['output'] as $outputDetails) { - $time = $outputDetails['time']; - $type = $outputDetails['type']; - $message = $outputDetails['message']; + if (!empty($substep['output'])) { + foreach ($substep['output'] as $outputDetails) { + $time = $outputDetails['time']; + $type = $outputDetails['type']; + $message = $outputDetails['message']; - if ($type == 'info') { - echo '

' . $message . '

'; - } + if ($type == 'info') { + echo '

' . $message . '

'; + } + + if ($type == 'warning') { + echo '

' . $message . '

'; + } + + if ($type == 'error') { + echo '

' . $message . '

'; + } - if ($type == 'pre') { - echo '
' . $message . '
'; + if ($type == 'pre') { + echo '
' . $message . '
'; + } } + } ?> +
+ +
+ + + // Calculate start time + if (!empty($substep['start'])) { + $startTime = \Controllers\Common::microtimeToTime($substep['start']); + } + + echo '

'; + + if (!empty($startTime)) { + echo $startTime; + } + + if (!empty($duration)) { + echo ' - took ' . $duration; + } + + echo '

'; ?> +