Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix path create in absence of acl for base prefix
Browse files Browse the repository at this point in the history
secwall committed Sep 20, 2024
1 parent 6c51a56 commit a31a732
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion internal/dcs/zk.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"log/slog"
"net"
"os"
"slices"
"strings"
"sync"
"time"
@@ -159,12 +160,30 @@ func (z *zkDCS) getSelfLockOwner() LockOwner {
func (z *zkDCS) makePath(path string) error {
parts := strings.Split(path, sep)
prefix := ""
var paths []string
for _, part := range parts {
if part == "" {
continue
}
prefix = JoinPath(prefix, part)
_, err := z.retryCreate(prefix, []byte{}, 0, z.acl)
paths = append(paths, prefix)
}
slices.Reverse(paths)
var createPaths []string
for _, path := range paths {
_, _, err := z.retryGet(path)
if err == nil {
break
}
if err == zk.ErrNoNode {
createPaths = append(createPaths, path)
} else {
return err
}
}
slices.Reverse(createPaths)
for _, path := range createPaths {
_, err := z.retryCreate(path, []byte{}, 0, z.acl)
if err != nil && err != zk.ErrNodeExists {
return err
}

0 comments on commit a31a732

Please sign in to comment.