Skip to content

Commit

Permalink
fix: panic if the user specify entrypoint for non-costom image (#1108)
Browse files Browse the repository at this point in the history
* fix: panic if user specify the entrypoint in non-custom image

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

* update err msg

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

Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy authored Oct 28, 2022
1 parent 8f89ba6 commit 214f7c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pkg/lang/ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ func (g Graph) Compile(uid, gid int) (llb.State, error) {
run := g.compileRun(copy)
git := g.compileGit(run)
user := g.compileUserOwn(git)
entrypoint := g.compileEntrypoint(user)
entrypoint, err := g.compileEntrypoint(user)
if err != nil {
return llb.State{}, errors.Wrap(err, "failed to compile entrypoint")
}
g.Writer.Finish()
return entrypoint, nil
}
10 changes: 7 additions & 3 deletions pkg/lang/ir/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path/filepath"
"strings"

"github.com/cockroachdb/errors"
"github.com/moby/buildkit/client/llb"

"github.com/tensorchord/envd/pkg/config"
Expand Down Expand Up @@ -78,9 +79,12 @@ func (g Graph) addNewProcess(root llb.State, name, command string, depends []str
return supervisor
}

func (g Graph) compileEntrypoint(root llb.State) llb.State {
func (g Graph) compileEntrypoint(root llb.State) (llb.State, error) {
if g.Image != nil {
return root
return root, nil
}
if len(g.Entrypoint) > 0 {
return root, errors.New("`config.entrypoint` is only for custom image, maybe you need `runtime.init`")
}
cmd := fmt.Sprintf("/var/envd/bin/envd-sshd --port %d --shell %s", config.SSHPortInContainer, g.Shell)
entrypoint := g.addNewProcess(root, "sshd", cmd, nil)
Expand Down Expand Up @@ -108,5 +112,5 @@ func (g Graph) compileEntrypoint(root llb.State) llb.State {
entrypoint = g.addNewProcess(entrypoint, "rstudio", strings.Join(rstudioCmd, " "), deps)
}

return entrypoint
return entrypoint, nil
}

0 comments on commit 214f7c8

Please sign in to comment.