fix(nim): use published Docker port in status checks#1022
fix(nim): use published Docker port in status checks#1022cr7258 wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded Changes
Sequence DiagramsequenceDiagram
participant Caller as Caller
participant nimStatusByName as nimStatusByName()
participant Docker as Docker CLI
participant HealthCheck as HTTP Health Check
Caller->>nimStatusByName: nimStatusByName(containerName, port?)
nimStatusByName->>Docker: docker inspect containerName
Docker-->>nimStatusByName: container state (running/stopped)
alt Container Running
alt Port Parameter Provided
nimStatusByName->>HealthCheck: curl http://localhost:PORT/v1/models
HealthCheck-->>nimStatusByName: health status
else Port Parameter Not Provided
nimStatusByName->>Docker: docker port containerName 8000
Docker-->>nimStatusByName: hostPort mapping
alt Mapping Found
nimStatusByName->>HealthCheck: curl http://localhost:MAPPED_PORT/v1/models
HealthCheck-->>nimStatusByName: health status
else No Mapping
nimStatusByName->>HealthCheck: curl http://localhost:8000/v1/models
HealthCheck-->>nimStatusByName: health status (fallback)
end
end
else Container Stopped
nimStatusByName-->>Caller: { running: false, healthy: false }
end
nimStatusByName-->>Caller: { running: boolean, healthy: boolean }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
nimStatusByName()previously hardcoded its health check to localhost:8000, which caused false unhealthy reports when a NIM container was published on a non-default host port. This change uses the explicit port when provided, otherwise resolves the published port viadocker portcommand.Related Issue
Fixes #1016
Changes
nimStatusByName()so it no longer hardcodeslocalhost:8000for health checksdocker port <container> 80008000if Docker port lookup fails and skip health checks when the container is not runningType of Change
Testing
npx prek run --all-filespasses (or equivalentlymake check).npm testpasses.make docsbuilds without warnings. (for doc-only changes)npx vitest run test/nim.test.js RUN v4.1.0 /Users/sevenc/code/ai/agent/NemoClaw ✓ cli test/nim.test.js (13 tests) 3751ms ✓ nim (13) ✓ listModels (2) ✓ returns 5 models 1ms ✓ each model has name, image, and minGpuMemoryMB 0ms ✓ getImageForModel (2) ✓ returns correct image for known model 0ms ✓ returns null for unknown model 0ms ✓ containerName (1) ✓ prefixes with nemoclaw-nim- 0ms ✓ detectGpu (3) ✓ returns object or null 1149ms ✓ nvidia type is nimCapable 1150ms ✓ apple type is not nimCapable 1180ms ✓ nimStatus (1) ✓ returns not running for nonexistent container 265ms ✓ nimStatusByName (4) ✓ uses provided port directly 1ms ✓ uses published docker port when no port is provided 1ms ✓ falls back to 8000 when docker port lookup fails 0ms ✓ does not run health check when container is not running 1ms Test Files 1 passed (1) Tests 13 passed (13) Start at 12:34:32 Duration 3.91s (transform 19ms, setup 0ms, import 75ms, tests 3.75s, environment 0ms)Checklist
General
Code Changes
npx prek run --all-filesauto-fixes formatting (ormake formatfor targeted runs).Doc Changes
update-docsagent skill to draft changes while complying with the style guide. For example, prompt your agent with "/update-docscatch up the docs for the new changes I made in this PR."Summary by CodeRabbit
Release Notes
New Features
Tests