Skip to content

Commit

Permalink
fix: pre mkdir for runtime mount (#1153)
Browse files Browse the repository at this point in the history
* fix: pre mkdir for runtime mount

Signed-off-by: Keming <kemingyang@tensorchord.ai>

* rebase

Signed-off-by: Keming <kemingyang@tensorchord.ai>

Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy authored Nov 4, 2022
1 parent a6c6081 commit 1af3449
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/lang/ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ func (g Graph) Compile(uid, gid int) (llb.State, error) {
run := g.compileRun(copy)
git := g.compileGit(run)
user := g.compileUserOwn(git)
entrypoint, err := g.compileEntrypoint(user)
mount := g.compileMountDir(user)
entrypoint, err := g.compileEntrypoint(mount)
if err != nil {
return llb.State{}, errors.Wrap(err, "failed to compile entrypoint")
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/lang/ir/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ func (g Graph) installHorust(root llb.State) llb.State {
horust := root.
File(llb.Copy(llb.Image(types.HorustImage), "/", "/usr/local/bin"),
llb.WithCustomName("[internal] install horust")).
File(llb.Mkdir(types.HorustServiceDir, 0755, llb.WithParents(true))).
File(llb.Mkdir(types.HorustLogDir, 0777, llb.WithParents(true)))
File(llb.Mkdir(types.HorustServiceDir, 0755, llb.WithParents(true)),
llb.WithCustomNamef("[internal] mkdir for horust service: %s", types.HorustServiceDir)).
File(llb.Mkdir(types.HorustLogDir, 0777, llb.WithParents(true)),
llb.WithCustomNamef("[internal] mkdir for horust log: %s", types.HorustLogDir))
return horust
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/lang/ir/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,14 @@ func (g Graph) copySSHKey(root llb.State) (llb.State, error) {
llb.WithCustomName("[internal] install ssh keys"))
return run, nil
}

func (g Graph) compileMountDir(root llb.State) llb.State {
mount := root
for _, m := range g.Mount {
mount = mount.File(llb.Mkdir(m.Destination, 0755, llb.WithParents(true),
llb.WithUIDGID(g.uid, g.gid)),
llb.WithCustomNamef("[internal] create dir for runtime.mount %s", m.Destination),
)
}
return mount
}

0 comments on commit 1af3449

Please sign in to comment.