Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suport for discovered SLOs to optimize configure #341

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
12 changes: 10 additions & 2 deletions cmd/optimize/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,13 @@ FROM entities(k8s:deployment)[attributes("k8s.cluster.name") = "{{.Cluster}}" &&
"unable to parse profiler report_contents.optimization_configuration.slo.median_response_time.target into float64: %w", err)
}
// Use rounding for parity with UI logic
newOptimizerConfig.Config.Slo.ErrorPercent.Target = adaptivePrecisionRound(errorPercentTarget, 4)
newOptimizerConfig.Config.Slo.MedianResponseTime.Target = adaptivePrecisionRound(medianResponseTimeTarget, 3)
// discovered values are used after yaml ovverrides are applied
discoveredErrorPercent := adaptivePrecisionRound(errorPercentTarget, 4)
newOptimizerConfig.Config.Slo.ErrorPercent.Target = discoveredErrorPercent
newOptimizerConfig.Config.Slo.ErrorPercent.Discovered = discoveredErrorPercent
discoveredMedianResponseTime := adaptivePrecisionRound(medianResponseTimeTarget, 3)
newOptimizerConfig.Config.Slo.MedianResponseTime.Target = discoveredMedianResponseTime
newOptimizerConfig.Config.Slo.MedianResponseTime.Discovered = discoveredMedianResponseTime

// Set ignored blockers
prefix := "report_contents.optimization_blockers."
Expand Down Expand Up @@ -387,6 +392,9 @@ FROM entities(k8s:deployment)[attributes("k8s.cluster.name") = "{{.Cluster}}" &&
if err != nil {
return fmt.Errorf("yaml.Unmarshal(configBytes, &configStruct): %w", err)
}
// restore original discovered values as they are not allowed to be overidden
newOptimizerConfig.Config.Slo.ErrorPercent.Discovered = discoveredErrorPercent
newOptimizerConfig.Config.Slo.MedianResponseTime.Discovered = discoveredMedianResponseTime
}

// write new config to ORION
Expand Down
6 changes: 4 additions & 2 deletions cmd/optimize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ type Guardrails struct {
Mem Mem `json:"mem"`
}
type ErrorPercent struct {
Target float64 `json:"target"`
Target float64 `json:"target"`
Discovered float64 `json:"discovered"`
}
type MedianResponseTime struct {
Target float64 `json:"target"`
Target float64 `json:"target"`
Discovered float64 `json:"discovered"`
}
type Slo struct {
ErrorPercent ErrorPercent `json:"errorPercent"`
Expand Down
Loading