1 Commits

Author SHA1 Message Date
jared 9e9d8a33e3 Fix hwmonDaemon hash collisions and automated description rendering
Lint / PHP (phpcs PSR-12) (push) Successful in 40s
Lint / JS (eslint) (push) Successful in 13s
Security / PHP Security (semgrep) (push) Failing after 1m59s
Lint / Deploy (push) Successful in 5s
Lint / Notify on failure (push) Has been skipped
- Include source_type (auto vs manual) in dedup hash so automated
  tickets never collide with manually created ones. This was causing
  hwmonDaemon to hijack manual task tickets that shared the same
  cluster/category/environment tags.

- Include specific OSD ID in hash subtype (osd_down_N) so each OSD
  failure gets its own ticket instead of all colliding to osd_down.

- Wrap hwmonDaemon report descriptions in fenced code blocks in
  comments so ASCII art box-drawing renders correctly instead of
  collapsing into a paragraph blob.

- Refresh ticket description on every automated update so the ticket
  body shows current sensor data, not stale values from first report.

- Only post a worsening-condition comment when title or priority
  actually changed (not just a description refresh).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 08:06:13 -04:00
+29 -6
View File
@@ -158,15 +158,24 @@ function generateTicketHash($data)
$issueSubtype = 'clock_skew'; $issueSubtype = 'clock_skew';
} elseif (stripos($title, 'cluster usage') !== false) { } elseif (stripos($title, 'cluster usage') !== false) {
$issueSubtype = 'usage'; $issueSubtype = 'usage';
} elseif (stripos($title, 'OSD down') !== false) { } elseif (stripos($title, 'OSD down') !== false || preg_match('/OSD\s+osd\.\d+\s+is\s+DOWN/i', $title)) {
// Include the specific OSD ID so each individual OSD gets its own ticket
if (preg_match('/osd\.(\d+)/i', $title, $osdMatch)) {
$issueSubtype = 'osd_down_' . $osdMatch[1];
} else {
$issueSubtype = 'osd_down'; $issueSubtype = 'osd_down';
}
} elseif (stripos($title, 'HEALTH_ERR') !== false) { } elseif (stripos($title, 'HEALTH_ERR') !== false) {
$issueSubtype = 'health_err'; $issueSubtype = 'health_err';
} }
} }
// Include source type so automated tickets never collide with manual ones
$sourceType = stripos($title, '[auto]') !== false ? 'auto' : 'manual';
// Build stable components // Build stable components
$stableComponents = [ $stableComponents = [
'source_type' => $sourceType,
'issue_category' => $issueCategory, 'issue_category' => $issueCategory,
'issue_subtype' => $issueSubtype, 'issue_subtype' => $issueSubtype,
'environment_tags' => array_values(array_filter( 'environment_tags' => array_values(array_filter(
@@ -218,8 +227,9 @@ if ($existing) {
$newPriority = (int)$priority; $newPriority = (int)$priority;
if ($existingStatus !== 'Closed') { if ($existingStatus !== 'Closed') {
// Ticket is still active — update title and escalate priority if the new // Ticket is still active — update title, escalate priority, and refresh
// report is more severe (lower number = higher severity). // the description with the latest sensor data if the new report is more severe
// (lower priority number = higher severity).
$changes = []; $changes = [];
$updateSql = "UPDATE tickets SET updated_at = NOW(), updated_by = ?"; $updateSql = "UPDATE tickets SET updated_at = NOW(), updated_by = ?";
$bindTypes = "i"; $bindTypes = "i";
@@ -239,6 +249,14 @@ if ($existing) {
$changes['priority'] = ['from' => $existingPriority, 'to' => $newPriority]; $changes['priority'] = ['from' => $existingPriority, 'to' => $newPriority];
} }
// Always refresh the description so the ticket body shows current sensor data
if (!empty($description)) {
$updateSql .= ", description = ?";
$bindTypes .= "s";
$bindVals[] = $description;
$changes['description_refreshed'] = true;
}
if (!empty($changes)) { if (!empty($changes)) {
$updateSql .= " WHERE ticket_id = ?"; $updateSql .= " WHERE ticket_id = ?";
$bindTypes .= "s"; $bindTypes .= "s";
@@ -249,7 +267,9 @@ if ($existing) {
$updStmt->execute(); $updStmt->execute();
$updStmt->close(); $updStmt->close();
// Comment summarising what changed // Only add a comment when something meaningful changed (not just a description refresh)
$meaningfulChanges = array_diff_key($changes, ['description_refreshed' => true]);
if (!empty($meaningfulChanges)) {
$changeLines = []; $changeLines = [];
if (isset($changes['title'])) { if (isset($changes['title'])) {
$changeLines[] = "- **Title updated** to reflect current issue"; $changeLines[] = "- **Title updated** to reflect current issue";
@@ -257,14 +277,17 @@ if ($existing) {
if (isset($changes['priority'])) { if (isset($changes['priority'])) {
$changeLines[] = "- **Priority escalated** from P{$changes['priority']['from']} to P{$changes['priority']['to']}"; $changeLines[] = "- **Priority escalated** from P{$changes['priority']['from']} to P{$changes['priority']['to']}";
} }
// Wrap description in a fenced code block so ASCII art / box-drawing
// characters render correctly instead of collapsing into a paragraph blob
$commentText = "**hwmonDaemon reported a worsened condition — ticket updated automatically.**\n\n" . $commentText = "**hwmonDaemon reported a worsened condition — ticket updated automatically.**\n\n" .
implode("\n", $changeLines) . "\n\nLatest report:\n\n" . $description; implode("\n", $changeLines) . "\n\nLatest report:\n\n```\n" . $description . "\n```";
$commentStmt = $conn->prepare( $commentStmt = $conn->prepare(
"INSERT INTO ticket_comments (ticket_id, user_id, user_name, comment_text, markdown_enabled) VALUES (?, ?, 'hwmonDaemon', ?, 1)" "INSERT INTO ticket_comments (ticket_id, user_id, user_name, comment_text, markdown_enabled) VALUES (?, ?, 'hwmonDaemon', ?, 1)"
); );
$commentStmt->bind_param("sis", $existingId, $userId, $commentText); $commentStmt->bind_param("sis", $existingId, $userId, $commentText);
$commentStmt->execute(); $commentStmt->execute();
$commentStmt->close(); $commentStmt->close();
}
$auditLog->log($userId, 'update', 'ticket', $existingId, array_merge( $auditLog->log($userId, 'update', 'ticket', $existingId, array_merge(
$changes, $changes,
@@ -305,7 +328,7 @@ if ($existing) {
$reopenStmt->close(); $reopenStmt->close();
$commentText = "**Issue recurred — ticket reopened automatically.**\n\n" . $commentText = "**Issue recurred — ticket reopened automatically.**\n\n" .
"New report received from hwmonDaemon:\n\n" . $description; "New report received from hwmonDaemon:\n\n```\n" . $description . "\n```";
$commentStmt = $conn->prepare( $commentStmt = $conn->prepare(
"INSERT INTO ticket_comments (ticket_id, user_id, user_name, comment_text, markdown_enabled) VALUES (?, ?, 'hwmonDaemon', ?, 1)" "INSERT INTO ticket_comments (ticket_id, user_id, user_name, comment_text, markdown_enabled) VALUES (?, ?, 'hwmonDaemon', ?, 1)"
); );