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

Building with multiple tags only updates the first tag #2678

Closed
weikequ opened this issue Dec 4, 2023 · 5 comments
Closed

Building with multiple tags only updates the first tag #2678

weikequ opened this issue Dec 4, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@weikequ
Copy link
Contributor

weikequ commented Dec 4, 2023

Description

First seen here: runfinch/finch#707.

When running build while specifying multiple tags for the container, only the first tag is updated if the tags already exist.

Steps to reproduce the issue

echo 'FROM busybox
CMD ["echo", "1"]
' > Dockerfile
sudo nerdctl build . -t test:tag1 -t test:tag2 -q
sudo nerdctl run test:tag1
# 1
sudo nerdctl run test:tag2
# 1
echo 'FROM busybox
CMD ["echo", "2"]
' > Dockerfile
sudo nerdctl build . -t test:tag1 -t test:tag2 -q
sudo nerdctl run test:tag1
# 2
sudo nerdctl run test:tag2
# 1 (but should be 2)

Describe the results you received and expected

See steps above.

What version of nerdctl are you using?

1.7.1

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

No response

@weikequ weikequ added the kind/unconfirmed-bug-claim Unconfirmed bug claim label Dec 4, 2023
@weikequ
Copy link
Contributor Author

weikequ commented Dec 4, 2023

I am happy to work on this and contribute a fix

@weikequ
Copy link
Contributor Author

weikequ commented Dec 5, 2023

Seems like this is the issue in the code. Does anyone have any context on why we decided to skip images that already exist if it's not the first image? Related/caused by this conversation.

if len(tags) > 1 {
log.L.Debug("Found more than 1 tag")
imageService := client.ImageService()
image, err := imageService.Get(ctx, tags[0])
if err != nil {
return fmt.Errorf("unable to tag image: %s", err)
}
for _, targetRef := range tags[1:] {
image.Name = targetRef
if _, err := imageService.Create(ctx, image); err != nil {
// if already exists; skip.
if errors.Is(err, errdefs.ErrAlreadyExists) {
continue

@AkihiroSuda AkihiroSuda added bug Something isn't working and removed kind/unconfirmed-bug-claim Unconfirmed bug claim labels Dec 5, 2023
@AkihiroSuda
Copy link
Member

Cc @manugupt1

@manugupt1 manugupt1 self-assigned this Dec 6, 2023
@manugupt1
Copy link
Contributor

I will look at this sometime this month and try to fix it. AFAIR, I did not think of this case.

manugupt1 added a commit to manugupt1/nerdctl that referenced this issue Jan 21, 2024
containerd#2678
Signed-off-by: Manu Gupta <manugupt1@gmail.com>
manugupt1 added a commit to manugupt1/nerdctl that referenced this issue Jan 21, 2024
manugupt1 added a commit to manugupt1/nerdctl that referenced this issue Jan 21, 2024
manugupt1 added a commit to manugupt1/nerdctl that referenced this issue Jan 21, 2024
containerd#2678
Signed-off-by: Manu Gupta <manugupt1@gmail.com>
manugupt1 added a commit to manugupt1/nerdctl that referenced this issue Jan 21, 2024
containerd#2678
Signed-off-by: Manu Gupta <manugupt1@gmail.com>
@manugupt1
Copy link
Contributor

This fixed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants