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 etcd-io#3601 and etcd-io#3964

Conflicts:
	etcdserver/auth/auth.go
  • Loading branch information
mitake authored and gyuho committed Jan 27, 2016
1 parent f502739 commit f7314e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 12 additions & 2 deletions etcdserver/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ type store struct {
timeout time.Duration
ensuredOnce bool

<<<<<<< HEAD
mu sync.Mutex // protect enabled
enabled *bool
=======
mu sync.Mutex // protect enabled

PasswordStore
>>>>>>> b2d2c79... etcdserver, auth: not cache a flag of auth status
}

type User struct {
Expand Down Expand Up @@ -415,7 +421,13 @@ func (s *store) EnableAuth() error {
} else {
plog.Errorf("error enabling auth (%v)", err)
}
<<<<<<< HEAD
return err
=======

plog.Noticef("auth: enabled auth")
return nil
>>>>>>> b2d2c79... etcdserver, auth: not cache a flag of auth status
}

func (s *store) DisableAuth() error {
Expand All @@ -428,8 +440,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
2 changes: 0 additions & 2 deletions etcdserver/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f7314e6

Please sign in to comment.