mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13085 from gyuho/c
[backport 3.5] etcdserver: don't activate alarm w/missing AlarmType
This commit is contained in:
commit
abe57c1aed
@ -721,6 +721,9 @@ func (a *applierV3backend) Alarm(ar *pb.AlarmRequest) (*pb.AlarmResponse, error)
|
|||||||
case pb.AlarmRequest_GET:
|
case pb.AlarmRequest_GET:
|
||||||
resp.Alarms = a.s.alarmStore.Get(ar.Alarm)
|
resp.Alarms = a.s.alarmStore.Get(ar.Alarm)
|
||||||
case pb.AlarmRequest_ACTIVATE:
|
case pb.AlarmRequest_ACTIVATE:
|
||||||
|
if ar.Alarm == pb.AlarmType_NONE {
|
||||||
|
break
|
||||||
|
}
|
||||||
m := a.s.alarmStore.Activate(types.ID(ar.MemberID), ar.Alarm)
|
m := a.s.alarmStore.Activate(types.ID(ar.MemberID), ar.Alarm)
|
||||||
if m == nil {
|
if m == nil {
|
||||||
break
|
break
|
||||||
@ -738,7 +741,7 @@ func (a *applierV3backend) Alarm(ar *pb.AlarmRequest) (*pb.AlarmResponse, error)
|
|||||||
case pb.AlarmType_NOSPACE:
|
case pb.AlarmType_NOSPACE:
|
||||||
a.s.applyV3 = newApplierV3Capped(a)
|
a.s.applyV3 = newApplierV3Capped(a)
|
||||||
default:
|
default:
|
||||||
lg.Warn("unimplemented alarm activation", zap.String("alarm", fmt.Sprintf("%+v", m)))
|
lg.Panic("unimplemented alarm activation", zap.String("alarm", fmt.Sprintf("%+v", m)))
|
||||||
}
|
}
|
||||||
case pb.AlarmRequest_DEACTIVATE:
|
case pb.AlarmRequest_DEACTIVATE:
|
||||||
m := a.s.alarmStore.Deactivate(types.ID(ar.MemberID), ar.Alarm)
|
m := a.s.alarmStore.Deactivate(types.ID(ar.MemberID), ar.Alarm)
|
||||||
|
@ -366,6 +366,21 @@ func testV3CurlResignMissiongLeaderKey(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestV3CurlMaintenanceAlarmMissiongAlarm(t *testing.T) {
|
||||||
|
for _, p := range apiPrefix {
|
||||||
|
testCtl(t, testV3CurlMaintenanceAlarmMissiongAlarm, withApiPrefix(p), withCfg(*newConfigNoTLS()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testV3CurlMaintenanceAlarmMissiongAlarm(cx ctlCtx) {
|
||||||
|
if err := cURLPost(cx.epc, cURLReq{
|
||||||
|
endpoint: path.Join(cx.apiPrefix, "/maintenance/alarm"),
|
||||||
|
value: `{"action": "ACTIVATE"}`,
|
||||||
|
}); err != nil {
|
||||||
|
cx.t.Fatalf("failed post maintenance alarm (%s) (%v)", cx.apiPrefix, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// to manually decode; JSON marshals integer fields with
|
// to manually decode; JSON marshals integer fields with
|
||||||
// string types, so can't unmarshal with epb.CampaignResponse
|
// string types, so can't unmarshal with epb.CampaignResponse
|
||||||
type campaignResponse struct {
|
type campaignResponse struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user