Skip to content

Autograder Image Builder#2324

Open
coder6583 wants to merge 36 commits into
ec2-testingfrom
somanarita-ec2docker-manager
Open

Autograder Image Builder#2324
coder6583 wants to merge 36 commits into
ec2-testingfrom
somanarita-ec2docker-manager

Conversation

@coder6583
Copy link
Copy Markdown
Contributor

Description

This feature allows instructors to upload Dockerfiles, which will then be used to build the Docker image locally in Tango, and pushed to AWS ECR, so the autograding instances can pull the Docker image and use it to run the autograder.
Another feature we have is the public template image (base docker image). The admiin can upload images on the Manage Base Autograder Images page, and then instructors can upload Dockerfiles that pull from those images (FROM at the top of the file).

Motivation and Context

Currently, there are no ways to create autograding images that can be used on ec2 instances from the frontend.

How Has This Been Tested?

  1. Create a course
  2. On the Manage Course page, you should be able to see a button that says "Manage autograder Images" on the left side.
  3. Click on New Docker Image, enter whatever name you want, and upload a dockerfile with it.
  4. Wait for the docker image to be built, you can refresh the status by either refreshing the page or clicking the refresh all button. When done, it should say "Ready". The View Logs page only works when the build has finished, so you won't be able to see anything when the docker image is building. I am currently working on fixing this.
  5. Create a new assessment and an autograder, and in the autograder settings, choose the newly built image. Only choose the image when it has finished building (the image shows up as "Ready" in the Manage autograder images page).
  6. You should be able to submit a file and see it autograde (hopefully).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Other issues / help required

coder6583 and others added 30 commits April 3, 2026 18:07
#2322)

Filter out non-ready container images in autograder settings and add dockerfile_contents column
@coder6583 coder6583 requested a review from anthony-yip April 17, 2026 01:44
@coder6583 coder6583 changed the base branch from master to ec2-testing April 17, 2026 01:47
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This pull request introduces container image management for autograders and EC2-based autograding configuration. New models, controllers, views, and database migrations enable instructors and administrators to build, manage, and track Docker container images via TangoClient integration. Autograder configuration is expanded to optionally support AWS EC2 credentials and instance types, with encrypted storage for sensitive credentials.

Changes

Cohort / File(s) Summary
Docker & Ruby Configuration
Dockerfile, Gemfile
Updated Docker base image from phusion/passenger-ruby32:2.6.1 to 3.1.6 and Ruby version requirement from 3.2.2 to 3.2.10.
Environment & Routing Configuration
config/environments/development.rb, config/environments/production.rb.template, config/initializers/filter_parameter_logging.rb, config/routes.rb
Added feature flags ec2_docker and ec2_ssh; disabled docker_image_upload_enabled in development. Added filtering for access_key and access_key_id credentials in logs. Added namespaced admin routes for container images and nested course-scoped container image routes with custom actions (refresh_status, log, refresh_all_status).
Database Migrations
db/migrate/20241205233214_*.rb, db/migrate/20241211042124_*.rb, db/migrate/20251021034813_*.rb, db/migrate/20260403212234_*.rb, db/migrate/20260406195046_*.rb, db/migrate/20260407033729_*.rb, db/migrate/20260416010842_*.rb, db/migrate/20260416073038_*.rb, db/migrate/20260416081649_*.rb
Added EC2 SSH fields (instance_type, access_key, access_key_id) to autograders table with encryption migration. Created new container_images table with status enum, image tracking, course association, and public template hierarchy support.
Database Schema
db/schema.rb
Updated schema version to 20260416081649. Added container_images table with indexes and partial unique constraint on public names. Added encrypted credential columns and EC2 instance references to autograders. Added new ami_images, ami_package_sources, and ami_packages tables with associations and indexes.
Core Models
app/models/autograder.rb, app/models/container_image.rb, app/models/course.rb
Added encrypted access_key and access_key_id attributes to Autograder with conditional validations when use_access_key is enabled. Increased autograde_image validation length from 64 to 512 characters. Created new ContainerImage model with status enum (draft, building, ready, disabled, failed), associations to Course and public templates, custom validations, and helper methods. Added has_many :container_images association to Course.
Autograder Controllers
app/controllers/autograders_controller.rb, app/helpers/assessment_autograde_core.rb
Updated autograders_controller to initialize EC2 fields on creation, load available container images in edit view, and handle optional access key clearing during updates. Expanded parameter whitelist for use_access_key, access_key, access_key_id, and instance_type. Refactored tango_add_job to conditionally include EC2 job properties (ec2Vmms, instanceType, accessKey, accessKeyId) when ec2_ssh is enabled.
Container Image Controllers
app/controllers/container_images_controller.rb, app/controllers/admin/container_images_controller.rb
Added ContainerImagesController for course-scoped container image management (CRUD, build via TangoClient.build_image, status refresh with TangoClient.build_status/all_build_status, logging). Added Admin::ContainerImagesController for platform-wide public template management with similar workflows and per-image/bulk status refresh endpoints.
Container Image Views
app/views/container_images/*.html.erb, app/views/admin/container_images/*.html.erb
Added index, new, and log views for course-scoped container images and corresponding admin views. Created _manage_images partial to display image status chips with icons, actions, and ECR URI tooltips. Created _build_log partial to show build progress/logs with status badges and refresh controls. Created _new_image partial for Dockerfile upload form with optional public template selection.
Autograder Views & Forms
app/views/autograders/_form.html.erb, app/views/autograders/_basic_settings.html.erb, app/views/autograders/_ec2_settings.html.erb
Refactored autograder form into tabbed layout with "basic" and conditional "ec2" tabs. Created _basic_settings partial for image selection, timeout, release score, Makefile/tar uploads, and network disabling. Created _ec2_settings partial for access key credential inputs, instance type dropdown with grouped EC2 families, and pricing help text.
Layout & Course Views
app/views/layouts/_navbar.html.erb, app/views/courses/manage.html.erb
Added navbar menu item for administrators to access "Manage Base Autograder Images". Updated course management page to show "Manage autograder images" link when ec2_docker is enabled (instead of legacy upload option).
Stylesheets
app/assets/stylesheets/container_images.scss, app/assets/stylesheets/style.css.scss
Created container_images.scss with status chip components (draft/building/ready/disabled/error variants), status icons, layout helpers, and tooltip styling. Added button and label styles to style.css.scss.
JavaScript
app/assets/javascripts/autograder.js
Added autograder form interactions: toggle access key fields based on checkbox state with field clearing, EC2 instance type dropdown with hover highlighting and console logging, jQuery tooltip initialization.
External Service Client
lib/tango_client.rb
Added three new TangoClient class methods: build_image (posts Dockerfile for build queue), build_status (polls individual build status and image URI), all_build_status (fetches all queued builds).

Sequence Diagram(s)

sequenceDiagram
    participant Instructor as Instructor/<br/>Browser
    participant Controller as ContainerImages<br/>Controller
    participant Model as ContainerImage<br/>Model
    participant Tango as TangoClient
    participant DB as Database
    
    Instructor->>Controller: Upload Dockerfile (new/create)
    activate Controller
    Controller->>Tango: build_image(dockerfile_content)
    activate Tango
    Tango-->>Controller: { status, build_id }
    deactivate Tango
    Controller->>Model: Create with status=draft, build_id
    activate Model
    Model->>DB: Insert container_image
    deactivate Model
    Controller-->>Instructor: Redirect to image log
    deactivate Controller
    
    rect rgba(200, 200, 255, 0.5)
    Note over Instructor,Tango: Build In Progress (polling)
    end
    
    Instructor->>Controller: Refresh status / Refresh All
    activate Controller
    Controller->>Tango: build_status(build_id)
    activate Tango
    Tango-->>Controller: { status, image_uri, logs }
    deactivate Tango
    Controller->>Model: Update with status, image_uri, build_logs
    activate Model
    Model->>DB: Update container_image
    deactivate Model
    Controller-->>Instructor: Display updated status & logs
    deactivate Controller
    
    rect rgba(200, 255, 200, 0.5)
    Note over Instructor,DB: Build Ready - image_uri populated
    end
Loading
sequenceDiagram
    participant Instructor as Instructor/<br/>Browser
    participant Form as Autograder<br/>Form (EC2 Tab)
    participant Controller as Autograders<br/>Controller
    participant Model as Autograder<br/>Model
    participant Encryption as Encryption<br/>Layer
    participant DB as Database
    
    Instructor->>Form: Enter access key credentials
    Instructor->>Form: Select instance type
    Instructor->>Form: Submit form
    
    Form->>Controller: POST with access_key, access_key_id, instance_type
    activate Controller
    
    alt use_access_key enabled
        Controller->>Model: Create/Update autograder
        activate Model
        Model->>Encryption: Encrypt access_key
        activate Encryption
        Encryption-->>Model: access_key_ciphertext
        deactivate Encryption
        Model->>Encryption: Encrypt access_key_id
        activate Encryption
        Encryption-->>Model: access_key_id_ciphertext
        deactivate Encryption
        Model->>DB: Save with encrypted credentials
        deactivate Model
    else use_access_key disabled
        Controller->>Model: Set access_key, access_key_id to nil
        activate Model
        Model->>DB: Save (credentials cleared)
        deactivate Model
    end
    
    Controller-->>Instructor: Display success message
    deactivate Controller
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Autograder Image Builder' accurately and concisely describes the main feature: enabling instructors to build autograder Docker images via Dockerfiles.
Description check ✅ Passed The PR description follows the template structure and includes all critical sections: a clear description of the feature, motivation/context, detailed testing steps, and type of change checkbox selected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch somanarita-ec2docker-manager

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coder6583 coder6583 mentioned this pull request Apr 17, 2026
6 tasks
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.

2 participants