Skip to content

Commit

Permalink
score/container: align `container-ephemeral-storage-request-and-limit…
Browse files Browse the repository at this point in the history
…` to `container-resources`
  • Loading branch information
ReuDa authored and zegl committed Dec 19, 2023
1 parent 891b4c9 commit 7df9449
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions score/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,35 @@ func containerStorageEphemeralRequestAndLimit(ps ks.PodSpecer) (score scorecard.

score.Grade = scorecard.GradeAllOK

hasMissingLimit := false
hasMissingRequest := false

for _, container := range allContainers {
if container.Resources.Limits.StorageEphemeral().IsZero() {
score.AddComment(container.Name, "Ephemeral Storage limit is not set",
"Resource limits are recommended to avoid resource DDOS. Set resources.limits.ephemeral-storage")
score.Grade = scorecard.GradeCritical
} else if container.Resources.Requests.StorageEphemeral().IsZero() {
hasMissingLimit = true
}
if container.Resources.Requests.StorageEphemeral().IsZero() {
score.AddComment(container.Name, "Ephemeral Storage request is not set",
"Resource requests are recommended to make sure the application can start and run without crashing. Set resource.requests.ephemeral-storage")
score.Grade = scorecard.GradeWarning
hasMissingRequest = true
}
}

switch {
case len(allContainers) == 0:
score.Grade = scorecard.GradeCritical
score.AddComment("", "No containers defined", "")
case hasMissingLimit:
score.Grade = scorecard.GradeCritical
case hasMissingRequest:
score.Grade = scorecard.GradeWarning
default:
score.Grade = scorecard.GradeAllOK
}

return
}

Expand Down

0 comments on commit 7df9449

Please sign in to comment.