From a3a62854f5421a5e4de3b4f56934ca62f5098d2a Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 10 Jul 2023 15:30:28 +0200 Subject: [PATCH] api: fix slow version endpoint This endpoint queried the same package versions twice causing it to be slower than info. Because it already called info we can just reuse the package versions from there. Signed-off-by: Paul Holzinger --- pkg/api/handlers/compat/version.go | 35 ++++++++++-------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/pkg/api/handlers/compat/version.go b/pkg/api/handlers/compat/version.go index 0d34fbd98e..dd64841ac6 100644 --- a/pkg/api/handlers/compat/version.go +++ b/pkg/api/handlers/compat/version.go @@ -13,7 +13,6 @@ import ( "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/containers/podman/v4/version" - "github.com/sirupsen/logrus" ) func VersionHandler(w http.ResponseWriter, r *http.Request) { @@ -45,30 +44,20 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { "MinAPIVersion": version.APIVersion[version.Libpod][version.MinimalAPI].String(), "Os": goRuntime.GOOS, }, + }, { + Name: "Conmon", + Version: info.Host.Conmon.Version, + Details: map[string]string{ + "Package": info.Host.Conmon.Package, + }, + }, { + Name: fmt.Sprintf("OCI Runtime (%s)", info.Host.OCIRuntime.Name), + Version: info.Host.OCIRuntime.Version, + Details: map[string]string{ + "Package": info.Host.OCIRuntime.Package, + }, }} - if conmon, oci, err := runtime.DefaultOCIRuntime().RuntimeInfo(); err != nil { - logrus.Warnf("Failed to retrieve Conmon and OCI Information: %q", err.Error()) - } else { - additional := []types.ComponentVersion{ - { - Name: "Conmon", - Version: conmon.Version, - Details: map[string]string{ - "Package": conmon.Package, - }, - }, - { - Name: fmt.Sprintf("OCI Runtime (%s)", oci.Name), - Version: oci.Version, - Details: map[string]string{ - "Package": oci.Package, - }, - }, - } - components = append(components, additional...) - } - apiVersion := version.APIVersion[version.Compat][version.CurrentAPI] minVersion := version.APIVersion[version.Compat][version.MinimalAPI]