Skip to content
Open
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
14 changes: 7 additions & 7 deletions pkg/tnf/pkg/pacemaker/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ func (c *HealthCheck) sync(ctx context.Context, syncCtx factory.SyncContext) err

c.recordHealthCheckEvents(currentStatus, previousStatus)

// Only mark as processed after status was successfully updated
if currentStatus.OverallStatus != statusUnknown {
c.previousMu.Lock()
c.previous = currentStatus
c.previousMu.Unlock()
}

return nil
}

Expand Down Expand Up @@ -324,13 +331,6 @@ func (c *HealthCheck) getPacemakerStatus(ctx context.Context) (*HealthStatus, *H
currentStatus := c.buildHealthStatusFromCR(pacemakerCR)
currentStatus.CRLastUpdated = crLastUpdated

// Only update previous for non-Unknown status (preserves last valid for grace period)
if currentStatus.OverallStatus != statusUnknown {
c.previousMu.Lock()
c.previous = currentStatus
c.previousMu.Unlock()
}

return currentStatus, previous, nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/tnf/pkg/pacemaker/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ func TestHealthCheck_getPacemakerStatus_UnchangedTimestamp(t *testing.T) {
require.NotNil(t, current1, "First call should return a status")
require.Equal(t, statusHealthy, current1.OverallStatus, "First call should return healthy status")

// Simulate what sync() does after successful updateOperatorStatus
controller.previous = current1

// Second call with same timestamp should return nil (no change)
current2, _, err2 := controller.getPacemakerStatus(ctx)
require.NoError(t, err2, "Second getPacemakerStatus should not return an error")
Expand Down