Skip to content
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

libimage: Add input to error context when normalizing #1971

Merged

Conversation

cgwalters
Copy link
Contributor

Before, here's what happens if you forget a -v in your bind mount for example:

$ podman run /dev:/dev docker.io/busybox echo hello
Error: invalid reference format
$

After:

$ podman run /dev:/dev docker.io/busybox echo hello
Error: parsing reference "/dev:/dev": invalid reference format

This error prefixing is common in other callers.

None

@rhatdan
Copy link
Member

rhatdan commented Apr 26, 2024

/approve
LGTM

Copy link
Contributor

openshift-ci bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense, however there are more reference.Parse() callers here that do not wrap the error so I think they should be fixed too.

@Luap99
Copy link
Member

Luap99 commented Apr 26, 2024

I also also wonder if this breaks podman tests that hard code certain error messages. Not a blocker of course just something that may needs chnages when vendoring the next time into podman

Before, here's what happens if you forget a `-v` in your bind mount for example:

```
$ podman run /dev:/dev docker.io/busybox echo hello
Error: invalid reference format
$
```

After:

```
$ podman run /dev:/dev docker.io/busybox echo hello
Error: parsing reference "/dev:/dev": invalid reference format
```

This error prefixing is common in other callers.

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters
Copy link
Contributor Author

This makes a lot of sense, however there are more reference.Parse() callers here that do not wrap the error so I think they should be fixed too.

I looked at that, but my worry is we end up with double context somewhere; it's hard to trace through all these call chains (hmm, I wonder if someone wrote a tool for this).

I decided to change the implementation so that just the two callers here of normalizeTaggedDigestedString add context, which feels like it more closely matches what happens elsewhere.

I also also wonder if this breaks podman tests that hard code certain error messages. Not a blocker of course just something that may needs chnages when vendoring the next time into podman

Yeah, that seems possible.

@vrothberg
Copy link
Member

An alternative could be adding the context directly to the reference package in c/image?
@mtrmac WDYT?

@Luap99
Copy link
Member

Luap99 commented Apr 26, 2024

An alternative could be adding the context directly to the reference package in c/image? @mtrmac WDYT?

I was thinking about this too but then chances of including the path twice is higher as there seem to be many places already that wrap the error accordingly that would need to be changed back.

@mtrmac
Copy link
Contributor

mtrmac commented Apr 26, 2024

Yes, this is “pay a little cost every time a new ParseNormalizedNamed caller is added” vs. “invest more now to solve it for good”.

(And pedantically we might worry about starting to return a wrapped error , but nothing in Podman actually cares.)

It’s ~50 non-test calls across Podman, so quite doable, but also not something I can prioritize working on short-term. Perhaps a good first PR for a new contributor.

@rhatdan
Copy link
Member

rhatdan commented May 4, 2024

Lets get this fix in, and then we can look at moving it to containers/image later.

@Luap99
Copy link
Member

Luap99 commented May 6, 2024

Seems like a good idea to at least fix the bad podman run/create message for now.
/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 6, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 3202695 into containers:main May 6, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants