From c4a240acb11bf16abbaed11061147766b7c0dac8 Mon Sep 17 00:00:00 2001 From: smellthemoon <64083300+smellthemoon@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:14:25 +0800 Subject: [PATCH] enhance: memory value are displayed in MB (#35292) Signed-off-by: lixinguo Co-authored-by: lixinguo --- pkg/util/merr/utils.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/util/merr/utils.go b/pkg/util/merr/utils.go index 1c84e51d02976..3f44ea45d81a6 100644 --- a/pkg/util/merr/utils.go +++ b/pkg/util/merr/utils.go @@ -360,9 +360,12 @@ func WrapErrServiceUnavailable(reason string, msg ...string) error { } func WrapErrServiceMemoryLimitExceeded(predict, limit float32, msg ...string) error { + toMB := func(mem float32) float32 { + return mem / 1024 / 1024 + } err := wrapFields(ErrServiceMemoryLimitExceeded, - value("predict", predict), - value("limit", limit), + value("predict(MB)", toMB(predict)), + value("limit(MB)", toMB(limit)), ) if len(msg) > 0 { err = errors.Wrap(err, strings.Join(msg, "->")) @@ -400,9 +403,12 @@ func WrapErrServiceCrossClusterRouting(expectedCluster, actualCluster string, ms } func WrapErrServiceDiskLimitExceeded(predict, limit float32, msg ...string) error { + toMB := func(mem float32) float32 { + return mem / 1024 / 1024 + } err := wrapFields(ErrServiceDiskLimitExceeded, - value("predict", predict), - value("limit", limit), + value("predict(MB)", toMB(predict)), + value("limit(MB)", toMB(limit)), ) if len(msg) > 0 { err = errors.Wrap(err, strings.Join(msg, "->"))