Skip to content

Commit

Permalink
Surface registry error (#1376)
Browse files Browse the repository at this point in the history
* Surface registry error instead of logging it as debug

When permissions issues are encountered, it can be hard to determine the root cause
without the error returned from the registry

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix test expectation

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed Jul 11, 2024
1 parent 12e2de8 commit a87e12e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion acceptance/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
output, err := cmd.CombinedOutput()

h.AssertNotNil(t, err)
expected := "validating registry write access: ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
expected := "ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
h.AssertStringContains(t, string(output), expected)
})
})
Expand Down
11 changes: 4 additions & 7 deletions image/registry_handler.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package image

import (
"fmt"

"github.com/buildpacks/imgutil"
"github.com/buildpacks/imgutil/remote"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/pkg/errors"

"github.com/buildpacks/lifecycle/cmd"
)

// RegistryHandler takes care of the registry settings and checks
Expand Down Expand Up @@ -73,8 +72,7 @@ func verifyReadAccess(imageRef string, keychain authn.Keychain, opts []imgutil.I
img, _ := remote.NewImage(imageRef, keychain, opts...)
canRead, err := img.CheckReadAccess()
if !canRead {
cmd.DefaultLogger.Debugf("Error checking read access: %s", err)
return errors.Errorf("ensure registry read access to %s", imageRef)
return fmt.Errorf("failed to ensure registry read access to %s: %w", imageRef, err)
}

return nil
Expand All @@ -88,8 +86,7 @@ func verifyReadWriteAccess(imageRef string, keychain authn.Keychain, opts []imgu
img, _ := remote.NewImage(imageRef, keychain, opts...)
canReadWrite, err := img.CheckReadWriteAccess()
if !canReadWrite {
cmd.DefaultLogger.Debugf("Error checking read/write access: %s", err)
return errors.Errorf("ensure registry read/write access to %s", imageRef)
return fmt.Errorf("failed to ensure registry read/write access to %s: %w", imageRef, err)
}
return nil
}

0 comments on commit a87e12e

Please sign in to comment.