You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fixes self-re-execution thanks to Open WebUI having merged
open-webui/open-webui#5511.
It also works around more permission issues due to procfs mounts.
Docs updated.
Fixes#11Fixes#12
Updates #2
Updates #3
Copy file name to clipboardExpand all lines: docs/setup.md
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,10 @@ The below is the minimal subset of changes that `--privileged=true` does that is
52
52
* On **Docker**: Add `--mount=type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly=false` to `docker run`.
53
53
* On **Kubernetes**: Add a [`hostPath` volume](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) with `path` set to `/sys/fs/cgroup`, then mount it in your container's `volumeMounts` with options `mountPath` set to `/sys/fs/cgroup` and `readOnly` set to `false`.
54
54
***Why**: This is needed so that gVisor can create child [cgroups](https://en.wikipedia.org/wiki/Cgroups), necessary to enforce per-sandbox resource usage limits.
55
+
***Mount `procfs` at `/proc2`**:
56
+
* On **Docker**: Add `--mount=type=bind,source=/proc,target=/proc2,readonly=false,bind-recursive=disabled` to `docker run`.
57
+
* On **Kubernetes**: Add a [`hostPath` volume](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) with `path` set to `/proc`, then mount it in your container's `volumeMounts` with options `mountPath` set to `/proc2` and `readOnly` set to `false`.
58
+
***Why**: By default, in non-privileged mode, the container runtime will mask certain sub-paths of `/proc` inside the container by creating submounts of `/proc` (e.g. `/proc/bus`, `/proc/sys`, etc.). gVisor does not really care or use anything under these sub-mounts, but *does* need to be able to mount `procfs` in the chroot environment it isolates itself in. However, its ability to mount `procfs` requires having an existing unobstructed view of `procfs` (i.e. a mount of `procfs` with no submounts). Otherwise, such mount attempts will be denied by the kernel (see the explanation for "locked" mounts on [`mount_namespaces(8)`](https://www.man7.org/linux/man-pages/man7/mount_namespaces.7.html)). Therefore, exposing an unobstructed (non-recursive) view of `/proc` elsewhere in the container filesystem (such as `/proc2`) informs the kernel that it is OK for this container to be able to mount `procfs`.
55
59
* Remove the container's default **AppArmor profile**:
56
60
* On **Docker**: Add `--security-opt=apparmor=unconfined` to `docker run`.
57
61
* On **Kubernetes**: Set [`spec.securityContext.appArmorProfile.type`](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-apparmor-profile-for-a-container) to `Unconfined`.
@@ -66,20 +70,22 @@ The below is the minimal subset of changes that `--privileged=true` does that is
66
70
67
71
## Self-test mode
68
72
69
-
To verify that your setup works, you can run the tool in self-test mode using `run_code.py`'s`--use-sample-code` flag.
73
+
To verify that your setup works, you can run the function and the tool in self-test mode using the`--self_test` flag.
70
74
71
75
For example, here is a Docker invocation running the `run_code.py` script inside the Open WebUI container image with the above flags:
sh -c 'python3 /test/open-webui/tools/run_code.py --self_test && python3 /test/open-webui/functions/run_code.py --self_test'
83
89
```
84
90
85
91
If all goes well, you should see:
@@ -97,10 +103,12 @@ If all goes well, you should see:
97
103
✔ Self-test long_running_code passed.
98
104
⏳ Running self-test: ram_hog
99
105
✔ Self-test ram_hog passed.
100
-
✅ All self-tests passed, good go to!
106
+
✅ All tool self-tests passed, good go to!
107
+
...
108
+
✅ All function self-tests passed, good go to!
101
109
```
102
110
103
-
If you get an error, try to add the `--debug`flag at the very end of this command (i.e. as a `run_code.py`flag) for extra information, then file a bug.
111
+
If you get an error, try to add the `--debug`to each `run_code.py`invocation for extra information, then file a bug.
104
112
105
113
## Set valves
106
114
@@ -114,6 +122,7 @@ The code execution tool and function have the following valves available:
114
122
* Useful for multi-user setups to avoid denial-of-service.
115
123
***Auto Install**: Whether to automatically download and install gVisor if not present in the container.
116
124
* If not installed, gVisor will be automatically installed in `/tmp`.
125
+
* You can set the HTTPS proxy used for this download using the `HTTPS_PROXY` environment variable.
117
126
* Useful for convenience, but should be disabled for production setups.
118
127
***Debug**: Whether to produce debug logs.
119
128
* This should never be enabled in production setups as it produces a lot of information that isn't necessary for regular use.
@@ -78,7 +80,7 @@ class Valves(pydantic.BaseModel):
78
80
)
79
81
AUTO_INSTALL: bool=pydantic.Field(
80
82
default=True,
81
-
description=f"Whether to automatically install gVisor if not installed on the system; may be overridden by environment variable {_VALVE_OVERRIDE_ENVIRONMENT_VARIABLE_NAME_PREFIX}AUTO_INSTALL.",
83
+
description=f"Whether to automatically install gVisor if not installed on the system; may be overridden by environment variable {_VALVE_OVERRIDE_ENVIRONMENT_VARIABLE_NAME_PREFIX}AUTO_INSTALL. Use the 'HTTPS_PROXY' environment variable to control the proxy used for download.",
82
84
)
83
85
DEBUG: bool=pydantic.Field(
84
86
default=False,
@@ -105,7 +107,7 @@ class Valves(pydantic.BaseModel):
105
107
)
106
108
WEB_ACCESSIBLE_DIRECTORY_URL: str=pydantic.Field(
107
109
default="/cache/functions/run_code",
108
-
description=f"URL corresponding to WEB_ACCESSIBLE_DIRECTORY_PATH. May start with '/' to make it relative to the Open WebUI serving domain. may be overridden by environment variable {_VALVE_OVERRIDE_ENVIRONMENT_VARIABLE_NAME_PREFIX}WEB_ACCESSIBLE_DIRECTORY_URL.",
110
+
description=f"URL corresponding to WEB_ACCESSIBLE_DIRECTORY_PATH. May start with '/' to make it relative to the Open WebUI serving domain. May be overridden by environment variable {_VALVE_OVERRIDE_ENVIRONMENT_VARIABLE_NAME_PREFIX}WEB_ACCESSIBLE_DIRECTORY_URL.",
"procfs is obstructed; please mount a new procfs mount somewhere in the container, e.g. /proc2 (`--mount=type=bind,source=/proc,target=/proc2,readonly=false`)"
2072
+
)
2073
+
2074
+
@classmethod
2075
+
defunshare(cls, flags):
1988
2076
"""
1989
2077
Implementation of `os.unshare` that works on Python < 3.12.
0 commit comments