Skip to content

Commit

Permalink
etcdserver: Fix v2v3api set to create parent directly if not exists
Browse files Browse the repository at this point in the history
When a new file is created under an non existent directly,
the v2 API automatically create the parent directly.
This commit aligns the behaviour of v2v3 emulation to comply with the v2
API.
  • Loading branch information
Iwasaki Yudai committed Apr 25, 2018
1 parent 3da4c8a commit 1b62051
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions etcdserver/api/v2v3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ func (s *v2v3Store) Set(
applyf := func(stm concurrency.STM) error {
parent := path.Dir(nodePath)
if !isRoot(parent) && stm.Rev(s.mkPath(parent)+"/") == 0 {
ecode = v2error.EcodeKeyNotFound
return nil
_, err := s.Create(parent+"/", true, "", false, v2store.TTLOptionSet{})
if err != nil {
return err
}
}

key := s.mkPath(nodePath)
Expand Down

0 comments on commit 1b62051

Please sign in to comment.