-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: fix server panic on invalid Election Proclaim/Resign HTTP requests #9379
Conversation
370b386
to
b928829
Compare
|
||
"github.com/coreos/etcd/clientv3" | ||
"github.com/coreos/etcd/clientv3/concurrency" | ||
epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" | ||
) | ||
|
||
// ErrMissingLeaderField is returned when election API is | ||
// missing "leader" field. | ||
var ErrMissingLeaderField = errors.New(`missing "leader" field`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrMissingLeaderKey
LeaderKey is the user facing API. Check the actual proto in v3electionpb to verify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xiang90 Right, we define as LeaderKey
in proto. Just fixed.
Thanks!
lgtm in general |
|
||
"github.com/coreos/etcd/clientv3" | ||
"github.com/coreos/etcd/clientv3/concurrency" | ||
epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" | ||
) | ||
|
||
// ErrMissingLeaderKey is returned when election API is | ||
// missing "leader" field. | ||
var ErrMissingLeaderKey = errors.New(`missing "leader" field`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message also needs to be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I meant,
type ProclaimRequest struct {
// leader is the leadership hold on the election.
Leader *LeaderKey `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
// value is an update meant to overwrite the leader's current value.
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
So, the JSON field is still "leader"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message can be more descriptive like leader field must be provided
lgtm |
|
||
"github.com/coreos/etcd/clientv3" | ||
"github.com/coreos/etcd/clientv3/concurrency" | ||
epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" | ||
) | ||
|
||
// ErrMissingLeaderKey is returned when election API request | ||
// is missing "leader" field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing "leader" field.
-> missing the "leader" field.
?
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
lgtm |
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
…rigin-release-3.2 Automated cherry pick of #9379
Server should never panic from wrong-formatted client requests. Without this patch,
/v3/election/proclaim
request withleader
field missing can panic etcd servers.@jpbetz This needs 3.2 backport as well.