From 259f89d59a906b096efa70f83ffe29d479bde270 Mon Sep 17 00:00:00 2001 From: Hitoshi Mitake Date: Tue, 26 Jan 2016 11:26:49 +0900 Subject: [PATCH] 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 --- etcdserver/auth/auth.go | 7 +------ etcdserver/auth/auth_requests.go | 6 ------ etcdserver/auth/auth_test.go | 2 -- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/etcdserver/auth/auth.go b/etcdserver/auth/auth.go index 6730aa6bd..e3ddd6593 100644 --- a/etcdserver/auth/auth.go +++ b/etcdserver/auth/auth.go @@ -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) diff --git a/etcdserver/auth/auth_requests.go b/etcdserver/auth/auth_requests.go index d621ed0ef..7103578c4 100644 --- a/etcdserver/auth/auth_requests.go +++ b/etcdserver/auth/auth_requests.go @@ -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 } diff --git a/etcdserver/auth/auth_test.go b/etcdserver/auth/auth_test.go index 1f4615af4..d9813c969 100644 --- a/etcdserver/auth/auth_test.go +++ b/etcdserver/auth/auth_test.go @@ -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)