Skip to content

Commit

Permalink
Merge pull request #4987 from dodona-edu/fix/infinite-docker
Browse files Browse the repository at this point in the history
Fix docker images not being shut down
  • Loading branch information
jorg-vr authored Sep 20, 2023
2 parents 6f766b2 + 78e05b6 commit 7ba9ddd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/runners/submission_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def execute
while Time.zone.now - before_time < time_limit
before_stats = Time.zone.now
# Check if container is still running
if !Rails.env.test? && (Docker::Container.any? { |c| c.id.starts_with?(container.id) || container.id.starts_with?(container.id) } && container.refresh!.info['State']['Running'])
if !Rails.env.test? && (Docker::Container.all.any? { |c| c.id.starts_with?(container.id) || container.id.starts_with?(container.id) } && container.refresh!.info['State']['Running']) # rubocop:disable Rails/RedundantActiveRecordAllMethod
# If we don't pass these extra options gathering stats takes 1+ seconds (https://github.com/moby/moby/issues/23188#issuecomment-223211481)
stats = container.stats({ 'one-shot': true, stream: false })
memory = [stats['memory_stats']['usage'] / (1024.0 * 1024.0), memory].max if stats['memory_stats']&.fetch('usage', nil)
Expand Down

0 comments on commit 7ba9ddd

Please sign in to comment.