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
The logic for determining when to use coman as an init system has been updated to only activate when a Docker image is specified. This change should be validated to ensure it correctly prevents unintended usage of the init system in non-container environments.
ifletSome(path) = coman_squash {
context.insert("coman_squash",&path);// path to coman squash file on remote// whether to use coman as an init system. Only do this if running an image
context.insert("coman_init",&options.image.is_some());}
A warning message has been added to inform users when no Docker image is specified. It should be verified that this message is clear and helpful for users who might expect SSH or port forwarding functionality without a container.
println!("Warning: No docker image specified (-i), functionality like SSH and port forwarding only works when running a docker image");None};
The sbatch_script_template now includes new template parameters (coman_squash and coman_init) and updates the conditional execution logic. Ensure that these changes align with the intended behavior and that the template correctly handles cases where these parameters are not set.
# coman_squash: the path to the coman squash file# coman_init: whether to use coman as an init system for the command. Needed for SSH/Portforwarding. Only work when using a docker containersbatch_script_template = """#!/bin/bash#SBATCH --job-name={{name}}#SBATCH --ntasks=1#SBATCH --time=10:00:00srun {% if environment_file %}--environment={{environment_file}}{% endif %} {% if coman_init %}/coman/coman exec {% endif %}{{command}}"""
Correctly conditionally invoke coman exec in sbatch template
The template conditionally includes /coman/coman exec based on coman_init, which correctly reflects that coman should only be invoked when running within a Docker container. This ensures proper execution flow for containerized jobs.
+ # coman_squash: the path to the coman squash file+ # coman_init: whether to use coman as an init system for the command. Needed for SSH/Portforwarding. Only work when using a docker container+ sbatch_script_template = """+ #!/bin/bash+ #SBATCH --job-name={{name}}+ #SBATCH --ntasks=1+ #SBATCH --time=10:00:00+-srun {% if environment_file %}--environment={{environment_file}}{% endif %} {% if coman_squash %}/coman/coman exec {% endif %}{{command}}++srun {% if environment_file %}--environment={{environment_file}}{% endif %} {% if coman_init %}/coman/coman exec {% endif %}{{command}}+ """-
Suggestion importance[1-10]: 8
__
Why: This suggestion correctly identifies a key change in the template logic from using coman_squash to coman_init for conditional execution of /coman/coman exec. This is important for ensuring that coman is only invoked when appropriate, enhancing correctness and preventing unintended behavior in non-containerized environments.
Medium
Replace println with structured logging
Consider using a more structured logging approach instead of println! for warnings, especially in a library or application context where log levels and outputs may need to be configurable.
- println!(- "Warning: No docker image specified (-i), functionality like SSH and port forwarding only works when running a docker image"- );+ tracing::warn!("No docker image specified (-i), functionality like SSH and port forwarding only works when running a docker image");
Suggestion importance[1-10]: 6
__
Why: The suggestion proposes using tracing::warn! instead of println! for better logging practices. While this is a good improvement for maintainability and configurability, it's not critical for correctness and doesn't address any immediate bugs or security issues.
Low
Ensure coman init system is properly conditional on image presence
The logic for setting coman_init should be inverted to enable coman as init system only when an image is present. Currently, it's set to true when an image exists, which is correct, but the comment suggests it should only be enabled for images, so ensure this behavior aligns with intended usage.
+ context.insert("coman_squash", &path); // path to coman squash file on remote+ // whether to use coman as an init system. Only do this if running an image+ context.insert("coman_init", &options.image.is_some());-
Suggestion importance[1-10]: 5
__
Why: The suggestion points out a potential logic issue with coman_init flag, but the existing code already correctly sets it based on options.image.is_some(). The improved code provided is identical to the existing code, indicating no actual change is needed, hence a low score.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.