diff --git a/README.md b/README.md index ce97220..a6039c4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ inherits Operator access, and Operator access inherits View access on each reque this does not add stored grants to users or groups. Plugin settings also require HPC Scheduler Admin access in addition to Cacti's Settings permission. -Cacti device permissions still limit the rows and actions available to each user; unmapped objects require an administrator. +Cacti device permissions still limit the rows and actions available to each user; a cluster without a device is listed on the administrative pages for every user with the plugin realm, but not in the operator views, which list only clusters mapped to a device. Credentials, configuration, mapping, deletion and other administrative changes remain in the administrative pages. Acknowledgments last only in the current user's session, for at most one hour and only while the same observation remains diff --git a/docs/i18n/ar-SA/README.md b/docs/i18n/ar-SA/README.md index 5ebd5ed..b375c1d 100644 --- a/docs/i18n/ar-SA/README.md +++ b/docs/i18n/ar-SA/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](README.md) @@ -24,7 +24,7 @@ بعد نسخ ملفات الترقية، افتح صفحة الإضافات بصفتك مسؤولًا لتسجيل نطاق الأذونات الجديد. امنح نطاق Operator صراحةً ضمن **الإعداد > المستخدمون** أو مجموعات المستخدمين. تحتفظ الترقيات بمعرّفات نطاقي View وAdmin ومنحهما الحالي. يرث Admin وصول Operator ويرث Operator وصول View في كل طلب؛ ولا يضيف ذلك منحًا مخزّنة للمستخدمين أو المجموعات. تتطلب إعدادات الإضافة أيضًا HPC Scheduler Admin بالإضافة إلى إذن الإعدادات في Cacti. -تظل أذونات أجهزة Cacti تقيّد الصفوف والإجراءات المتاحة لكل مستخدم؛ وتتطلب الكائنات غير المرتبطة مسؤولًا. تبقى بيانات الاعتماد والإعدادات والربط والحذف والتغييرات الإدارية الأخرى في الصفحات الإدارية. لا تستمر الإقرارات إلا في جلسة المستخدم الحالي، لمدة ساعة على الأكثر وفقط ما دامت الملاحظة نفسها حديثة. تُبطلها الملاحظات الجديدة أو المعدّلة. ولا تجعل قياسًا فاشلًا سليمًا أو تكبح التنبيهات مطلقًا. +تظل أذونات أجهزة Cacti تقيّد الصفوف والإجراءات المتاحة لكل مستخدم؛ ويظهر العنقود الذي ليس له جهاز في الصفحات الإدارية لكل مستخدم يملك نطاق أذونات الإضافة، لكنه لا يظهر في صفحات العمليات التي تعرض فقط العناقيد المرتبطة بجهاز. تبقى بيانات الاعتماد والإعدادات والربط والحذف والتغييرات الإدارية الأخرى في الصفحات الإدارية. لا تستمر الإقرارات إلا في جلسة المستخدم الحالي، لمدة ساعة على الأكثر وفقط ما دامت الملاحظة نفسها حديثة. تُبطلها الملاحظات الجديدة أو المعدّلة. ولا تجعل قياسًا فاشلًا سليمًا أو تكبح التنبيهات مطلقًا. ## ملاحظات المشغّل للمعلم 2 diff --git a/docs/i18n/es-419/README.md b/docs/i18n/es-419/README.md index 779fe46..620b805 100644 --- a/docs/i18n/es-419/README.md +++ b/docs/i18n/es-419/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](README.md) | [العربية](../ar-SA/README.md) @@ -24,7 +24,7 @@ Este proyecto es independiente y no está afiliado al proyecto Cacti. Después de copiar los archivos de actualización, abra la página Complementos como administrador para registrar el nuevo permiso. Asigne expresamente Operator en **Configuración > Usuarios** o en los grupos de usuarios. Las actualizaciones conservan los identificadores y las concesiones de View y Admin. En cada petición, Admin hereda el acceso Operator y Operator hereda View; esto no añade concesiones almacenadas a usuarios ni grupos. Los ajustes del complemento también requieren HPC Scheduler Admin, además del permiso Ajustes de Cacti. -Los permisos de dispositivos de Cacti siguen limitando las filas y acciones disponibles para cada usuario; los objetos sin asociación requieren un administrador. Credenciales, configuración, asociaciones, eliminación y otros cambios administrativos permanecen en las páginas administrativas. Los acuses solo duran en la sesión del usuario actual, como máximo una hora y mientras la misma observación siga vigente. Las observaciones nuevas o modificadas los invalidan. Nunca marcan como correcta una medición fallida ni suprimen alertas. +Los permisos de dispositivos de Cacti siguen limitando las filas y acciones disponibles para cada usuario; un clúster sin dispositivo aparece en las páginas administrativas para todo usuario con el permiso del complemento, pero no en las páginas de operaciones, que solo muestran los clústeres asociados a un dispositivo. Credenciales, configuración, asociaciones, eliminación y otros cambios administrativos permanecen en las páginas administrativas. Los acuses solo duran en la sesión del usuario actual, como máximo una hora y mientras la misma observación siga vigente. Las observaciones nuevas o modificadas los invalidan. Nunca marcan como correcta una medición fallida ni suprimen alertas. ## Notas para operadores del hito 2 diff --git a/docs/i18n/es-ES/README.md b/docs/i18n/es-ES/README.md index a51d1d1..af525b0 100644 --- a/docs/i18n/es-ES/README.md +++ b/docs/i18n/es-ES/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -24,7 +24,7 @@ Este proyecto es independiente y no está afiliado al proyecto Cacti. Después de copiar los archivos de actualización, abra la página Complementos como administrador para registrar el nuevo permiso. Asigne expresamente Operator en **Configuración > Usuarios** o en los grupos de usuarios. Las actualizaciones conservan los identificadores y las concesiones de View y Admin. En cada petición, Admin hereda el acceso Operator y Operator hereda View; esto no añade concesiones almacenadas a usuarios ni grupos. Los ajustes del complemento también requieren HPC Scheduler Admin, además del permiso Ajustes de Cacti. -Los permisos de dispositivos de Cacti siguen limitando las filas y acciones disponibles para cada usuario; los objetos sin asociación requieren un administrador. Credenciales, configuración, asociaciones, eliminación y otros cambios administrativos permanecen en las páginas administrativas. Los acuses solo duran en la sesión del usuario actual, como máximo una hora y mientras la misma observación siga vigente. Las observaciones nuevas o modificadas los invalidan. Nunca marcan como correcta una medición fallida ni suprimen alertas. +Los permisos de dispositivos de Cacti siguen limitando las filas y acciones disponibles para cada usuario; un clúster sin dispositivo aparece en las páginas administrativas para todo usuario con el permiso del complemento, pero no en las páginas de operaciones, que solo muestran los clústeres asociados a un dispositivo. Credenciales, configuración, asociaciones, eliminación y otros cambios administrativos permanecen en las páginas administrativas. Los acuses solo duran en la sesión del usuario actual, como máximo una hora y mientras la misma observación siga vigente. Las observaciones nuevas o modificadas los invalidan. Nunca marcan como correcta una medición fallida ni suprimen alertas. ## Notas para operadores del hito 2 diff --git a/docs/i18n/hi-IN/README.md b/docs/i18n/hi-IN/README.md index 5e52222..72e7888 100644 --- a/docs/i18n/hi-IN/README.md +++ b/docs/i18n/hi-IN/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -24,7 +24,7 @@ अपग्रेड फ़ाइलें कॉपी करने के बाद नया अनुमति क्षेत्र दर्ज करने के लिए व्यवस्थापक के रूप में प्लगइन पृष्ठ खोलें। **कॉन्फ़िगरेशन > उपयोगकर्ता** या उपयोगकर्ता समूहों में Operator अनुमति स्पष्ट रूप से दें। अपग्रेड मौजूदा View और Admin क्षेत्र के ID और अनुदान सुरक्षित रखते हैं। हर अनुरोध में Admin को Operator और Operator को View पहुँच विरासत में मिलती है; इससे उपयोगकर्ता या समूह में संग्रहीत अनुदान नहीं जुड़ते। प्लगइन सेटिंग के लिए Cacti की Settings अनुमति के अतिरिक्त HPC Scheduler Admin भी आवश्यक है। -Cacti डिवाइस अनुमतियाँ अब भी हर उपयोगकर्ता के लिए उपलब्ध पंक्तियाँ और कार्रवाइयाँ सीमित करती हैं; अनमैप ऑब्जेक्ट के लिए व्यवस्थापक चाहिए। क्रेडेंशियल, कॉन्फ़िगरेशन, मैपिंग, हटाना और अन्य प्रशासनिक बदलाव प्रशासनिक पृष्ठों में ही रहते हैं। पुष्टि केवल वर्तमान उपयोगकर्ता के सत्र में, अधिकतम एक घंटे तक और उसी अवलोकन के ताज़ा रहने तक रहती है। नए या बदले अवलोकन उसे अमान्य कर देते हैं। यह कभी विफल माप को स्वस्थ नहीं बताती या अलर्ट नहीं दबाती। +Cacti डिवाइस अनुमतियाँ अब भी हर उपयोगकर्ता के लिए उपलब्ध पंक्तियाँ और कार्रवाइयाँ सीमित करती हैं; डिवाइस के बिना क्लस्टर प्रशासनिक पृष्ठों पर प्लगइन अनुमति क्षेत्र वाले हर उपयोगकर्ता को दिखता है, पर संचालन पृष्ठों में नहीं; वे केवल डिवाइस से मैप किए गए क्लस्टर सूचीबद्ध करते हैं। क्रेडेंशियल, कॉन्फ़िगरेशन, मैपिंग, हटाना और अन्य प्रशासनिक बदलाव प्रशासनिक पृष्ठों में ही रहते हैं। पुष्टि केवल वर्तमान उपयोगकर्ता के सत्र में, अधिकतम एक घंटे तक और उसी अवलोकन के ताज़ा रहने तक रहती है। नए या बदले अवलोकन उसे अमान्य कर देते हैं। यह कभी विफल माप को स्वस्थ नहीं बताती या अलर्ट नहीं दबाती। ## माइलस्टोन 2 के लिए ऑपरेटर टिप्पणियाँ diff --git a/docs/i18n/zh-CN/README.md b/docs/i18n/zh-CN/README.md index ed12d1a..59ac963 100644 --- a/docs/i18n/zh-CN/README.md +++ b/docs/i18n/zh-CN/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -24,7 +24,7 @@ 复制升级文件后,以管理员身份打开插件页面,注册新权限域。在**配置 > 用户**或用户组中明确授予 Operator 权限域。升级保留现有 View 和 Admin 权限域的 ID 及授权。每次请求时,Admin 继承 Operator 访问权限,Operator 继承 View 访问权限;这不会向用户或组添加持久化授权。插件设置除需要 Cacti 的设置权限外,还需要 HPC Scheduler Admin 权限。 -Cacti 设备权限仍限制每位用户可访问的行和操作;未映射对象需要管理员处理。凭据、配置、映射、删除和其他管理更改仍在管理页面中执行。确认记录仅在当前用户会话中有效,最多一小时,并且仅在同一观测结果仍然新鲜时有效。新出现或更改的观测结果会使确认失效。确认绝不会将失败的测量标记为健康,也不会抑制告警。 +Cacti 设备权限仍限制每位用户可访问的行和操作;没有设备的集群会列在管理页面上,所有拥有插件权限域的用户都能看到,但不会出现在运维页面中,运维页面只列出已映射到设备的集群。凭据、配置、映射、删除和其他管理更改仍在管理页面中执行。确认记录仅在当前用户会话中有效,最多一小时,并且仅在同一观测结果仍然新鲜时有效。新出现或更改的观测结果会使确认失效。确认绝不会将失败的测量标记为健康,也不会抑制告警。 ## 里程碑 2 操作员说明 diff --git a/hpcsched_clusters.php b/hpcsched_clusters.php index 82fdf99..1814ab4 100644 --- a/hpcsched_clusters.php +++ b/hpcsched_clusters.php @@ -99,7 +99,11 @@ function hpcsched_cluster_request(\Somethingwithproof\Hpcsched\ClusterRepository case 'enable': case 'disable': $hpcsched_cluster = hpcsched_cluster_request($hpcsched_clusters, $hpcsched_access); - $hpcsched_clusters->setState($hpcsched_cluster->id, $hpcsched_action === 'enable' ? \Somethingwithproof\Hpcsched\AdminState::Enabled : \Somethingwithproof\Hpcsched\AdminState::Disabled); + + if (!$hpcsched_clusters->setState($hpcsched_cluster->id, $hpcsched_action === 'enable' ? \Somethingwithproof\Hpcsched\AdminState::Enabled : \Somethingwithproof\Hpcsched\AdminState::Disabled)) { + raise_message('hpcsched_state', __('The cluster state was not changed: the write failed. See the Cacti log.', 'hpcsched'), MESSAGE_LEVEL_ERROR); + } + header('Location: hpcsched_clusters.php'); exit; case 'delete': @@ -130,6 +134,8 @@ function hpcsched_cluster_request(\Somethingwithproof\Hpcsched\ClusterRepository } elseif ($hpcsched_cluster->hostId > 0 && !$hpcsched_access->orphaned($hpcsched_cluster)) { $hpcsched_devices->attach($hpcsched_cluster->id, $hpcsched_cluster->hostId, $hpcsched_graphs); raise_message('hpcsched_device', __('Missing graphs were added.', 'hpcsched'), MESSAGE_LEVEL_INFO); + } else { + raise_message('hpcsched_device', __('No graphs were added: the cluster has no device, or its device no longer exists.', 'hpcsched'), MESSAGE_LEVEL_ERROR); } header('Location: ' . $hpcsched_back); @@ -142,8 +148,29 @@ function hpcsched_cluster_request(\Somethingwithproof\Hpcsched\ClusterRepository exit; case 'reindex_device': $hpcsched_cluster = hpcsched_cluster_request($hpcsched_clusters, $hpcsched_access); - $hpcsched_devices->reindex($hpcsched_cluster->hostId); - raise_message('hpcsched_device', __('The partitions were reindexed from the snapshot.', 'hpcsched'), MESSAGE_LEVEL_INFO); + $hpcsched_result = $hpcsched_cluster->hostId > 0 && !$hpcsched_access->orphaned($hpcsched_cluster) ? $hpcsched_devices->reindex($hpcsched_cluster->hostId) : \Somethingwithproof\Hpcsched\ReindexResult::NotRun; + + switch ($hpcsched_result) { + case \Somethingwithproof\Hpcsched\ReindexResult::Completed: + raise_message('hpcsched_device', __('The partitions were reindexed from the snapshot.', 'hpcsched'), MESSAGE_LEVEL_INFO); + break; + case \Somethingwithproof\Hpcsched\ReindexResult::Skipped: + raise_message('hpcsched_device', __('The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query.', 'hpcsched'), MESSAGE_LEVEL_ERROR); + break; + case \Somethingwithproof\Hpcsched\ReindexResult::Failed: + raise_message('hpcsched_device', __('The partitions were not reindexed: Cacti could not run the data query. See the Cacti log.', 'hpcsched'), MESSAGE_LEVEL_ERROR); + break; + case \Somethingwithproof\Hpcsched\ReindexResult::NoQuery: + raise_message('hpcsched_device', __('The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page.', 'hpcsched'), MESSAGE_LEVEL_ERROR); + break; + default: + raise_message( + 'hpcsched_device', + __('The partitions were not reindexed: the cluster has no device, or its device no longer exists.', 'hpcsched'), + MESSAGE_LEVEL_ERROR + ); + } + header('Location: hpcsched_clusters.php?action=device&id=' . $hpcsched_cluster->id); exit; case 'device': diff --git a/lib/CactiObjectRepository.php b/lib/CactiObjectRepository.php index 1069c81..5eb82d1 100644 --- a/lib/CactiObjectRepository.php +++ b/lib/CactiObjectRepository.php @@ -78,6 +78,17 @@ public function device(int $hostId): ?array { return ['id' => Row::int($row, 'id', 0, 1), 'description' => Row::string($row, 'description'), 'poller_id' => Row::int($row, 'poller_id', 1, 1)]; } + /** + * Whether Cacti's run_data_query() skips this device: it returns true + * without running the query for a disabled device or one that is down + * (HOST_DOWN is 1). + */ + public function queriesSkipped(int $hostId): bool { + $row = Row::one(db_fetch_row_prepared('SELECT status, disabled FROM host WHERE id = ?', [$hostId], true, $this->connection)); + + return $row !== null && (Row::int($row, 'status', 0, 1) === 1 || Row::string($row, 'disabled') === 'on'); + } + /** * Devices a cluster may be mapped to: every device not already mapped. * diff --git a/lib/ClusterRepository.php b/lib/ClusterRepository.php index 1e0c4b7..f625f8f 100644 --- a/lib/ClusterRepository.php +++ b/lib/ClusterRepository.php @@ -132,8 +132,8 @@ public function save(ClusterInput $input): int { return $ok && db_affected_rows($this->connection) === 1 ? $input->id : 0; } - public function setState(int $id, AdminState $state): void { - db_execute_prepared('UPDATE plugin_hpcsched_cluster SET admin_state = ?, updated_at = GREATEST(updated_at + 1, ?) WHERE id = ?', [$state->value, $this->clock->now(), $id], true, $this->connection); + public function setState(int $id, AdminState $state): bool { + return db_execute_prepared('UPDATE plugin_hpcsched_cluster SET admin_state = ?, updated_at = GREATEST(updated_at + 1, ?) WHERE id = ?', [$state->value, $this->clock->now(), $id], true, $this->connection) !== false; } public function delete(int $id): bool { diff --git a/lib/DeviceProvisioner.php b/lib/DeviceProvisioner.php index e1e4164..460ff91 100644 --- a/lib/DeviceProvisioner.php +++ b/lib/DeviceProvisioner.php @@ -194,7 +194,7 @@ public function attach(int $clusterId, int $hostId, bool $partitionGraphs): void /** * Run Cacti's reindex when the device's partition indexes differ from * the snapshot's, which Cacti's own index count check misses for a - * renamed partition (ADR 0011). Returns whether a reindex ran. + * renamed partition (ADR 0011). Returns whether a reindex completed. */ public function reindexIfChanged(Cluster $cluster): bool { $queryId = $this->objects->queryId(); @@ -207,18 +207,39 @@ public function reindexIfChanged(Cluster $cluster): bool { return false; } - $this->reindex($cluster->hostId); - - return true; + return $this->reindex($cluster->hostId) === ReindexResult::Completed; } - public function reindex(int $hostId): void { + /** + * Cacti returns true for a query it skips on a disabled or down device + * and false when it fails, so the device state is read before the call + * and again after it: run_data_query() reads the state itself, and a + * device disabled in between would otherwise be reported as completed. + * The core call gives no other signal, so the check narrows that window + * without closing it. + */ + public function reindex(int $hostId): ReindexResult { + if ($hostId <= 0) { + return ReindexResult::NotRun; + } + $queryId = $this->objects->queryId(); - if ($hostId > 0 && $queryId > 0) { - $this->includeCore(); - run_data_query($hostId, $queryId); + if ($queryId <= 0) { + return ReindexResult::NoQuery; } + + if ($this->objects->queriesSkipped($hostId)) { + return ReindexResult::Skipped; + } + + $this->includeCore(); + + if (run_data_query($hostId, $queryId) === false) { + return ReindexResult::Failed; + } + + return $this->objects->queriesSkipped($hostId) ? ReindexResult::Skipped : ReindexResult::Completed; } public function description(Cluster $cluster): string { diff --git a/lib/Reader.php b/lib/Reader.php index 8ae28cc..b4ffe35 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -54,6 +54,13 @@ public function run(Cluster $cluster, int $pollerInterval): ClusterRun { try { return $this->runLeased($cluster, $budget, $interval); + } catch (DatabaseError $e) { + // The lease is still held here, so the failure can be recorded + // for the health page before the caller logs it and exits. + $now = $this->clock->now(); + $this->runs->finish(new ClusterRun($cluster->id, finishedAt: $now, outcome: RunOutcome::Failed, error: ErrorClass::Failed, lastFailure: $now), $this->holder); + + throw $e; } finally { $this->runs->release($cluster->id, $this->holder); } diff --git a/lib/ReindexResult.php b/lib/ReindexResult.php new file mode 100644 index 0000000..403a901 --- /dev/null +++ b/lib/ReindexResult.php @@ -0,0 +1,38 @@ + + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This file is part of plugin_hpcsched, a plugin for Cacti. + * https://github.com/somethingwithproof/plugin_hpcsched + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + + +namespace Somethingwithproof\Hpcsched; + +/** + * What a reindex request did. Cacti's run_data_query() returns true for a + * query it skips because the device is disabled or down, so the skip is + * detected from the device row before the call. + */ +enum ReindexResult { + /** No device to reindex. */ + case NotRun; + /** The plugin's data query does not exist yet. */ + case NoQuery; + /** The device is disabled or down, so Cacti skipped the query. */ + case Skipped; + /** Cacti ran the query and reported failure, for example a silent remote collector. */ + case Failed; + case Completed; +} diff --git a/locales/LC_MESSAGES/ar-SA.mo b/locales/LC_MESSAGES/ar-SA.mo index b5b3317..e734a0f 100644 Binary files a/locales/LC_MESSAGES/ar-SA.mo and b/locales/LC_MESSAGES/ar-SA.mo differ diff --git a/locales/LC_MESSAGES/es-419.mo b/locales/LC_MESSAGES/es-419.mo index 5fa8f96..dcd2931 100644 Binary files a/locales/LC_MESSAGES/es-419.mo and b/locales/LC_MESSAGES/es-419.mo differ diff --git a/locales/LC_MESSAGES/es-ES.mo b/locales/LC_MESSAGES/es-ES.mo index 5819c90..1177119 100644 Binary files a/locales/LC_MESSAGES/es-ES.mo and b/locales/LC_MESSAGES/es-ES.mo differ diff --git a/locales/LC_MESSAGES/hi-IN.mo b/locales/LC_MESSAGES/hi-IN.mo index 4595769..65699d2 100644 Binary files a/locales/LC_MESSAGES/hi-IN.mo and b/locales/LC_MESSAGES/hi-IN.mo differ diff --git a/locales/LC_MESSAGES/zh-CN.mo b/locales/LC_MESSAGES/zh-CN.mo index d055482..3e7b8d7 100644 Binary files a/locales/LC_MESSAGES/zh-CN.mo and b/locales/LC_MESSAGES/zh-CN.mo differ diff --git a/locales/po/ar-SA.po b/locales/po/ar-SA.po index fcc9892..ec99985 100644 --- a/locales/po/ar-SA.po +++ b/locales/po/ar-SA.po @@ -30,6 +30,10 @@ msgstr "لم يُحفظ العنقود: غيّره شخص آخر منذ فتح msgid "The cluster was saved." msgstr "حُفظ العنقود." +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "لم تتغير حالة العنقود: فشلت الكتابة. راجع سجل Cacti." + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "حُذف العنقود ولقطته المؤقتة. احتُفظ بجهازه ورسومه. لم يُتصل بالمُجدول." @@ -54,6 +58,10 @@ msgstr "لم يُربط العنقود: الجهاز غير موجود، أو ل msgid "Missing graphs were added." msgstr "أُضيفت الرسوم المفقودة." +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "لم تُضف رسوم بيانية: ليس للعنقود جهاز، أو لم يعد جهازه موجودًا." + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "لم يُفك ربط العنقود: غيّره شخص آخر منذ فتح الصفحة." @@ -66,6 +74,22 @@ msgstr "فُك ربط العنقود. احتُفظ بالجهاز ورسومه." msgid "The partitions were reindexed from the snapshot." msgstr "أُعيدت فهرسة الأقسام من اللقطة." +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "لم تُعد فهرسة الأقسام: الجهاز معطّل أو متوقف، لذلك تخطّى Cacti استعلام بياناته." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "لم تُعد فهرسة الأقسام: تعذّر على Cacti تشغيل استعلام البيانات. راجع سجل Cacti." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "لم تُعد فهرسة الأقسام: استعلام بيانات HPC Scheduler غير مثبّت. ثبّت القوالب من صفحة الحالة الصحية." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "لم تُعد فهرسة الأقسام: ليس للعنقود جهاز، أو لم يعد جهازه موجودًا." + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "قوالب HPC Scheduler مثبّتة." diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index b4f3229..d4bb5c9 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -32,6 +32,10 @@ msgstr "" msgid "The cluster was saved." msgstr "" +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "" + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "" @@ -56,6 +60,10 @@ msgstr "" msgid "Missing graphs were added." msgstr "" +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "" + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "" @@ -68,6 +76,22 @@ msgstr "" msgid "The partitions were reindexed from the snapshot." msgstr "" +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "" + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "" diff --git a/locales/po/es-419.po b/locales/po/es-419.po index d889b8b..3013a3c 100644 --- a/locales/po/es-419.po +++ b/locales/po/es-419.po @@ -30,6 +30,10 @@ msgstr "No se ha guardado el clúster: alguien lo modificó después de abrir el msgid "The cluster was saved." msgstr "Se ha guardado el clúster." +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "No se cambió el estado del clúster: falló la escritura. Consulte el registro de Cacti." + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "Se han eliminado el clúster y su instantánea en caché. Se han conservado su dispositivo y sus gráficos. No se contactó con el planificador." @@ -54,6 +58,10 @@ msgstr "No se ha asociado el clúster: el dispositivo no existe, no está autori msgid "Missing graphs were added." msgstr "Se han añadido los gráficos que faltaban." +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "No se agregaron gráficos: el clúster no tiene dispositivo o su dispositivo ya no existe." + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "No se ha desvinculado el clúster: alguien lo modificó después de abrir la página." @@ -66,6 +74,22 @@ msgstr "Se ha desvinculado el clúster. Se han conservado el dispositivo y sus g msgid "The partitions were reindexed from the snapshot." msgstr "Se han reindexado las particiones a partir de la instantánea." +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "No se reindexaron las particiones: el dispositivo está deshabilitado o inactivo, por lo que Cacti omitió su consulta de datos." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "No se reindexaron las particiones: Cacti no pudo ejecutar la consulta de datos. Consulte el registro de Cacti." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "No se reindexaron las particiones: la consulta de datos de HPC Scheduler no está instalada. Instale las plantillas desde la página de estado." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "No se reindexaron las particiones: el clúster no tiene dispositivo o su dispositivo ya no existe." + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "Las plantillas de HPC Scheduler están instaladas." diff --git a/locales/po/es-ES.po b/locales/po/es-ES.po index d7d9ef7..a46b653 100644 --- a/locales/po/es-ES.po +++ b/locales/po/es-ES.po @@ -30,6 +30,10 @@ msgstr "No se ha guardado el clúster: alguien lo modificó después de abrir el msgid "The cluster was saved." msgstr "Se ha guardado el clúster." +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "No se ha cambiado el estado del clúster: falló la escritura. Consulte el registro de Cacti." + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "Se han eliminado el clúster y su instantánea en caché. Se han conservado su dispositivo y sus gráficos. No se contactó con el planificador." @@ -54,6 +58,10 @@ msgstr "No se ha asociado el clúster: el dispositivo no existe, no está autori msgid "Missing graphs were added." msgstr "Se han añadido los gráficos que faltaban." +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "No se han añadido gráficos: el clúster no tiene dispositivo o su dispositivo ya no existe." + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "No se ha desvinculado el clúster: alguien lo modificó después de abrir la página." @@ -66,6 +74,22 @@ msgstr "Se ha desvinculado el clúster. Se han conservado el dispositivo y sus g msgid "The partitions were reindexed from the snapshot." msgstr "Se han reindexado las particiones a partir de la instantánea." +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "No se han reindexado las particiones: el dispositivo está deshabilitado o inactivo, por lo que Cacti omitió su consulta de datos." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "No se han reindexado las particiones: Cacti no pudo ejecutar la consulta de datos. Consulte el registro de Cacti." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "No se han reindexado las particiones: la consulta de datos de HPC Scheduler no está instalada. Instale las plantillas desde la página de estado." + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "No se han reindexado las particiones: el clúster no tiene dispositivo o su dispositivo ya no existe." + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "Las plantillas de HPC Scheduler están instaladas." diff --git a/locales/po/hi-IN.po b/locales/po/hi-IN.po index dab22dd..9f98877 100644 --- a/locales/po/hi-IN.po +++ b/locales/po/hi-IN.po @@ -30,6 +30,10 @@ msgstr "क्लस्टर सहेजा नहीं गया: फ़ॉ msgid "The cluster was saved." msgstr "क्लस्टर सहेज दिया गया।" +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "क्लस्टर की स्थिति नहीं बदली: लिखना विफल रहा। Cacti लॉग देखें।" + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "क्लस्टर और उसका कैश किया गया स्नैपशॉट हटा दिए गए। उसका डिवाइस और ग्राफ़ रखे गए। शेड्यूलर से संपर्क नहीं किया गया।" @@ -54,6 +58,10 @@ msgstr "क्लस्टर मैप नहीं हुआ: डिवाइ msgid "Missing graphs were added." msgstr "अनुपस्थित ग्राफ़ जोड़ दिए गए।" +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "ग्राफ़ नहीं जोड़े गए: क्लस्टर के पास डिवाइस नहीं है, या उसका डिवाइस अब मौजूद नहीं है।" + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "क्लस्टर की मैपिंग नहीं हटाई गई: पृष्ठ खुलने के बाद किसी और ने इसे बदल दिया।" @@ -66,6 +74,22 @@ msgstr "क्लस्टर की मैपिंग हटा दी गई msgid "The partitions were reindexed from the snapshot." msgstr "स्नैपशॉट से पार्टिशन फिर इंडेक्स किए गए।" +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "पार्टिशन दोबारा इंडेक्स नहीं हुए: डिवाइस अक्षम है या बंद है, इसलिए Cacti ने उसकी डेटा क्वेरी छोड़ दी।" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "पार्टिशन दोबारा इंडेक्स नहीं हुए: Cacti डेटा क्वेरी नहीं चला सका। Cacti लॉग देखें।" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "पार्टिशन दोबारा इंडेक्स नहीं हुए: HPC Scheduler डेटा क्वेरी इंस्टॉल नहीं है। हेल्थ पेज से टेम्पलेट इंस्टॉल करें।" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "पार्टिशन दोबारा इंडेक्स नहीं हुए: क्लस्टर के पास डिवाइस नहीं है, या उसका डिवाइस अब मौजूद नहीं है।" + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "HPC Scheduler टेम्पलेट स्थापित हैं।" diff --git a/locales/po/zh-CN.po b/locales/po/zh-CN.po index f34af6a..38b6686 100644 --- a/locales/po/zh-CN.po +++ b/locales/po/zh-CN.po @@ -30,6 +30,10 @@ msgstr "未保存集群:表单打开后其他人已修改集群,或写入失 msgid "The cluster was saved." msgstr "已保存集群。" +#: hpcsched_clusters.php +msgid "The cluster state was not changed: the write failed. See the Cacti log." +msgstr "未更改集群状态:写入失败。请查看 Cacti 日志。" + #: hpcsched_clusters.php msgid "The cluster and its cached snapshot were deleted. Its device and graphs were kept. The scheduler was not contacted." msgstr "已删除集群及其缓存快照。设备和图表已保留。未连接调度器。" @@ -54,6 +58,10 @@ msgstr "未映射集群:设备不存在、您无权访问、设备已承载另 msgid "Missing graphs were added." msgstr "已添加缺失的图表。" +#: hpcsched_clusters.php +msgid "No graphs were added: the cluster has no device, or its device no longer exists." +msgstr "未添加图表:集群没有设备,或其设备已不存在。" + #: hpcsched_clusters.php msgid "The cluster was not unmapped: it was changed by someone else since the page was opened." msgstr "未取消集群映射:页面打开后其他人已修改集群。" @@ -66,6 +74,22 @@ msgstr "已取消集群映射。设备及其图表已保留。" msgid "The partitions were reindexed from the snapshot." msgstr "已根据快照重新索引分区。" +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the device is disabled or down, so Cacti skipped its data query." +msgstr "未重新索引分区:设备已禁用或已宕机,因此 Cacti 跳过了其数据查询。" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: Cacti could not run the data query. See the Cacti log." +msgstr "未重新索引分区:Cacti 无法运行数据查询。请参阅 Cacti 日志。" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the HPC Scheduler data query is not installed. Install the templates from the health page." +msgstr "未重新索引分区:未安装 HPC Scheduler 数据查询。请从健康状态页面安装模板。" + +#: hpcsched_clusters.php +msgid "The partitions were not reindexed: the cluster has no device, or its device no longer exists." +msgstr "未重新索引分区:集群没有设备,或其设备已不存在。" + #: hpcsched_health.php msgid "The HPC Scheduler templates are installed." msgstr "已安装 HPC Scheduler 模板。" diff --git a/poller_hpcsched.php b/poller_hpcsched.php index e413fb4..fa3d456 100644 --- a/poller_hpcsched.php +++ b/poller_hpcsched.php @@ -133,12 +133,21 @@ } }); +$hpcsched_run = null; + try { $hpcsched_run = hpcsched_reader($hpcsched_fitted, $hpcsched_holder, $hpcsched_clock)->run($hpcsched_row, $hpcsched_interval); +} catch (\Somethingwithproof\Hpcsched\DatabaseError $e) { + // exit() would skip the finally block, so exit after it has run. + cacti_log('ERROR: The HPC scheduler reader for cluster ' . $hpcsched_cluster . ' stopped on a database error: ' . $e->getMessage(), false, 'HPCSCHED'); } finally { unregister_process('hpcsched', 'reader', $hpcsched_cluster); } +if ($hpcsched_run === null) { + exit(1); +} + // A partition added, removed, or renamed reaches the cluster device through // Cacti's reindex; its index count check alone misses a rename (ADR 0011). if ($hpcsched_row->hostId > 0 && $hpcsched_run->outcome !== \Somethingwithproof\Hpcsched\RunOutcome::Failed && hpcsched_provisioner()->reindexIfChanged($hpcsched_row)) { diff --git a/tests/Unit/ReaderTest.php b/tests/Unit/ReaderTest.php index cf757f9..7495c0e 100644 --- a/tests/Unit/ReaderTest.php +++ b/tests/Unit/ReaderTest.php @@ -27,6 +27,7 @@ use Somethingwithproof\Hpcsched\CommandRunner; use Somethingwithproof\Hpcsched\ErrorClass; use Somethingwithproof\Hpcsched\FixedClock; +use Somethingwithproof\Hpcsched\DatabaseError; use Somethingwithproof\Hpcsched\HttpResponse; use Somethingwithproof\Hpcsched\Reader; use Somethingwithproof\Hpcsched\RunOutcome; @@ -165,6 +166,21 @@ function hpcsched_sql(): array { ->and($run->error)->toBe(ErrorClass::Failed); }); +it('records a failed run and rethrows when a database read fails mid-run', function () { + $clock = new FixedClock(100000); + // The previous section rows cannot be read. + $GLOBALS['__hpcsched_db_rows']['FROM plugin_hpcsched_section WHERE cluster_id'] = false; + + expect(fn () => hpcsched_reader_for(hpcsched_fixture_responses(), $clock)->run(hpcsched_rest_cluster($this->scratch), 60)) + ->toThrow(DatabaseError::class); + + $finish = array_values(array_filter($GLOBALS['__hpcsched_db_exec'], fn (array $s): bool => str_contains($s['sql'], 'SET finished_at'))); + + expect($finish)->toHaveCount(1) + ->and($finish[0]['params'])->toContain('failed') + ->and(array_column($GLOBALS['__hpcsched_db_exec'], 'sql'))->toContain('UPDATE plugin_hpcsched_run SET lease_expires = 0 WHERE cluster_id = ? AND holder = ?'); +}); + it('refuses a run while another holds the lease', function () { $GLOBALS['__hpcsched_db_rows'] = [HPCSCHED_LEASE => [['c' => 0]]]; diff --git a/tests/bin/device-flow.php b/tests/bin/device-flow.php index dc26869..7b819cc 100644 --- a/tests/bin/device-flow.php +++ b/tests/bin/device-flow.php @@ -249,6 +249,12 @@ function flow_rrd_values($host_id) { flow_expect($change(array('batch', 'devel', 'gpu')) && $indexes() === array('batch', 'devel', 'gpu'), 'a renamed partition is reindexed although the index count is the same'); flow_expect(!$provisioner->reindexIfChanged($clusters->get($cluster_id)), 'no reindex runs while the partitions are unchanged'); + // Cacti returns true for a query it skips, so a disabled device is reported as skipped. + db_execute_prepared("UPDATE host SET disabled = 'on' WHERE id = ?", array($host_id)); + $skipped = $provisioner->reindex($host_id); + db_execute_prepared("UPDATE host SET disabled = '' WHERE id = ?", array($host_id)); + flow_expect($skipped === \Somethingwithproof\Hpcsched\ReindexResult::Skipped && $provisioner->reindex($host_id) === \Somethingwithproof\Hpcsched\ReindexResult::Completed, 'a reindex of a disabled device is reported as skipped, and of an enabled one as completed'); + $gpu_graphs = (int) db_fetch_cell_prepared("SELECT COUNT(*) FROM graph_local WHERE host_id = ? AND snmp_index = 'gpu'", array($host_id)); flow_expect($change(array('batch')) && $indexes() === array('batch'), 'a removed partition leaves the indexes'); flow_expect((int) db_fetch_cell_prepared("SELECT COUNT(*) FROM poller_item AS pi INNER JOIN data_local AS dl ON dl.id = pi.local_data_id WHERE dl.host_id = ? AND dl.snmp_index = 'gpu'", array($host_id)) === 0 && (int) db_fetch_cell_prepared("SELECT COUNT(*) FROM graph_local WHERE host_id = ? AND snmp_index = 'gpu'", array($host_id)) === $gpu_graphs && $gpu_graphs === 5, 'the removed partition is no longer polled and its graphs stay');