From 6ae51e41f97727960dbc49255f338090e3217a87 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 15 Jan 2021 13:18:03 +0300 Subject: [PATCH] [#312] control: Add health status field to health check response body Signed-off-by: Leonard Lyubich --- pkg/services/control/service.go | 23 ++++++++++++++++++++++- pkg/services/control/service.pb.go | Bin 29642 -> 30524 bytes pkg/services/control/service.proto | 3 +++ pkg/services/control/service_test.go | 4 +++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkg/services/control/service.go b/pkg/services/control/service.go index 1ab9f6b85..f4ce62439 100644 --- a/pkg/services/control/service.go +++ b/pkg/services/control/service.go @@ -66,9 +66,17 @@ func (x *HealthCheckResponse_Body) SetNetmapStatus(v NetmapStatus) { } } +// SetHealthStatus sets health status of the storage node application. +func (x *HealthCheckResponse_Body) SetHealthStatus(v HealthStatus) { + if x != nil { + x.HealthStatus = v + } +} + const ( _ = iota healthRespBodyStatusFNum + healthRespBodyHealthStatusFNum ) // StableMarshal reads binary representation of health check response body @@ -89,7 +97,19 @@ func (x *HealthCheckResponse_Body) StableMarshal(buf []byte) ([]byte, error) { buf = make([]byte, sz) } - _, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.NetmapStatus)) + var ( + offset, n int + err error + ) + + n, err = proto.EnumMarshal(healthRespBodyStatusFNum, buf[offset:], int32(x.NetmapStatus)) + if err != nil { + return nil, err + } + + offset += n + + _, err = proto.EnumMarshal(healthRespBodyHealthStatusFNum, buf[offset:], int32(x.HealthStatus)) if err != nil { return nil, err } @@ -109,6 +129,7 @@ func (x *HealthCheckResponse_Body) StableSize() int { size := 0 size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus)) + size += proto.EnumSize(healthRespBodyHealthStatusFNum, int32(x.HealthStatus)) return size } diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index fa6dae39491fff2fe0094615df5507225e67f06f..a253b35917d732bca6a0daf6fe85c74f37c4c57b 100644 GIT binary patch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6^di)j-6v0dwF#TO5toTm+A?IbQ0l25QXKPEfn!I(dFTQs68NR_pwv- zqfzj}DjpM1W(h9imLVacyP1Td4dR&*?a)q!5*8^1uu;BDvIpC#9U<$4tS8UlNb4bm zWUN`!UZqYMnlw)>Q%y8Oy2%bpJ~`>6v(=ncqAX8%yy&F)hNPHa+gydO`l6ZENj*x? zkCPo8J@?0pj*jX)_Ouau;o4?9CMSlGoan&KiraoZG1rP;H@eWMyYX>S!jsC7OW>e# z4qFuyuPeRqR>!bU@1ttk6{XBDcB(=mvXO{n6QJs@CPO}=rsTU diff --git a/pkg/services/control/service.proto b/pkg/services/control/service.proto index 10652e257..50c23eeb3 100644 --- a/pkg/services/control/service.proto +++ b/pkg/services/control/service.proto @@ -34,6 +34,9 @@ message HealthCheckResponse { message Body { // Status of the storage node in NeoFS network map. NetmapStatus netmap_status = 1; + + // Health status of storage node application. + HealthStatus health_status = 2; } // Body of health check response message. diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index 8943a1bfb..3c9bb6012 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -22,12 +22,14 @@ func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) { func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body { body := new(control.HealthCheckResponse_Body) body.SetNetmapStatus(control.NetmapStatus_ONLINE) + body.SetHealthStatus(control.HealthStatus_SHUTTING_DOWN) return body } func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool { - return b1.GetNetmapStatus() == b2.GetNetmapStatus() + return b1.GetNetmapStatus() == b2.GetNetmapStatus() && + b1.GetHealthStatus() == b2.GetHealthStatus() } func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) {