Skip to content

Commit

Permalink
etcdserver, auth: not cache a flag of auth status
Browse files Browse the repository at this point in the history
This commit removes a flag that indicates auth is enabled or disabled
because it doesn't have an invalidation mechanism.

Fixes #3601 and #3964
  • Loading branch information
mitake committed Jan 26, 2016
1 parent b1a45fe commit 0ca3ca5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
7 changes: 1 addition & 6 deletions etcdserver/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ type store struct {
timeout time.Duration
ensuredOnce bool

mu sync.Mutex // protect enabled
enabled *bool
mu sync.Mutex // protect enabled

PasswordStore
}
Expand Down Expand Up @@ -440,8 +439,6 @@ func (s *store) EnableAuth() error {
return err
}

b := true
s.enabled = &b
plog.Noticef("auth: enabled auth")
return nil
}
Expand All @@ -456,8 +453,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)
Expand Down
6 changes: 0 additions & 6 deletions etcdserver/auth/auth_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand Down

0 comments on commit 0ca3ca5

Please sign in to comment.