From fe71f2135bdc3aa6ea28de7ed1ac324f7d689ed6 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Wed, 7 Feb 2024 16:53:29 +0000 Subject: [PATCH 1/2] shared/simplestreams/products: Fix regression in parsing version files Don't stop when finding first matching version file because the index is parsed in random order and LXD calls it multiple times when figuring out which image file to download and so stopping early can cause mismatches when trying to match a converted alias to a specific file fingerprint. Introduced with 3e9acc4 Signed-off-by: Thomas Parrott (cherry picked from commit 3681d5e54649fcc2fc9375b6820c1133f140228d) --- shared/simplestreams/products.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shared/simplestreams/products.go b/shared/simplestreams/products.go index a07e4d5b1b5b..542051403899 100644 --- a/shared/simplestreams/products.go +++ b/shared/simplestreams/products.go @@ -279,8 +279,6 @@ func (s *Products) ToLXD() ([]api.Image, map[string][][]string) { if err != nil { continue } - - break // Stop at first compatible item found. } else if shared.StringInSlice(item.FileType, lxdCompatItems) { // Locate the root files for _, subItem := range version.Items { @@ -291,8 +289,6 @@ func (s *Products) ToLXD() ([]api.Image, map[string][][]string) { } } } - - break // Stop at first compatible item found. } } } From d3253e4cbc85b97e3bc6dba9a27fd2ab0c4d8685 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Wed, 7 Feb 2024 10:28:36 +0000 Subject: [PATCH 2/2] shared/simplestreams/simplestreams: Improve error messages Signed-off-by: Thomas Parrott (cherry picked from commit 56364f5a97373155d5e6a5a6b10d06d16a25fb3c) --- shared/simplestreams/simplestreams.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/simplestreams/simplestreams.go b/shared/simplestreams/simplestreams.go index 3f3255cac913..68e1d96278a3 100644 --- a/shared/simplestreams/simplestreams.go +++ b/shared/simplestreams/simplestreams.go @@ -377,7 +377,7 @@ func (s *SimpleStreams) GetFiles(fingerprint string) (map[string]DownloadableFil } } - return nil, fmt.Errorf("Couldn't find the requested image") + return nil, fmt.Errorf("Couldn't find the requested image for fingerprint %q", fingerprint) } // ListAliases returns a list of image aliases for the provided image fingerprint. @@ -501,9 +501,9 @@ func (s *SimpleStreams) GetImage(fingerprint string) (*api.Image, error) { } if len(matches) == 0 { - return nil, fmt.Errorf("The requested image couldn't be found") + return nil, fmt.Errorf("The requested image couldn't be found for fingerprint %q", fingerprint) } else if len(matches) > 1 { - return nil, fmt.Errorf("More than one match for the provided partial fingerprint") + return nil, fmt.Errorf("More than one match for the provided partial fingerprint %q", fingerprint) } return &matches[0], nil