api/v2auth: remove defer in loop.
@@ -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 {
