Skip to content

Commit 7bacdb9

Browse files
committed
[cozy-lib, bug] divf by cpu ratio, not mulf
Signed-off-by: Timofei Larkin <[email protected]>
1 parent 4369b03 commit 7bacdb9

2 files changed

Lines changed: 18 additions & 23 deletions

File tree

‎packages/library/cozy-lib/templates/_resourcepresets.tpl‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,27 @@ These presets are for basic testing and not meant to be used in production
1313
{{- define "cozy-lib.resources.preset" -}}
1414
{{- $cpuAllocationRatio := include "cozy-lib.resources.cpuAllocationRatio" . | float64 }}
1515
{{- $args := index . 0 }}
16+
{{- $global := index . 1 }}
1617

1718
{{- $baseCPU := dict
18-
"nano" (dict "requests" (dict "cpu" "100m" ))
19-
"micro" (dict "requests" (dict "cpu" "250m" ))
20-
"small" (dict "requests" (dict "cpu" "500m" ))
21-
"medium" (dict "requests" (dict "cpu" "500m" ))
22-
"large" (dict "requests" (dict "cpu" "1" ))
23-
"xlarge" (dict "requests" (dict "cpu" "2" ))
24-
"2xlarge" (dict "requests" (dict "cpu" "4" ))
19+
"nano" (dict "cpu" "100m" )
20+
"micro" (dict "cpu" "250m" )
21+
"small" (dict "cpu" "500m" )
22+
"medium" (dict "cpu" "500m" )
23+
"large" (dict "cpu" "1" )
24+
"xlarge" (dict "cpu" "2" )
25+
"2xlarge" (dict "cpu" "4" )
2526
}}
2627
{{- $baseMemory := dict
27-
"nano" (dict "requests" (dict "memory" "128Mi" ))
28-
"micro" (dict "requests" (dict "memory" "256Mi" ))
29-
"small" (dict "requests" (dict "memory" "512Mi" ))
30-
"medium" (dict "requests" (dict "memory" "1Gi" ))
31-
"large" (dict "requests" (dict "memory" "2Gi" ))
32-
"xlarge" (dict "requests" (dict "memory" "4Gi" ))
33-
"2xlarge" (dict "requests" (dict "memory" "8Gi" ))
28+
"nano" (dict "memory" "128Mi" )
29+
"micro" (dict "memory" "256Mi" )
30+
"small" (dict "memory" "512Mi" )
31+
"medium" (dict "memory" "1Gi" )
32+
"large" (dict "memory" "2Gi" )
33+
"xlarge" (dict "memory" "4Gi" )
34+
"2xlarge" (dict "memory" "8Gi" )
3435
}}
3536

36-
{{- range $baseCPU }}
37-
{{- $_ := set . "limits" (dict "cpu" (include "cozy-lib.resources.toFloat" .requests.cpu | float64 | mulf $cpuAllocationRatio | toString)) }}
38-
{{- end }}
39-
{{- range $baseMemory }}
40-
{{- $_ := set . "limits" (dict "memory" .requests.memory) }}
41-
{{- end }}
42-
4337
{{- $presets := dict
4438
"nano" (dict
4539
"requests" (dict "ephemeral-storage" "50Mi")
@@ -72,7 +66,8 @@ These presets are for basic testing and not meant to be used in production
7266
}}
7367
{{- $_ := merge $presets $baseCPU $baseMemory }}
7468
{{- if hasKey $presets $args -}}
75-
{{- index $presets $args | toYaml -}}
69+
{{- $flatDict := index $presets $args }}
70+
{{- include "cozy-lib.resources.sanitize" (list $flatDict $global) }}
7671
{{- else -}}
7772
{{- printf "ERROR: Preset key '%s' invalid. Allowed values are %s" . (join "," (keys $presets)) | fail -}}
7873
{{- end -}}

‎packages/library/cozy-lib/templates/_resources.tpl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
to have equal requests and limits, except CPU, where the limit is increased
3535
by a factor of the CPU allocation ratio. The template expects to receive a
3636
dict {"requests":{...}, "limits":{...}} as input, e.g.
37-
{{ include "cozy-lib.resources.sanitize" .Values.resources }}.
37+
{{ include "cozy-lib.resources.sanitize" list (.Values.resources $) }}.
3838
Example input:
3939
==============
4040
limits:

0 commit comments

Comments
 (0)