Skip to content
Merged
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
91 changes: 55 additions & 36 deletions gen/api/v1/operator_health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/controller/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func (c *EnvBasedController) sendHealthReport(ctx context.Context) {
report,
c.getClusterID(),
versionInfo.String(),
versionInfo.GitCommit,
c.startTime,
)
if err := c.Reconciler.DakrClient.ReportHealth(ctx, req); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/health/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func worstStatus(a, b gen.HealthStatus) gen.HealthStatus {

// BuildHeartbeatRequest constructs a ReportHealthRequest from the current
// HealthManager state. The zxporter operator type is OPERATOR_TYPE_READ.
func BuildHeartbeatRequest(hm *HealthManager, clusterID, version string, startTime time.Time) *gen.ReportHealthRequest {
return BuildHeartbeatRequestFromReport(hm.BuildReport(), clusterID, version, startTime)
func BuildHeartbeatRequest(hm *HealthManager, clusterID, version, commit string, startTime time.Time) *gen.ReportHealthRequest {
return BuildHeartbeatRequestFromReport(hm.BuildReport(), clusterID, version, commit, startTime)
}

// BuildHeartbeatRequestFromReport constructs a ReportHealthRequest from an
// already-built report map. Use this when you need to log and send the same
// snapshot to avoid a double lock acquisition on HealthManager.
func BuildHeartbeatRequestFromReport(report map[string]ComponentStatus, clusterID, version string, startTime time.Time) *gen.ReportHealthRequest {
func BuildHeartbeatRequestFromReport(report map[string]ComponentStatus, clusterID, version, commit string, startTime time.Time) *gen.ReportHealthRequest {
overall := gen.HealthStatus_HEALTH_STATUS_UNSPECIFIED
components := make([]*gen.ComponentHealth, 0, len(report))

Expand All @@ -60,6 +60,7 @@ func BuildHeartbeatRequestFromReport(report map[string]ComponentStatus, clusterI
ClusterId: clusterID,
OperatorType: gen.OperatorType_OPERATOR_TYPE_READ,
Version: version,
Commit: commit,
OverallStatus: overall,
Components: components,
UptimeSince: timestamppb.New(startTime),
Expand Down
5 changes: 3 additions & 2 deletions internal/health/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ func TestBuildHeartbeatRequest(t *testing.T) {

startTime := time.Now().Add(-10 * time.Minute)

req := BuildHeartbeatRequest(hm, "cluster-123", "1.2.3", startTime)
req := BuildHeartbeatRequest(hm, "cluster-123", "1.2.3", "abc123", startTime)

assert.Equal(t, "cluster-123", req.ClusterId)
assert.Equal(t, "1.2.3", req.Version)
assert.Equal(t, "abc123", req.Commit)
assert.Equal(t, gen.OperatorType_OPERATOR_TYPE_READ, req.OperatorType)
require.NotNil(t, req.UptimeSince)
assert.Equal(t, startTime.Unix(), req.UptimeSince.AsTime().Unix())
Expand Down Expand Up @@ -73,7 +74,7 @@ func TestBuildHeartbeatRequest_OverallStatus(t *testing.T) {
hm.UpdateStatus(name, s, "", nil)
}

req := BuildHeartbeatRequest(hm, "c1", "1.0.0", time.Now())
req := BuildHeartbeatRequest(hm, "c1", "1.0.0", "def456", time.Now())
assert.Equal(t, tt.expected, req.OverallStatus)
})
}
Expand Down
Binary file modified proto/dakr_proto_descriptor.bin
Binary file not shown.