forked from TrueCloudLab/frostfs-node
[#312] control: Add health status field to health check response body
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0abb8acef3
commit
6ae51e41f9
4 changed files with 28 additions and 2 deletions
|
@ -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 (
|
const (
|
||||||
_ = iota
|
_ = iota
|
||||||
healthRespBodyStatusFNum
|
healthRespBodyStatusFNum
|
||||||
|
healthRespBodyHealthStatusFNum
|
||||||
)
|
)
|
||||||
|
|
||||||
// StableMarshal reads binary representation of health check response body
|
// 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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -109,6 +129,7 @@ func (x *HealthCheckResponse_Body) StableSize() int {
|
||||||
size := 0
|
size := 0
|
||||||
|
|
||||||
size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus))
|
size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus))
|
||||||
|
size += proto.EnumSize(healthRespBodyHealthStatusFNum, int32(x.HealthStatus))
|
||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
BIN
pkg/services/control/service.pb.go
generated
BIN
pkg/services/control/service.pb.go
generated
Binary file not shown.
|
@ -34,6 +34,9 @@ message HealthCheckResponse {
|
||||||
message Body {
|
message Body {
|
||||||
// Status of the storage node in NeoFS network map.
|
// Status of the storage node in NeoFS network map.
|
||||||
NetmapStatus netmap_status = 1;
|
NetmapStatus netmap_status = 1;
|
||||||
|
|
||||||
|
// Health status of storage node application.
|
||||||
|
HealthStatus health_status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Body of health check response message.
|
// Body of health check response message.
|
||||||
|
|
|
@ -22,12 +22,14 @@ func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) {
|
||||||
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
||||||
body := new(control.HealthCheckResponse_Body)
|
body := new(control.HealthCheckResponse_Body)
|
||||||
body.SetNetmapStatus(control.NetmapStatus_ONLINE)
|
body.SetNetmapStatus(control.NetmapStatus_ONLINE)
|
||||||
|
body.SetHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
||||||
|
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool {
|
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) {
|
func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue