From 7d07ac07fc5025a9c59975d94b013b9e18653275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Fri, 6 Dec 2024 17:22:00 +0100 Subject: [PATCH] cloudguestregistryauth is only expected to work for PAYG The tool is also installed for BYOS images, and users can register the system against the cloud registry, but this is not mandatory, so ignore the errors in such a case. (bsc#1233630) --- mgradm/shared/podman/podman.go | 25 +++++++++++++++++++++---- uyuni-tools.changes.cbosdo.byos-fix | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 uyuni-tools.changes.cbosdo.byos-fix diff --git a/mgradm/shared/podman/podman.go b/mgradm/shared/podman/podman.go index c8e75018d..2b1829fc9 100644 --- a/mgradm/shared/podman/podman.go +++ b/mgradm/shared/podman/podman.go @@ -356,8 +356,12 @@ func Upgrade( hubXmlrpcFlags adm_utils.HubXmlrpcFlags, salineFlags adm_utils.SalineFlags, ) error { - if err := CallCloudGuestRegistryAuth(); err != nil { - return err + // Calling cloudguestregistryauth only makes sense if using the cloud provider registry. + // This check assumes users won't use custom registries that are not the cloud provider one on a cloud image. + if !strings.HasPrefix(registry, "registry.suse.com") { + if err := CallCloudGuestRegistryAuth(); err != nil { + return err + } } serverImage, err := utils.ComputeImage(registry, utils.DefaultTag, image) @@ -526,13 +530,26 @@ func CallCloudGuestRegistryAuth() error { path, err := exec.LookPath(cloudguestregistryauth) if err == nil { - // the binary is installed - return utils.RunCmdStdMapping(zerolog.DebugLevel, path) + if err := utils.RunCmdStdMapping(zerolog.DebugLevel, path); err != nil && isPAYG() { + // Not being registered against the cloud registry is not an error on BYOS. + return err + } else if err != nil { + log.Info().Msg(L("The above error is only relevant if using a public cloud provider registry")) + } } // silently ignore error if it is missing return nil } +func isPAYG() bool { + flavorCheckPath := "/usr/bin/instance-flavor-check" + if utils.FileExists(flavorCheckPath) { + out, _ := utils.RunCmdOutput(zerolog.DebugLevel, flavorCheckPath) + return strings.TrimSpace(string(out)) == "PAYG" + } + return false +} + // GetMountPoint return folder where a given volume is mounted. func GetMountPoint(volumeName string) (string, error) { args := []string{"volume", "inspect", "--format", "{{.Mountpoint}}", volumeName} diff --git a/uyuni-tools.changes.cbosdo.byos-fix b/uyuni-tools.changes.cbosdo.byos-fix new file mode 100644 index 000000000..9440cdaae --- /dev/null +++ b/uyuni-tools.changes.cbosdo.byos-fix @@ -0,0 +1 @@ +- Only raise an error if cloudguestregistryauth fails for PAYG (bsc#1233630)