api/v2auth: remove defer in loop.

This commit is contained in:
caoming 2019-01-08 08:56:55 +08:00
parent 8945fecf85
commit e96dbfb973

View File

@ -32,7 +32,6 @@ func (s *store) ensureAuthDirectories() error {
}
for _, res := range []string{StorePermsPrefix, StorePermsPrefix + "/users/", StorePermsPrefix + "/roles/"} {
ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
defer cancel()
pe := false
rr := etcdserverpb.Request{
Method: "PUT",
@ -41,6 +40,7 @@ func (s *store) ensureAuthDirectories() error {
PrevExist: &pe,
}
_, err := s.server.Do(ctx, rr)
cancel()
if err != nil {
if e, ok := err.(*v2error.Error); ok {
if e.ErrorCode == v2error.EcodeNodeExist {