etcdserver, auth: not cache a flag of auth status

This commit removes a flag that indicates auth is enabled or disabled
because it doesn't have an invalidation mechanism.

Fixes https://github.com/coreos/etcd/issues/3601 and https://github.com/coreos/etcd/issues/3964

Conflicts (Resolved):
	etcdserver/auth/auth.go
This commit is contained in:
Hitoshi Mitake 2016-01-26 11:26:49 +09:00 committed by Gyu-Ho Lee
parent 756d701f13
commit 259f89d59a
3 changed files with 1 additions and 14 deletions

View File

@ -95,8 +95,7 @@ type store struct {
timeout time.Duration
ensuredOnce bool
mu sync.Mutex // protect enabled
enabled *bool
mu sync.Mutex
}
type User struct {
@ -409,8 +408,6 @@ func (s *store) EnableAuth() error {
}
err = s.enableAuth()
if err == nil {
b := true
s.enabled = &b
plog.Noticef("auth: enabled auth")
} else {
plog.Errorf("error enabling auth (%v)", err)
@ -428,8 +425,6 @@ func (s *store) DisableAuth() error {
err := s.disableAuth()
if err == nil {
b := false
s.enabled = &b
plog.Noticef("auth: disabled auth")
} else {
plog.Errorf("error disabling auth (%v)", err)

View File

@ -85,15 +85,10 @@ func (s *store) detectAuth() bool {
if s.server == nil {
return false
}
if s.enabled != nil {
return *s.enabled
}
value, err := s.requestResource("/enabled", false)
if err != nil {
if e, ok := err.(*etcderr.Error); ok {
if e.ErrorCode == etcderr.EcodeKeyNotFound {
b := false
s.enabled = &b
return false
}
}
@ -107,7 +102,6 @@ func (s *store) detectAuth() bool {
plog.Errorf("internal bookkeeping value for enabled isn't valid JSON (%v)", err)
return false
}
s.enabled = &u
return u
}

View File

@ -611,8 +611,6 @@ func TestDisableAuth(t *testing.T) {
t.Error("Expected error; already disabled")
}
// clear cache
s.enabled = nil
err = s.DisableAuth()
if err != nil {
t.Error("Unexpected error", err)