Skip to content

Commit 1ac3ee9

Browse files
committed
Update kernels to work with latest Backend.AI agent.
1 parent 9b8e7ca commit 1ac3ee9

File tree

10 files changed

+77
-164
lines changed

10 files changed

+77
-164
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ docs/_build/
5757
# PyBuilder
5858
target/
5959

60-
# etc
60+
# autoenv / direnv
6161
.env
62+
.envrc
6263

6364
# Generate binaries for images
6465
*/jail
@@ -71,6 +72,7 @@ old/*/jail-check
7172
old/*/intra-jail-check
7273

7374
node_modules/
75+
yarn.lock
7476

7577
.*.swp
7678
venv*

c/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def __init__(self):
3535
super().__init__()
3636
self.child_env.update(CHILD_ENV)
3737

38+
async def init_with_loop(self):
39+
pass
40+
3841
async def build(self, build_cmd):
3942
if build_cmd is None or build_cmd == '':
4043
# skipped
@@ -90,6 +93,10 @@ async def query(self, code_text):
9093
async def complete(self, data):
9194
return []
9295

96+
async def interrupt(self):
97+
# subproc interrupt is already handled by BaseRunner
98+
pass
99+
93100

94101
if __name__ == '__main__':
95102
CProgramRunner().run()

cpp/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def __init__(self):
3535
super().__init__()
3636
self.child_env.update(CHILD_ENV)
3737

38+
async def init_with_loop(self):
39+
pass
40+
3841
async def build(self, build_cmd):
3942
if build_cmd is None or build_cmd == '':
4043
# skipped
@@ -88,6 +91,10 @@ async def query(self, code_text):
8891
async def complete(self, data):
8992
return []
9093

94+
async def interrupt(self):
95+
# subproc interrupt is already handled by BaseRunner
96+
pass
97+
9198

9299
if __name__ == '__main__':
93100
CPPProgramRunner().run()

go/Dockerfile

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,19 @@
1-
# Dockerfile ref: https://github.com/docker-library/golang (official golang docker package)
2-
FROM lablup/kernel-base-python3-minimal:latest
3-
MAINTAINER DevOps "devops@lablup.com"
1+
FROM golang:1.9.0-alpine3.6 as go-binary
42

5-
ENV GOLANG_VERSION 1.8.1
63

7-
# Install Python packages
8-
RUN pip install --no-cache-dir aiozmq
4+
FROM lablup/kernel-base-python3-minimal:latest
95

