Skip to content

Commit

Permalink
cloudguestregistryauth is only expected to work for PAYG
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
cbosdo committed Dec 10, 2024
1 parent 3c5a820 commit 7d07ac0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
25 changes: 21 additions & 4 deletions mgradm/shared/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions uyuni-tools.changes.cbosdo.byos-fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Only raise an error if cloudguestregistryauth fails for PAYG (bsc#1233630)

0 comments on commit 7d07ac0

Please sign in to comment.