Skip to content

Commit 98c016d

Browse files
authored
Don't pull images in k8s (#889)
As part of refactoring the runtime interface, I caused the proxy process to attempt to pull down images when running in k8s. Handle this with a conditional guard for now. Given the current plan to split the k8s logic apart further, we may come up with a more natural split in future. At very least, we can consider having a no-op image puller.
1 parent 26075b5 commit 98c016d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cmd/thv/app/run.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/stacklok/toolhive/pkg/logger"
1212
"github.com/stacklok/toolhive/pkg/permissions"
1313
"github.com/stacklok/toolhive/pkg/process"
14+
"github.com/stacklok/toolhive/pkg/registry"
1415
"github.com/stacklok/toolhive/pkg/runner"
1516
"github.com/stacklok/toolhive/pkg/runner/retriever"
1617
"github.com/stacklok/toolhive/pkg/transport"
@@ -242,12 +243,20 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
242243
envVarValidator = &runner.CLIEnvVarValidator{}
243244
}
244245

245-
// Take the MCP server we were supplied and either fetch the image, or
246-
// build it from a protocol scheme. If the server URI refers to an image
247-
// in our trusted registry, we will also fetch the image metadata.
248-
imageURL, imageMetadata, err := retriever.GetMCPServer(ctx, serverOrImage, runCACertPath, runVerifyImage)
249-
if err != nil {
250-
return fmt.Errorf("failed to find or create the MCP server %s: %v", serverOrImage, err)
246+
var imageMetadata *registry.ImageMetadata
247+
imageURL := serverOrImage
248+
249+
// Only pull image if we are not running in Kubernetes mode.
250+
// This split will go away if we implement a separate command or binary
251+
// for running MCP servers in Kubernetes.
252+
if !container.IsKubernetesRuntime() {
253+
// Take the MCP server we were supplied and either fetch the image, or
254+
// build it from a protocol scheme. If the server URI refers to an image
255+
// in our trusted registry, we will also fetch the image metadata.
256+
imageURL, imageMetadata, err = retriever.GetMCPServer(ctx, serverOrImage, runCACertPath, runVerifyImage)
257+
if err != nil {
258+
return fmt.Errorf("failed to find or create the MCP server %s: %v", serverOrImage, err)
259+
}
251260
}
252261

253262
// Initialize a new RunConfig with values from command-line flags

0 commit comments

Comments
 (0)