106
# Install Go environments
7+
COPY --from=go-binary /usr/local/go /usr/local/
118
RUN apk add --no-cache ca-certificates
12-
# https://golang.org/issue/14851 (Go 1.8 & 1.7)
13-
COPY *.patch /go-alpine-patches/
14-
RUN set -eux; \
15-
apk add --no-cache --virtual .build-deps \
16-
bash \
17-
gcc \
18-
musl-dev \
19-
openssl \
20-
go
21-
RUN export \
22-
# set GOROOT_BOOTSTRAP such that we can actually build Go
23-
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
24-
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
25-
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
26-
GOOS="$(go env GOOS)" \
27-
GOARCH="$(go env GOARCH)" \
28-
GO386="$(go env GO386)" \
29-
GOARM="$(go env GOARM)" \
30-
GOHOSTOS="$(go env GOHOSTOS)" \
31-
GOHOSTARCH="$(go env GOHOSTARCH)" \
32-
; \
33-
\
34-
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
35-
echo '33daf4c03f86120fdfdc66bddf6bfff4661c7ca11c5da473e537f4d69b470e57 *go.tgz' | sha256sum -c -; \
36-
tar -C /usr/local -xzf go.tgz; \
37-
rm go.tgz; \
38-
\
39-
cd /usr/local/go/src; \
40-
for p in /go-alpine-patches/*.patch; do \
41-
[ -f "$p" ] || continue; \
42-
patch -p2 -i "$p"; \
43-
done; \
44-
./make.bash; \
45-
\
46-
rm -rf /go-alpine-patches; \
47-
apk del .build-deps; \
48-
\
49-
export PATH="/usr/local/go/bin:$PATH"; \
50-
go version
519

5210
ENV GOPATH /home/work
5311
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
5412

5513
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5614
WORKDIR $GOPATH
5715

58-
COPY go-wrapper /usr/local/bin/
59-
60-
COPY run.py /home/sorna/run.py
16+
COPY run.py /home/sorna/
17+
COPY policy.yml /home/sorna/
6118

62-
USER work
63-
CMD ["/home/sorna/jail", "python3", "/usr/local/bin/python3", "/home/sorna/run.py"]
19+
LABEL io.sorna.features "batch query uid-match user-input"

go/go-wrapper

Lines changed: 0 additions & 97 deletions
This file was deleted.

go/no-pic.patch

Lines changed: 0 additions & 16 deletions
This file was deleted.

go/policy.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
whitelist_paths:
2+
OP_OPEN: ["*"]
3+
OP_ACCESS: ["*"]
4+
OP_EXEC: ["*"]
5+
OP_STAT: ["*"]
6+
OP_CHMOD: ["/home/work/*", "/tmp/*"]
7+
exec_allowance: -1
8+
fork_allowance: -1
9+
max_child_procs: 32
10+
extra_envs: []
11+
preserved_env_keys: [
12+
"HOME", "PATH", "LANG",
13+
"USER", "SHELL", "TERM",
14+
"LD_LIBRARY_PATH",
15+
"LD_PRELOAD",
16+
# Python-specific
17+
"PYTHONPATH",
18+
"PYTHONUNBUFFERED",
19+
"MPLCONFIGDIR",
20+
"OPENBLAS_NUM_THREADS",
21+
]
22+
23+
diff_to_default: true
24+
25+
# Following syscalls are blindly allowed.
26+
# IMPORTANT: ptrace MUST NOT be included!
27+
allowed_syscalls:

go/run.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def __init__(self):
3434
super().__init__()
3535
self.child_env.update(CHILD_ENV)
3636

37+
async def init_with_loop(self):
38+
pass
39+
3740
async def build(self, build_cmd):
3841
if build_cmd is None or build_cmd == '':
3942
# skipped
@@ -69,6 +72,13 @@ async def query(self, code_text):
6972
cmd = f'go run {tmpf.name}'
7073
await self.run_subproc(cmd)
7174

75+
async def complete(self, data):
76+
return []
77+
78+
async def interrupt(self):
79+
# subproc interrupt is already handled by BaseRunner
80+
pass
81+
7282

7383
if __name__ == '__main__':
7484
GoProgramRunner().run()

java8/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def __init__(self):
4040
super().__init__()
4141
self.child_env = CHILD_ENV
4242

43+
async def init_with_loop(self):
44+
pass
45+
4346
async def build(self, build_cmd):
4447
if build_cmd is None or build_cmd == '':
4548
# skipped
@@ -105,6 +108,10 @@ async def query(self, code_text):
105108
async def complete(self, data):
106109
return []
107110

111+
async def interrupt(self):
112+
# subproc interrupt is already handled by BaseRunner
113+
pass
114+
108115

109116
def main():
110117
JavaProgramRunner().run()

rust/run.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self):
3333
super().__init__()
3434
self.child_env.update(CHILD_ENV)
3535

36+
async def init_with_loop(self):
37+
pass
38+
3639
async def build(self, build_cmd):
3740
if build_cmd is None or build_cmd == '':
3841
# skipped
@@ -67,6 +70,13 @@ async def query(self, code_text):
6770
cmd = f'rustc {tmpf.name} && chmod 755 ./{fname} && ./{fname}'
6871
await self.run_subproc(cmd)
6972

73+
async def complete(self, data):
74+
return []
75+
76+
async def interrupt(self):
77+
# subproc interrupt is already handled by BaseRunner
78+
pass
79+
7080

7181
if __name__ == '__main__':
7282
RustProgramRunner().run()

0 commit comments

Comments
 (0)