Skip to content

Commit

Permalink
Merge pull request #11960 from tedyu/internal-create-err-chk
Browse files Browse the repository at this point in the history
etcdserver: check error return for store#internalCreate
  • Loading branch information
gyuho authored Jun 3, 2020
2 parents be06390 + 1748394 commit a09533d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions etcdserver/api/v2store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
}
e.PrevNode = n.Repr(false, false, s.clock)

n.Remove(false, false, nil)
if err := n.Remove(false, false, nil); err != nil {
return nil, err
}
} else {
return nil, v2error.NewError(v2error.EcodeNodeExist, nodePath, currIndex)
}
Expand All @@ -630,7 +632,9 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
}

// we are sure d is a directory and does not have the children with name n.Name
d.Add(n)
if err := d.Add(n); err != nil {
return nil, err
}

// node with TTL
if !n.IsPermanent() {
Expand Down

0 comments on commit a09533d

Please sign in to comment.