Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use an "init service" to load the apparmor profile #63

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions tutorcodejail/patches/k8s-jobs

This file was deleted.

9 changes: 0 additions & 9 deletions tutorcodejail/patches/local-docker-compose-jobs-services

This file was deleted.

15 changes: 15 additions & 0 deletions tutorcodejail/patches/local-docker-compose-services
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ codejailservice:
- ../plugins/codejail/apps/config/tutor.py:/openedx/codejailservice/codejailservice/tutor.py:ro
- ../../data/codejail:/openedx/data
restart: unless-stopped
depends_on:
- codejail-apparmor-loader

codejail-apparmor-loader:
image: {{ CODEJAIL_APPARMOR_DOCKER_IMAGE }}
privileged: true
command:
- /usr/bin/loader
- -logtostderr
- -v=2
- /profiles
volumes:
- ../plugins/codejail/apps/profiles/docker-edx-sandbox:/profiles/docker-edx-sandbox:ro
- /sys:/sys
- /etc/apparmor.d:/etc/apparmor.d
20 changes: 0 additions & 20 deletions tutorcodejail/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,6 @@ def get_apparmor_abi():
]
)

# To add a custom initialization task, create a bash script template under:
# tutorcodejail/templates/codejail/tasks/
# and then add it to the MY_INIT_TASKS list. Each task is in the format:
# ("<service>", ("<path>", "<to>", "<script>", "<template>"))
MY_INIT_TASKS: list[tuple[str, tuple[str, ...], int]] = [
("codejail-apparmor", ("codejail", "tasks", "codejail-apparmor", "init"), hooks.priorities.HIGH),
]


# For each task added to MY_INIT_TASKS, we load the task template
# and add it to the CLI_DO_INIT_TASKS filter, which tells Tutor to
# run it as part of the `init` job.
for service, template_path, priority in MY_INIT_TASKS:
full_path: str = str(
importlib_resources.files("tutorcodejail") / os.path.join("templates", *template_path)
)
with open(full_path, encoding="utf-8") as init_task_file:
init_task: str = init_task_file.read()
hooks.Filters.CLI_DO_INIT_TASKS.add_item((service, init_task), priority=priority)


hooks.Filters.IMAGES_BUILD.add_item((
"codejail",
Expand Down
Empty file.

This file was deleted.

Loading