From a169a8b9dce79273cd4217921c2f79d339a99662 Mon Sep 17 00:00:00 2001 From: Philipp Thun Date: Fri, 5 Apr 2024 01:41:33 +0200 Subject: [PATCH] fix: Allow for bytes as units in container metrics regex (#1105) Adjusts container metrics regex to allow for `cf app` output to display `memory` and `disk` output in bytes. Fixes `windows` and `apps` suite failures. Previously, the cf CLI defaulted to `K`, `M`, or `G` as the units for those columns. However, cf CLI v7.7.10/v8.7.10 bumped `code.cloudfoundry.org/bytefmt` to include [this change](https://github.com/cloudfoundry/bytefmt/commit/854d396b647c90b5a45646f9dcc2c9cd08ea8d51), which now outputs `B` as the unit in certain circumstances. --------- Co-authored-by: Carson Long <12767276+ctlong@users.noreply.github.com> --- apps/lifecycle.go | 2 +- windows/lifecycle.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/lifecycle.go b/apps/lifecycle.go index 50f185fa0..6644fb05d 100644 --- a/apps/lifecycle.go +++ b/apps/lifecycle.go @@ -226,7 +226,7 @@ var _ = AppsDescribe("Application Lifecycle", func() { Context("is able to retrieve container metrics", func() { // #0 running 2015-06-10 02:22:39 PM 0.0% 48.7M of 2G 14M of 1G 68B/s of unlimited - var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`) + var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`) stats := func() (float64, float64, float64) { app := cf.Cf("app", appName) Expect(app.Wait()).To(Exit(0)) diff --git a/windows/lifecycle.go b/windows/lifecycle.go index a4fc51336..4f1e4e419 100644 --- a/windows/lifecycle.go +++ b/windows/lifecycle.go @@ -47,7 +47,7 @@ var _ = WindowsDescribe("Application Lifecycle", func() { By("verifying reported usage", func() { // #0 running 2015-06-10 02:22:39 PM 0.0% 48.7M of 2G 14M of 1G 68B/s of unlimited - var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`) + var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`) stats := func() (float64, float64, float64) { helpers.CurlApp(Config, appName, "/logspew/1024")