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

[base/kvm] Add KVM enabled base container #949

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

nrybowski
Copy link
Member

@nrybowski nrybowski commented May 23, 2023

This PR adds a new base container able to launch a specific Linux kernel within a KVM.
New grading environments should inherit from this container as it is the case for the base container.
Task leveraging such grading environments must support the SSH feature of INGInious.

TODO

  • Patch virtme to enable port forwarding for telnet
  • Add a 'KVM' label in the base container to dynamically enable KVM passthrough on the Agents
  • Add 'KVM' flag to Docker Agent
    • Check if KVM is enabled on the Agent environment
  • Automate KVM launch in student container
  • Automate shell redirection to KVM in student container
  • Hardcode qemu-kvm src rpm url
  • Add documentation

TODO in further PRs

  • Use serial port to spawn a shell (see virtme) in the VM rather than using telnet and port forwarding
  • Log the commands typed in the telnet shell as here

"-o", "ForceCommand=echo LOGIN: Good luck !; script -q .ssh_logs; cp .ssh_logs /task/student/.ssh_logs; echo LOGOUT: Good bye!",

Such logs could be used in further grading scripts.

nrybowski added a commit to nrybowski/INGInious-containers that referenced this pull request May 23, 2023
@nrybowski
Copy link
Member Author

This PR should solve #939.

@nrybowski nrybowski marked this pull request as ready for review May 25, 2023 23:24
@nrybowski
Copy link
Member Author

Some slowness is observed during the execution of a simple mininet command such as mn --switch lxbr --topo tree,depth=2,fanout=8 --test pingall at the startup of the fifth switch.
The VM has two cores and 256Mo of RAM but none of those ressources are used at their maximum.
Further investigation is required but do not prevent the integration of this feature which is anyway still experimental.

Copy link
Member

@anthonygego anthonygego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very a first pass. I'd like to see those issues addressed first because I'm wondering if there is a possibility to make this fully modular and if it would be relevant.

Indeed, the added lines seem very tied to the additional container architecture and make code harder to understand. I would know if it's possible to put these additional piece of codes in a kind of hook folder provided in the container image.

@@ -150,13 +165,14 @@ def create_container(self, image, network_grading, mem_limit, task_path, sockets
course_common_student_path: {'bind': '/course/common/student', 'mode': 'ro'}
},
runtime=runtime,
ulimits=[nofile_limit]
ulimits=[nofile_limit],
devices=['/dev/kvm'] if kvm and image_requires_kvm else []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear that unwanted behaviours can happen silently here. If the container image requires kvm and the agent does not support/enable it, no notification will be given. There seems to be no way for the user to know if the agent supports kvm, and, moreover, nothing prevents the job to be assigned to an inappropriate agent.

I'm however more likely to deploy an agent that do support kvm into a cluster of other agents that don't.

For me it would probably be more relevant to implement this as the ssh or nvidia filters : announce another agent type that will allow container images tagged with org.inginious.kvm to be listed as available environment, so that we can ensure appropriate routing and ensure the user selected the right environment.

Implementation of nvidia is here f842bee

However, I realize that implementing a kvm filter, as it may be compatible with other agent type, would require to duplicate all those one to have a kvm-enabled flavour.

Maybe it would be useful to rethink the way this is done and add some kind of feature flags in addition to the agent type, so that we can handle docker or nvidia with ssh or kvm as supported features or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion with @anthonygego, this will be implemented as existing filters (ssh, nvidia, ..).
The features flags common to all the Agents will be grouped in a new data-class.

Front-end side, the grading environment should not include the feature flags in the dropdown and those will be added as check boxes.

base-containers/kvm/Dockerfile Show resolved Hide resolved
@@ -21,6 +21,7 @@ logger = setup_logger()
# Check the runtimes
runtime = sys.argv[1]
parent_runtime = sys.argv[2]
kvm_enabled = sys.argv[3] == "True"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd document the args at both sides, here and at the call side in _docker_interface.py (to avoid implementing a useless argumentparser that would be self documenting)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments managment will be replaced by an argparser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime environments allowing to run as root could provide more capabilities to the containers
2 participants