Skip to content
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

Merged
merged 3 commits into from
Mar 2, 2018

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Mar 1, 2018

Server should never panic from wrong-formatted client requests. Without this patch, /v3/election/proclaim request with leader field missing can panic etcd servers.

@jpbetz This needs 3.2 backport as well.

@gyuho
Copy link
Contributor Author

gyuho commented Mar 1, 2018

Fix #9375.
/cc @therve

@gyuho gyuho force-pushed the fix-election branch 2 times, most recently from 370b386 to b928829 Compare March 1, 2018 22:45
@gyuho gyuho changed the title *: fix panic on wrong-formatted Election Proclaim/Resign HTTP requests *: fix server panic on invalid Election Proclaim/Resign HTTP requests Mar 1, 2018

"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`)
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@xiang90
Copy link
Contributor

xiang90 commented Mar 1, 2018

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`)
Copy link
Contributor

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.

Copy link
Contributor Author

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"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. ok.

Copy link
Contributor

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

@xiang90
Copy link
Contributor

xiang90 commented Mar 1, 2018

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.
Copy link
Member

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>
@fanminshi
Copy link
Member

lgtm

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
@gyuho gyuho merged commit 0a972da into etcd-io:master Mar 2, 2018
@gyuho gyuho deleted the fix-election branch March 2, 2018 02:21
gyuho added a commit that referenced this pull request Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants