Skip to content

Conversation

@p1-0tr
Copy link

@p1-0tr p1-0tr commented Oct 10, 2025

Summary by Sourcery

Simplify and centralize controller image handling by extracting version and variant logic into utilities and enabling environment-driven image variant configuration

New Features:

  • Allow overriding the controller image variant via the MODEL_RUNNER_CONTROLLER_VARIANT environment variable

Enhancements:

  • Add controller_image.go with helpers for determining image version, variant, and formatted image tags
  • Refactor EnsureControllerImage, PruneControllerImages, and CreateControllerContainer to use the new image naming utilities
  • Remove inline tag constants and logic in favor of the centralized helper functions

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 10, 2025

Reviewer's Guide

Introduced a centralized controller image naming module that resolves version and variant via environment variables, replacing scattered inline logic across image pulling, pruning, and container creation.

Class diagram for new controller image naming helpers

classDiagram
    class controller_image.go {
        +ControllerImage : string
        +defaultControllerImageVersion : string
        +controllerImageVersion() string
        +controllerImageVariant(detectedGPU gpupkg.GPUSupport) string
        +fmtControllerImageName(repo string, version string, variant string) string
        +controllerImageName(detectedGPU gpupkg.GPUSupport) string
    }
Loading

Class diagram for refactored usage in images.go and containers.go

classDiagram
    class images.go {
        +EnsureControllerImage(ctx, dockerClient, gpu, printer) error
        +PruneControllerImages(ctx, dockerClient, printer) error
    }
    class containers.go {
        +CreateControllerContainer(ctx, dockerClient, port, environment, doNotTrack, gpu, modelStorageVolume, printer, engineKind) error
    }
    class controller_image.go
    images.go --> controller_image.go : uses
    containers.go --> controller_image.go : uses
Loading

File-Level Changes

Change Details Files
Extracted controller image naming logic into standalone helpers
  • Created controller_image.go with version and variant resolution
  • Implemented fmtControllerImageName and controllerImageName functions
  • Replaced hardcoded constants and env lookups
cmd/cli/pkg/standalone/controller_image.go
Replaced inline image name construction with helper calls
  • Updated EnsureControllerImage to use controllerImageName
  • Refactored PruneControllerImages to call fmtControllerImageName
  • Simplified CreateControllerContainer to invoke controllerImageName
cmd/cli/pkg/standalone/images.go
cmd/cli/pkg/standalone/containers.go
Added support for custom controller image variant via environment variable
  • MODEL_RUNNER_CONTROLLER_VARIANT introduced and parsed
  • Allowed overriding default GPU-based variant selection
cmd/cli/pkg/standalone/controller_image.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@p1-0tr p1-0tr force-pushed the ps-ctl-image-variant-env branch from 3da79cc to 28d3bea Compare October 10, 2025 13:15

func fmtControllerImageName(repo, version, variant string) string {
tag := repo + ":" + version
if len(variant) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
if len(variant) > 0 {
if variant != "" {

I guess the compiler produces the same output nowadays.

@p1-0tr p1-0tr marked this pull request as ready for review October 15, 2025 06:35
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider normalizing the MODEL_RUNNER_CONTROLLER_VARIANT value (e.g. trimming whitespace and lowercasing) before use to avoid unexpected tag mismatches.
  • The special-casing of “cpu” and “generic” both mapping to no suffix may be confusing—either document that behavior clearly or adjust the logic to handle a distinct “generic” tag if needed.
  • Add unit tests for the new controller_image.go helpers to validate expected behavior across different environment variable and GPU detection combinations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider normalizing the MODEL_RUNNER_CONTROLLER_VARIANT value (e.g. trimming whitespace and lowercasing) before use to avoid unexpected tag mismatches.
- The special-casing of “cpu” and “generic” both mapping to no suffix may be confusing—either document that behavior clearly or adjust the logic to handle a distinct “generic” tag if needed.
- Add unit tests for the new controller_image.go helpers to validate expected behavior across different environment variable and GPU detection combinations.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@p1-0tr p1-0tr force-pushed the ps-ctl-image-variant-env branch from 28d3bea to bc1483b Compare October 15, 2025 06:38
@ericcurtin ericcurtin merged commit fb5e172 into main Oct 15, 2025
9 checks passed
@ericcurtin ericcurtin deleted the ps-ctl-image-variant-env branch October 15, 2025 11:11
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.

4 participants