Skip to content

Commit bfa0b3e

Browse files
authored
Merge pull request #642 from planetscale/fix-mysqld-limits
Correctly set the resources of `mysqldExporter`
2 parents 0035266 + 0f90ca5 commit bfa0b3e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pkg/operator/vttablet/pod.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,15 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
223223
},
224224
SecurityContext: securityContext,
225225
VolumeMounts: mysqldMounts,
226-
Resources: corev1.ResourceRequirements{
226+
// TODO(enisoc): Add readiness and liveness probes that make sense for mysqld-exporter.
227+
// This depends on the exact semantics of each of mysqld-exporter's HTTP handlers,
228+
// so we need to do more investigation. For now it's better to leave them empty.
229+
}
230+
231+
if spec.MysqldExporter != nil && (len(spec.MysqldExporter.Resources.Limits) > 0 || len(spec.MysqldExporter.Resources.Requests) > 0) {
232+
update.ResourceRequirements(&mysqldExporterContainer.Resources, &spec.MysqldExporter.Resources)
233+
} else {
234+
mysqldExporterContainer.Resources = corev1.ResourceRequirements{
227235
Requests: corev1.ResourceList{
228236
corev1.ResourceCPU: *resource.NewMilliQuantity(mysqldExporterCPURequestMillis, resource.DecimalSI),
229237
corev1.ResourceMemory: *resource.NewQuantity(mysqldExporterMemoryRequestBytes, resource.BinarySI),
@@ -234,14 +242,7 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
234242
corev1.ResourceCPU: *resource.NewMilliQuantity(mysqldExporterCPULimitMillis, resource.DecimalSI),
235243
corev1.ResourceMemory: *resource.NewQuantity(mysqldExporterMemoryLimitBytes, resource.BinarySI),
236244
},
237-
},
238-
// TODO(enisoc): Add readiness and liveness probes that make sense for mysqld-exporter.
239-
// This depends on the exact semantics of each of mysqld-exporter's HTTP handlers,
240-
// so we need to do more investigation. For now it's better to leave them empty.
241-
}
242-
243-
if spec.MysqldExporter != nil {
244-
update.ResourceRequirements(&mysqldExporterContainer.Resources, &spec.MysqldExporter.Resources)
245+
}
245246
}
246247
}
247248

0 commit comments

Comments
 (0)