@@ -1514,28 +1514,27 @@ func readConmonHealthCheckPipeData(ctr *Container, pipe *os.File) {
1514
1514
return
1515
1515
}
1516
1516
1517
- // Log the raw message received from conmon
1518
- logrus .Debugf ("HEALTHCHECK: Raw message received from conmon for container %s: %q" , ctr .ID (), string (b ))
1519
- logrus .Debugf ("HEALTHCHECK: Message length: %d bytes" , len (b ))
1517
+ // Log the raw JSON string received from conmon
1518
+ logrus .Debugf ("HEALTHCHECK: Raw JSON received from conmon for container %s: %q" , ctr .ID (), string (b ))
1519
+ logrus .Debugf ("HEALTHCHECK: JSON length: %d bytes" , len (b ))
1520
1520
1521
- // Parse the message as a simple integer (no JSON)
1522
- messageStr := strings .TrimSpace (string (b ))
1523
- messageType , err := strconv .Atoi (messageStr )
1524
- if err != nil {
1525
- logrus .Errorf ("HEALTHCHECK: Failed to parse message as integer for container %s: %v" , ctr .ID (), err )
1521
+ // Parse the JSON
1522
+ var si syncInfo
1523
+ if err := json .Unmarshal (b , & si ); err != nil {
1524
+ logrus .Errorf ("HEALTHCHECK: Failed to parse JSON from conmon for container %s: %v" , ctr .ID (), err )
1526
1525
continue
1527
1526
}
1528
1527
1529
- logrus .Debugf ("HEALTHCHECK: Parsed message type for container %s: %d " , ctr .ID (), messageType )
1528
+ logrus .Debugf ("HEALTHCHECK: Parsed sync info for container %s: Data=%d, Message=%q " , ctr .ID (), si . Data , si . Message )
1530
1529
1531
1530
// Handle healthcheck status updates based on your new encoding scheme
1532
1531
// Base message type is -100, status values are added to it:
1533
1532
// -100 + 0 (none) = -100
1534
1533
// -100 + 1 (starting) = -99
1535
1534
// -100 + 2 (healthy) = -98
1536
1535
// -100 + 3 (unhealthy) = -97
1537
- if messageType >= HealthCheckMsgStatusUpdate && messageType <= HealthCheckMsgStatusUpdate + HealthCheckStatusUnhealthy {
1538
- statusValue := messageType - HealthCheckMsgStatusUpdate // Convert back to status value
1536
+ if si . Data >= HealthCheckMsgStatusUpdate && si . Data <= HealthCheckMsgStatusUpdate + HealthCheckStatusUnhealthy {
1537
+ statusValue := si . Data - HealthCheckMsgStatusUpdate // Convert back to status value
1539
1538
var status string
1540
1539
1541
1540
switch statusValue {
@@ -1553,20 +1552,20 @@ func readConmonHealthCheckPipeData(ctr *Container, pipe *os.File) {
1553
1552
}
1554
1553
1555
1554
logrus .Infof ("HEALTHCHECK: Received healthcheck status update for container %s: %s (message type: %d, status value: %d)" ,
1556
- ctr .ID (), status , messageType , statusValue )
1555
+ ctr .ID (), status , si . Data , statusValue )
1557
1556
1558
1557
// Update the container's healthcheck status
1559
1558
if err := ctr .updateHealthStatus (status ); err != nil {
1560
1559
logrus .Errorf ("HEALTHCHECK: Failed to update healthcheck status for container %s: %v" , ctr .ID (), err )
1561
1560
} else {
1562
1561
logrus .Infof ("HEALTHCHECK: Successfully updated healthcheck status for container %s to %s" , ctr .ID (), status )
1563
1562
}
1564
- } else if messageType < 0 {
1563
+ } else if si . Data < 0 {
1565
1564
// Other negative message types - might be healthcheck related but not recognized
1566
- logrus .Debugf ("HEALTHCHECK: Received unrecognized negative message type %d for container %s - might be healthcheck related" , messageType , ctr .ID ())
1567
- } else if messageType > 0 {
1565
+ logrus .Debugf ("HEALTHCHECK: Received unrecognized negative message type %d for container %s - might be healthcheck related" , si . Data , ctr .ID ())
1566
+ } else if si . Data > 0 {
1568
1567
// Positive message types - not healthcheck related
1569
- logrus .Debugf ("HEALTHCHECK: Received positive message type %d for container %s - not healthcheck related" , messageType , ctr .ID ())
1568
+ logrus .Debugf ("HEALTHCHECK: Received positive message type %d for container %s - not healthcheck related" , si . Data , ctr .ID ())
1570
1569
}
1571
1570
}
1572
1571
}
0 commit comments