-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/podman: Add error parsing method #786
Conversation
This new helper function parses the output of Podman in stderr into a dedicated structure with defined methods for working with the error. The most significant part is the method Is() that wraps around errors.Is() and if that fails to find a match resorts to string matching. This is needed because there are no defined errors to catch errors coming from Podman. The structure is only meant to be used internally. containers#786
afd427d
to
8bee17e
Compare
Build failed.
|
This new helper function parses the output of Podman in stderr into a dedicated structure with defined methods for working with the error. The most significant part is the method Is() that wraps around errors.Is() and if that fails to find a match resorts to string matching. This is needed because there are no defined errors to catch errors coming from Podman. The structure is only meant to be used internally. containers#786
8bee17e
to
f7773d9
Compare
Build succeeded.
|
This new helper function parses the output of Podman in stderr into a dedicated structure with defined methods for working with the error. The most significant part is the method Is() that wraps around errors.Is() and if that fails to find a match resorts to string matching. This is needed because there are no defined errors to catch errors coming from Podman. The structure is only meant to be used internally. containers#786
This new helper function parses the output of Podman in stderr into a dedicated structure with defined methods for working with the error. The most significant part is the method Is() that wraps around errors.Is() and if that fails to find a match resorts to string matching. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
f7773d9
to
e81af81
Compare
This new helper function parses the output of Podman in stderr into a dedicated structure with defined methods for working with the error. The most significant part is the method Is() that wraps around errors.Is() and if that fails to find a match resorts to string matching. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
Build failed.
|
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
e81af81
to
66175db
Compare
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
66175db
to
99fc1b7
Compare
Build failed.
|
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
99fc1b7
to
2c4c3bc
Compare
Build failed.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the branch, @HarryMichal ! This looks really good. One small question:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add some unit tests for the internalError
implementation.
Yes, we should. The setup will be a bit tricky since the type is not exported but Go should have a way to go around the fact. |
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
2c4c3bc
to
15e4257
Compare
Build failed.
|
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
15e4257
to
cf70190
Compare
Build failed.
|
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
cf70190
to
328a9ab
Compare
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
328a9ab
to
f130844
Compare
This new helper type serves for parsing the output of Podman in stderr into a form that can be further analyzed. The most significant part is the method Is() that lexically compares error strings. This is needed because there are no defined errors to catch errors coming from Podman. containers#786
Build failed.
|
Let's fold this pull request into #787 Otherwise it's becoming impossible to manage all the branches that include each other and are evolving in different ways. |
This is meant to get a better understanding of a failed 'podman pull' invocation to understand whether pulling an image requires logging into the registry or not. Currently, 'podman pull' doesn't have a dedicated exit code to denote authorization errors, so this is meant to be a temporary workaround for that. Parsing the error stream is inherently fragile and tricky because there's no guarantee that the structure of the messages won't change, and there's no clear definition of how the messages are laid out. Therefore, this approach can't be treated as a generic solution for getting detailed information about failed Podman invocations. The error stream is used not only for dumping error messages, but also for showing progress bars. Therefore, all lines are skipped until one that starts with "Error: " is found. This is a heuristic based on how Go programs written using the Cobra [1] library tend to report errors. All subsequent lines are taken together and split around the ": " sub-string, on the assumption that the ": " sub-string is used when a new error message is prefixed to an inner error. Each sub-string created from the split is treated as a potential member of the chain of errors reported within Podman. Some real world examples of the 'podman pull' error stream in the case of authorization errors are: * With Docker Hub (https://hub.docker.com/): Trying to pull docker.io/library/foobar:latest... Error: Error initializing source docker://foobar:latest: Error reading manifest latest in docker.io/library/foobar: errors: denied: requested access to the resource is denied unauthorized: authentication required * With registry.redhat.io: Trying to pull registry.redhat.io/foobar:latest... Error: Error initializing source docker://registry.redhat.io/foobar:latest: unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication [1] https://github.com/spf13/cobra/ https://pkg.go.dev/github.com/spf13/cobra containers#786 containers#787
This is meant to get a better understanding of a failed 'podman pull' invocation to understand whether pulling an image requires logging into the registry or not. Currently, 'podman pull' doesn't have a dedicated exit code to denote authorization errors, so this is meant to be a temporary workaround for that. Parsing the error stream is inherently fragile and tricky because there's no guarantee that the structure of the messages won't change, and there's no clear definition of how the messages are laid out. Therefore, this approach can't be treated as a generic solution for getting detailed information about failed Podman invocations. The error stream is used not only for dumping error messages, but also for showing progress bars. Therefore, all lines are skipped until one that starts with "Error: " is found. This is a heuristic based on how Go programs written using the Cobra [1] library tend to report errors. All subsequent lines are taken together and split around the ": " sub-string, on the assumption that the ": " sub-string is used when a new error message is prefixed to an inner error. Each sub-string created from the split is treated as a potential member of the chain of errors reported within Podman. Some real world examples of the 'podman pull' error stream in the case of authorization errors are: * With Docker Hub (https://hub.docker.com/): Trying to pull docker.io/library/foobar:latest... Error: Error initializing source docker://foobar:latest: Error reading manifest latest in docker.io/library/foobar: errors: denied: requested access to the resource is denied unauthorized: authentication required * With registry.redhat.io: Trying to pull registry.redhat.io/foobar:latest... Error: Error initializing source docker://registry.redhat.io/foobar:latest: unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication [1] https://github.com/spf13/cobra/ https://pkg.go.dev/github.com/spf13/cobra containers#689 containers#786 containers#787
This new helper function parses the output of Podman in stderr into
a dedicated structure with defined methods for working with the error.
The most significant part is the method Is() that wraps around
errors.Is() and if that fails to find a match resorts to string
matching. This is needed because there are no defined errors to catch
errors coming from Podman.
The structure is only meant to be used internally.