From 8e408590706a761d5824d0515d1653e6bcf5fbe0 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 2 Dec 2024 13:45:19 -0600 Subject: [PATCH] Fix how we set the resources for mysqldExporter Signed-off-by: Florent Poinsard --- pkg/operator/vttablet/pod.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/operator/vttablet/pod.go b/pkg/operator/vttablet/pod.go index c07df5d9..16e423c9 100644 --- a/pkg/operator/vttablet/pod.go +++ b/pkg/operator/vttablet/pod.go @@ -223,7 +223,15 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) { }, SecurityContext: securityContext, VolumeMounts: mysqldMounts, - Resources: corev1.ResourceRequirements{ + // TODO(enisoc): Add readiness and liveness probes that make sense for mysqld-exporter. + // This depends on the exact semantics of each of mysqld-exporter's HTTP handlers, + // so we need to do more investigation. For now it's better to leave them empty. + } + + if spec.MysqldExporter != nil && (len(spec.MysqldExporter.Resources.Limits) > 0 || len(spec.MysqldExporter.Resources.Requests) > 0) { + mysqldExporterContainer.Resources = spec.MysqldExporter.Resources + } else { + mysqldExporterContainer.Resources = corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: *resource.NewMilliQuantity(mysqldExporterCPURequestMillis, resource.DecimalSI), corev1.ResourceMemory: *resource.NewQuantity(mysqldExporterMemoryRequestBytes, resource.BinarySI), @@ -234,14 +242,7 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) { corev1.ResourceCPU: *resource.NewMilliQuantity(mysqldExporterCPULimitMillis, resource.DecimalSI), corev1.ResourceMemory: *resource.NewQuantity(mysqldExporterMemoryLimitBytes, resource.BinarySI), }, - }, - // TODO(enisoc): Add readiness and liveness probes that make sense for mysqld-exporter. - // This depends on the exact semantics of each of mysqld-exporter's HTTP handlers, - // so we need to do more investigation. For now it's better to leave them empty. - } - - if spec.MysqldExporter != nil { - update.ResourceRequirements(&mysqldExporterContainer.Resources, &spec.MysqldExporter.Resources) + } } }