-
Notifications
You must be signed in to change notification settings - Fork 11
fix(apptainer): ensure apptainer jobs run as privileged #62
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
base: main
Are you sure you want to change the base?
Conversation
Apptainer jobs require privileged access to function correctly, for instance to mount volumes and manage cgroups. The previous implementation incorrectly relied on `job.is_containerized` to enable privileged mode for Apptainer jobs. I suspect this flag is intended for use with the `--containerize` option and does not reliably indicate that a job is running in a container. This commit enables privileged mode whenever the Apptainer deployment method is used.
📝 WalkthroughWalkthroughA conditional block setting container privileged mode for APPTAINER containerized jobs was removed and consolidated. Privileged mode is now centrally determined by checking if either an explicit privileged flag is set or APPTAINER is among the deployment methods. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
snakemake_executor_plugin_kubernetes/__init__.py (1)
84-87: Update documentation to reflect Apptainer auto-enable behavior.Consider updating the help text for the
privilegedsetting to clarify that privileged mode is automatically enabled when using the Apptainer deployment method, even if this flag is set toFalse.Apply this diff to improve the documentation:
privileged: Optional[bool] = field( default=False, - metadata={"help": "Create privileged containers for jobs."}, + metadata={"help": "Create privileged containers for jobs. Note: privileged mode is automatically enabled when using Apptainer deployment method."}, )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
snakemake_executor_plugin_kubernetes/__init__.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
⚙️ CodeRabbit configuration file
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
Files:
snakemake_executor_plugin_kubernetes/__init__.py
🧠 Learnings (1)
📚 Learning: 2024-08-14T14:18:38.175Z
Learnt from: johanneskoester
Repo: snakemake/snakemake-executor-plugin-kubernetes PR: 22
File: snakemake_executor_plugin_kubernetes/__init__.py:32-39
Timestamp: 2024-08-14T14:18:38.175Z
Learning: Do not suggest type annotation of the `self` argument of methods in the Snakemake executor plugin for Kubernetes.
Applied to files:
snakemake_executor_plugin_kubernetes/__init__.py
🔇 Additional comments (1)
snakemake_executor_plugin_kubernetes/__init__.py (1)
350-353: The code usage pattern confirmsdeployment_methodis a collection type.Based on verification:
deployment_methodis accessed fromself.workflow.deployment_settings(Snakemake core package)- The code uses the
inoperator at line 352:DeploymentMethod.APPTAINER in self.workflow.deployment_settings.deployment_method, which only works with collection types (list, set, tuple, or custom types with__contains__)- If
deployment_methodwas a single enum value, the code would fail with aTypeErrorat runtime- The pattern is consistent with supporting multiple deployment methods
The consolidated logic is correct and properly checks whether Apptainer is among the configured deployment methods. However, since
deployment_methodis from the external Snakemake package (not verifiable within this repository), manually confirm that your version of the Snakemake package documentsdeployment_methodas a collection type and that this code works correctly in your test environment before merging.
Hi,
Honestly, I'm not really sure about this one, I may just be missing the obvious. Feel free to close that PR if that's the case.
I wasn't able to reach the branch where the container is set as privileged when running in Apptainer because
job.is_containerizedwould always evaluate to false, regardless of the snakemake flags I use. I believe checking the deployment method is sufficient to detect for container jobs, and avoid the explicit use of--kubernetes-privileged trueflag.Summary by CodeRabbit
Bug Fixes