-
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
RFC, WIP: etcdserver: let maintenance services require root role #6898
Conversation
f971a3a
to
7a81f49
Compare
@mitake have you tried |
@heyitsanthony I didn't notice the interface... I'll try it, thanks! |
@heyitsanthony I added a protection mechanism to |
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.
approach looks OK
|
||
func defragTest(cx ctlCtx) { | ||
func initKeys(cx ctlCtx) { |
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.
maintenanceInitKeys
?
func TestCtlV3SnapshotWithAuth(t *testing.T) { testCtl(t, snapshotTestWithAuth) } | ||
|
||
func snapshotTestWithAuth(cx ctlCtx) { | ||
var kvs = []kv{{"key", "val1"}, {"key", "val2"}, {"key", "val3"}} |
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.
maintenanceInitKeys
?
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.
ok
} | ||
|
||
as := ms.ag.AuthStore() | ||
err = as.IsAdminPermitted(authInfo) |
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.
return ms.ag.AuthStore().IsAdminPermitted(authInfo)
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.
I'll change it after finishing another ongoing PR: #6903
AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error) | ||
AuthStore() auth.AuthStore | ||
} | ||
|
||
type maintenanceServer struct { |
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.
can there be a separate type returned by NewMaintenanceServer
:
type authMaintenanceServer struct {
ag AuthGetter
ms *maintenanceServer
}
that does the auth checks before calling into the auth-free maintenance server? This buys type-checking that auth covers all calls for the service since if it misses a check it won't match the interface. I'd like to avoid mingling auth code with non-auth code if it's not strictly necessary...
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.
ok, I'll try it
@@ -639,7 +639,7 @@ func (s *EtcdServer) isValidSimpleToken(token string) bool { | |||
} | |||
} | |||
|
|||
func (s *EtcdServer) authInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error) { | |||
func (s *EtcdServer) AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error) { |
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.
it seems like this belongs in the auth package if it's important enough to export? can probably pass a func f(idx uint64) <-chan
to get around the etcdserver dependency in isValidToken where it waits for the revision update
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.
ok, I'll try to move the function to auth pkg.
9962061
to
8e6e6e5
Compare
@heyitsanthony updated based on your comments, PTAL. |
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.
minor nit about warnings
|
||
func (ams *authMaintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) { | ||
if err := ams.isAuthenticated(ctx); err != nil { | ||
plog.Warningf("invalid Degragment request was issued: %s", err) |
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.
drop the warnings? other auth failures don't warn, so it's inconsistent
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.
OK, I'll remove the warnings.
@@ -153,6 +156,9 @@ type AuthStore interface { | |||
|
|||
// Close does cleanup of AuthStore | |||
Close() error | |||
|
|||
// AuthInfoFromCtx gets AuthInfo from gRPC's context |
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.
remove the mention of gRPC? then this interface seems more generic.
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.
In AuthInfoFromCtx()
, gRPC's metadata is obtained by metadata.FromContext()
. So I think the context cannot be said generic.
LGTM. |
@heyitsanthony Can you approve this pr? We can add a test for the quorum loss case. it is important to ensure that we can still get a snapshot at least to recover the cluster. |
@heyitsanthony as @xiang90 says, I also think that quorum loss cases shouldn't prevent the maintenance RPCs and its auth. They are similar to serializable range requests. |
This commit lets maintenance services require root privilege. It also moves AuthInfoFromCtx() from etcdserver to auth pkg for cleaning purpose.
@heyitsanthony @xiang90 removed the needless warnings. I kept the comment that mentions gRPC, how do you think? |
Current coverage is 64.01% (diff: 36.11%)
|
ok. lgtm. @heyitsanthony Can you approve this pr? |
just wanted to confirm it'd work under quorum loss, sorry for the confusion! lgtm. Thanks! |
This PR lets maintenance services require root role. But
Snapshot()
isn't protected yet because it doesn't havectx
in its parameter. I'm seeking how to obtain credential information in the function.