-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtiny_request.go
More file actions
66 lines (54 loc) · 2.28 KB
/
Copy pathtiny_request.go
File metadata and controls
66 lines (54 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package rules
import (
"fmt"
"github.com/optiqor/optiqor-cli/pkg/parser"
)
// tinyCPURequest and tinyMemoryRequest fire when a workload sets
// requests so small they're almost certainly placeholders. They
// surface as LOW: probably a typo or copy-paste from a Helm scaffold,
// not a deliberate choice. Catching them early prevents charts from
// shipping with effectively-zero scheduling weight.
const (
tinyCPUMillicores = 10 // 10m
tinyMemoryBytes = 32 * 1024 * 1024 // 32 MiB
)
type tinyCPURequest struct{}
func newTinyCPURequest() Detector { return tinyCPURequest{} }
func (tinyCPURequest) ID() string { return "tiny-cpu-request" }
func (tinyCPURequest) Name() string { return "Suspiciously small CPU request" }
func (tinyCPURequest) Run(w parser.Workload) []Finding {
if !w.Requests.CPU.Set {
return nil
}
if w.Requests.CPU.Value == 0 || w.Requests.CPU.Value >= tinyCPUMillicores {
return nil
}
return []Finding{{
DetectorID: "tiny-cpu-request",
Workload: w.Name,
Title: "CPU request below the placeholder threshold",
Detail: fmt.Sprintf("requests.cpu is %s — below the 10m threshold most charts use as a sentinel. Probably a placeholder from a Helm scaffold. Set it to your observed P95 (or remove the limit-without-request asymmetry the scheduler is currently dealing with).", w.Requests.CPU),
Severity: SeverityLow,
Confidence: ConfidenceHigh,
}}
}
type tinyMemoryRequest struct{}
func newTinyMemoryRequest() Detector { return tinyMemoryRequest{} }
func (tinyMemoryRequest) ID() string { return "tiny-memory-request" }
func (tinyMemoryRequest) Name() string { return "Suspiciously small memory request" }
func (tinyMemoryRequest) Run(w parser.Workload) []Finding {
if !w.Requests.Memory.Set {
return nil
}
if w.Requests.Memory.Value == 0 || w.Requests.Memory.Value >= tinyMemoryBytes {
return nil
}
return []Finding{{
DetectorID: "tiny-memory-request",
Workload: w.Name,
Title: "Memory request below the placeholder threshold",
Detail: fmt.Sprintf("requests.memory is %s — below 32 MiB. A workload that genuinely needs less memory is a rarity; most charts setting tiny memory requests are using a placeholder. Set it to your observed P95.", w.Requests.Memory),
Severity: SeverityLow,
Confidence: ConfidenceHigh,
}}
}