Unverified Commit 390a3397 authored by julienmancuso's avatar julienmancuso Committed by GitHub
Browse files

fix: do not fail if backendFramework cannot be detected (#2655)

parent 266265ea
...@@ -1012,7 +1012,7 @@ func detectBackendFrameworkFromArgs(command []string, args []string) (BackendFra ...@@ -1012,7 +1012,7 @@ func detectBackendFrameworkFromArgs(command []string, args []string) (BackendFra
} }
if len(detected) == 0 { if len(detected) == 0 {
return "", fmt.Errorf("no backend framework detected from command: %q", fullCommand) return BackendFrameworkNoop, nil
} }
if len(detected) > 1 { if len(detected) > 1 {
...@@ -1059,13 +1059,13 @@ func determineBackendFramework( ...@@ -1059,13 +1059,13 @@ func determineBackendFramework(
} }
// Validate consistency if both detected and explicit exist // Validate consistency if both detected and explicit exist
if detectedFramework != "" && explicitFramework != "" && detectedFramework != explicitFramework { if detectedFramework != "" && detectedFramework != BackendFrameworkNoop && explicitFramework != "" && detectedFramework != explicitFramework {
return "", fmt.Errorf("backend framework mismatch: detected %q from command but explicitly configured as %q", return "", fmt.Errorf("backend framework mismatch: detected %q from command but explicitly configured as %q",
detectedFramework, explicitFramework) detectedFramework, explicitFramework)
} }
// Return in order of preference: detected > explicit > error // Return in order of preference: detected > explicit > error
if detectedFramework != "" { if detectedFramework != "" && detectedFramework != BackendFrameworkNoop {
return detectedFramework, nil return detectedFramework, nil
} }
...@@ -1079,7 +1079,7 @@ func determineBackendFramework( ...@@ -1079,7 +1079,7 @@ func determineBackendFramework(
} }
// No command/args to detect from and no explicit config // No command/args to detect from and no explicit config
return "", fmt.Errorf("backend framework must be specified explicitly or detectable from command/args") return BackendFrameworkNoop, nil
} }
// getBackendFrameworkFromComponent attempts to determine backend framework using hybrid approach: // getBackendFrameworkFromComponent attempts to determine backend framework using hybrid approach:
......
...@@ -3626,10 +3626,10 @@ func TestDetectBackendFrameworkFromArgs(t *testing.T) { ...@@ -3626,10 +3626,10 @@ func TestDetectBackendFrameworkFromArgs(t *testing.T) {
expected: BackendFrameworkSGLang, expected: BackendFrameworkSGLang,
}, },
{ {
name: "no backend detected", name: "no backend detected",
command: []string{"/bin/sh", "-c"}, command: []string{"/bin/sh", "-c"},
args: []string{"echo hello world"}, args: []string{"echo hello world"},
expectError: true, expected: BackendFrameworkNoop,
}, },
{ {
name: "multiple backends detected", name: "multiple backends detected",
...@@ -3709,17 +3709,17 @@ func TestDetermineBackendFramework(t *testing.T) { ...@@ -3709,17 +3709,17 @@ func TestDetermineBackendFramework(t *testing.T) {
errorContains: "backend framework mismatch", errorContains: "backend framework mismatch",
}, },
{ {
name: "worker with no detection, no explicit - returns error", name: "worker with no detection, no explicit - returns noop",
componentType: "worker", componentType: "worker",
expectError: true, expected: BackendFrameworkNoop,
errorContains: "backend framework must be specified explicitly or detectable from command/args", expectError: false,
}, },
{ {
name: "worker with detection failure, no explicit - returns error", name: "worker with detection failure, no explicit - returns noop",
componentType: "worker", componentType: "worker",
args: []string{"echo hello world"}, args: []string{"echo hello world"},
expectError: true, expected: BackendFrameworkNoop,
errorContains: "could not determine backend framework", expectError: false,
}, },
} }
...@@ -3843,18 +3843,18 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) { ...@@ -3843,18 +3843,18 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) {
expected: BackendFrameworkNoop, expected: BackendFrameworkNoop,
}, },
{ {
name: "worker with no detection, no explicit - returns error", name: "worker with no detection, no explicit - returns noop",
component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{ component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{
DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{ DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{
ComponentType: "worker", // Worker component ComponentType: "worker", // Worker component
}, },
}, },
deployment: &v1alpha1.DynamoGraphDeployment{}, deployment: &v1alpha1.DynamoGraphDeployment{},
expectError: true, expected: BackendFrameworkNoop,
errorContains: "backend framework must be specified explicitly or detectable from command/args", expectError: false,
}, },
{ {
name: "worker with detection failure, no explicit - returns error", name: "worker with detection failure, no explicit - returns noop",
component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{ component: &v1alpha1.DynamoComponentDeploymentOverridesSpec{
DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{ DynamoComponentDeploymentSharedSpec: v1alpha1.DynamoComponentDeploymentSharedSpec{
ComponentType: "worker", // Worker component ComponentType: "worker", // Worker component
...@@ -3865,9 +3865,9 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) { ...@@ -3865,9 +3865,9 @@ func TestGetBackendFrameworkFromComponent(t *testing.T) {
}, },
}, },
}, },
deployment: &v1alpha1.DynamoGraphDeployment{}, deployment: &v1alpha1.DynamoGraphDeployment{},
expectError: true, expected: BackendFrameworkNoop,
errorContains: "could not determine backend framework", expectError: false,
}, },
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment