Skip to content

Commit

Permalink
fix-gid
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingPoeta committed Jan 17, 2025
1 parent 318cfc9 commit 38a8fda
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/scripts/hypo/fs_sdk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,13 @@ def test_issue_e(self):
state.read(file=v2, mode='r', offset=0, user='root', whence=0, length=4)
state.teardown()

def test_issue_f(self):
state = JuicefsMachine()
folders_0 = state.init_folders()
files_0 = state.create_file(content=b'', file_name='b', parent=folders_0, umask=18, user='root')
state.chown(entry=folders_0, owner='user1', user='root')
state.create_file(content=b'', file_name='a', parent=folders_0, umask=18, user='root')
state.teardown()

if __name__ == '__main__':
unittest.main()
24 changes: 23 additions & 1 deletion sdk/java/libjfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ var (

userGroupCache = make(map[string]map[string][]string) // name -> (user -> groups)

caller = CALLER_JAVA
)

const (
CALLER_JAVA = iota
CALLER_PYTHON
)

const (
BEHAVIOR_HADOOP = "Hadoop"
)

const (
Expand Down Expand Up @@ -210,7 +220,9 @@ func jfs_set_logger(cb unsafe.Pointer) {
func (w *wrapper) withPid(pid int64) meta.Context {
// mapping Java Thread ID to global one
ctx := meta.NewContext(w.ctx.Pid()*1000+uint32(pid), w.ctx.Uid(), w.ctx.Gids())
ctx.WithValue(meta.CtxKey("behavior"), "Hadoop")
if caller == CALLER_JAVA {
ctx.WithValue(meta.CtxKey("behavior"), BEHAVIOR_HADOOP)
}
return ctx
}

Expand Down Expand Up @@ -336,6 +348,7 @@ type javaConf struct {
PushAuth string `json:"pushAuth"`
PushLabels string `json:"pushLabels"`
PushGraphite string `json:"pushGraphite"`
Caller int `json:"caller"`
}

func getOrCreate(name, user, group, superuser, supergroup string, f func() *fs.FileSystem) int64 {
Expand Down Expand Up @@ -467,6 +480,15 @@ func jfs_init(cname, jsonConf, user, group, superuser, supergroup *C.char) int64
utils.SetLogLevel(logrus.WarnLevel)
}

switch jConf.Caller {
case CALLER_JAVA:
caller = CALLER_JAVA
case CALLER_PYTHON:
caller = CALLER_PYTHON
default:
caller = CALLER_PYTHON
}

metaConf := meta.DefaultConf()
metaConf.Retries = jConf.IORetries
metaConf.MaxDeletes = jConf.MaxDeletes
Expand Down
1 change: 1 addition & 0 deletions sdk/python/juicefs/juicefs/juicefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(self, name, meta, *, bucket="", storage_class="", read_only=False,
kwargs["pushAuth"] = push_auth
kwargs["pushLabels"] = push_labels
kwargs["pushGraphite"] = push_graphite
kwargs["caller"] = 1

jsonConf = json.dumps(kwargs)
self.umask = os.umask(0)
Expand Down

0 comments on commit 38a8fda

Please sign in to comment.