Skip to content

Commit

Permalink
issue-24: added build and exec jail timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
briandowns committed Jan 4, 2018
1 parent c998e6d commit 8ab0847
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type Jails struct {
CachePurgeAfter string `json:"cache_purge_after"`
ChildrenMax int `json:"children_max"`
MonitoringAddr string `json:"monitoring_addr"`
BuildTimeout string `json:"build_timeout"`
ExecTimeout string `json:"exec_timeout"`
}

// Config contains the parameters necessary to run sky-island
Expand Down
4 changes: 3 additions & 1 deletion example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"cache_default_expiration": "8h",
"cache_purge_after": "24h",
"children_max": 0,
"monitoring_addr": "127.0.0.1"
"monitoring_addr": "127.0.0.1",
"build_timeout": "10s",
"exec_timeout": "5s"
}
}
4 changes: 2 additions & 2 deletions handlers/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (h *handler) build(id, url, call string) ([]byte, error) {
return nil, err
}
buildCommand := []string{jailGoBin, "build", "-o", "/tmp/" + id, "-v", url + "/cmd"}
fullBuildArgs := []string{"-c", "-n", id, "ip4=disable", "path=" + h.conf.Jails.BaseJailDir + "/build", "host.hostname=build", "mount.devfs"}
fullBuildArgs := []string{"-c", "-n", id, "ip4=disable", "exec.timeout" + h.conf.Jails.BuildTimeout, "path=" + h.conf.Jails.BaseJailDir + "/build", "host.hostname=build", "mount.devfs"}
fullBuildArgs = append(fullBuildArgs, buildCommand...)
buildCmd := exec.Command("jail", fullBuildArgs...)
return buildCmd.CombinedOutput()
Expand All @@ -87,7 +87,7 @@ func (h *handler) execute(id, binPath string, ip4 bool) ([]byte, error) {
return nil, err
}
cm := strconv.Itoa(h.conf.Jails.ChildrenMax)
funcExecArgs := []string{"-c", "-n", id, "children.max=" + cm, "path=" + h.conf.Jails.BaseJailDir + "/" + id, "host.hostname=" + id, "mount.devfs"}
funcExecArgs := []string{"-c", "-n", id, "children.max=" + cm, "exec.timeout" + h.conf.Jails.ExecTimeout, "path=" + h.conf.Jails.BaseJailDir + "/" + id, "host.hostname=" + id, "mount.devfs"}
if ip4 {
ip, err := h.networksvc.Allocate([]byte(id))
if err != nil {
Expand Down

0 comments on commit 8ab0847

Please sign in to comment.