Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions pkg/bundler/validations/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ func RunValidations(ctx context.Context, componentName string, validations []rec
// Execute validation function
checkWarnings, checkErrors := fn(ctx, componentName, recipeResult, bundlerConfig, validation.Conditions)

// Process results based on severity
// If severity is "error", convert warnings to errors
// If severity is "warning", keep as warnings
// Process results based on severity:
// "error" — convert all check results to blocking errors
// "info" — log only (visible with --debug), not surfaced in deployment notes
// "warning" — (default) non-blocking deployment notes
severity := strings.ToLower(validation.Severity)
if severity == "error" {
switch severity {
case "error":
Comment thread
mchmarny marked this conversation as resolved.
// Convert all check results to errors
for _, warning := range checkWarnings {
msg := warning
Expand All @@ -121,7 +123,25 @@ func RunValidations(ctx context.Context, componentName string, validations []rec
errors = append(errors, err)
}
}
} else {
case "info":
// Log as informational only — not surfaced in deployment notes.
// Visible when debug logging is enabled (--debug).
for _, warning := range checkWarnings {
msg := warning
if validation.Message != "" {
msg = warning + ". " + validation.Message
}
slog.Info(msg, "component", componentName)
}
for _, err := range checkErrors {
slog.Info("validation check reported error",
"component", componentName,
"function", validation.Function,
"message", validation.Message,
"error", err,
)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
default:
// Default to warning severity
for _, warning := range checkWarnings {
if validation.Message != "" {
Expand Down
46 changes: 46 additions & 0 deletions pkg/bundler/validations/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,52 @@ func TestRunValidations(t *testing.T) {
wantMsgInWarn: false,
wantMsg: "This is an error",
},
{
name: "info severity suppresses warnings",
componentName: "nodewright-customizations",
validations: []recipe.ComponentValidationConfig{
{
Function: "CheckWorkloadSelectorMissing",
Severity: "info",
Conditions: map[string][]string{"intent": {"training"}},
Message: "Consider setting --workload-selector",
},
},
recipeResult: &recipe.RecipeResult{
ComponentRefs: []recipe.ComponentRef{
{Name: "nodewright-customizations"},
},
Criteria: &recipe.Criteria{
Intent: recipe.CriteriaIntentTraining,
},
},
bundlerConfig: config.NewConfig(),
wantWarnings: 0,
wantErrors: 0,
},
{
name: "info severity suppresses errors from checks",
componentName: "nodewright-customizations",
validations: []recipe.ComponentValidationConfig{
{
Function: "CheckAcceleratedSelectorMissing",
Severity: "info",
Conditions: map[string][]string{"intent": {"training", "inference"}},
Message: "Consider setting --accelerated-node-selector",
},
},
recipeResult: &recipe.RecipeResult{
ComponentRefs: []recipe.ComponentRef{
{Name: "nodewright-customizations"},
},
Criteria: &recipe.Criteria{
Intent: recipe.CriteriaIntentTraining,
},
},
bundlerConfig: config.NewConfig(),
wantWarnings: 0,
wantErrors: 0,
},
}

for _, tt := range tests {
Expand Down
8 changes: 4 additions & 4 deletions pkg/recipe/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ func TestComponentRegistry_Validations(t *testing.T) {
for _, v := range validations {
if v.Function == "CheckWorkloadSelectorMissing" {
foundWorkloadSelector = true
if v.Severity != "warning" {
t.Errorf("CheckWorkloadSelectorMissing should have severity 'warning', got %q", v.Severity)
if v.Severity != "info" {
t.Errorf("CheckWorkloadSelectorMissing should have severity 'info', got %q", v.Severity)
}
if v.Conditions == nil {
t.Error("CheckWorkloadSelectorMissing should have conditions")
Expand All @@ -305,8 +305,8 @@ func TestComponentRegistry_Validations(t *testing.T) {
}
if v.Function == "CheckAcceleratedSelectorMissing" {
foundAcceleratedSelector = true
if v.Severity != "warning" {
t.Errorf("CheckAcceleratedSelectorMissing should have severity 'warning', got %q", v.Severity)
if v.Severity != "info" {
t.Errorf("CheckAcceleratedSelectorMissing should have severity 'info', got %q", v.Severity)
}
if v.Conditions == nil {
t.Error("CheckAcceleratedSelectorMissing should have conditions")
Expand Down
4 changes: 2 additions & 2 deletions recipes/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ components:
- workloadSelector
validations:
- function: CheckWorkloadSelectorMissing
severity: warning
severity: info
conditions:
intent:
- training
message: "This may cause nodewright to evict running training jobs. Consider setting --workload-selector to prevent eviction."
- function: CheckAcceleratedSelectorMissing
severity: warning
severity: info
conditions:
intent:
- training
Expand Down
Loading