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

race, storage: add independent AddNames and RemoveNames for images,layers and containers #1153

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

flouthoc
Copy link
Collaborator

Adds SetNameWithOptions so operations which are invoke in parallel
manner can use it without destroying names from storage.

For instance

We are deleting names which were already written in store.
This creates faulty behavior when builds are invoked in parallel manner, as
this removes names for other builds.

To fix this behavior we must append to already written names and
override if needed. But this should be optional and not break public API

Following patch will be used by parallel operations at podman or buildah end, directly or indirectly.

PR replaces: #1152

containers.go Outdated Show resolved Hide resolved
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Would a {Add,Delete}Name API address the races?

containers.go Outdated Show resolved Hide resolved
@flouthoc flouthoc force-pushed the setname-options branch 3 times, most recently from 46e6c7d to 4a853d4 Compare February 23, 2022 11:06
@flouthoc
Copy link
Collaborator Author

Would a {Add,Delete}Name API address the races?

@vrothberg Bunch of code in common or podman or buildah needs to be instrumented slowly. So this seems most intuitive from what we discussed here #1152 .

There are some other things as well where we might have race but maybe that is part of a different PR.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

code changes LGTM

@giuseppe
Copy link
Member

Would a {Add,Delete}Name API address the races?

Wouldn't that be more difficult to handle for the caller? If it is adding multiple names and the operation fails middle way, should it then try to delete previously added ones?

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

If we need atomic name additions, we certainly also need atomic name removals. So I’d expect something like UpdateNames(id string, updates NameUpdates) with type NameUpdates struct { addNames, removeNames []string }

There was also an issue I can’t quickly find about store.CreateImage doing name updates and other changes atomically with other operations, that’s why I suggest a type NameUpdates that could be reused in that other feature.

containers.go Outdated Show resolved Hide resolved
@mtrmac
Copy link
Collaborator

mtrmac commented Feb 23, 2022

@vrothberg Bunch of code in common or podman or buildah needs to be instrumented slowly.

What difference does that make? Every line calling SetNames should be edited either way, whatever form we design for the new API.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 23, 2022

Also, if we know the old APIs are racy, they should be documented as deprecated.

@vrothberg
Copy link
Member

@vrothberg Bunch of code in common or podman or buildah needs to be instrumented slowly.

What difference does that make? Every line calling SetNames should be edited either way, whatever form we design for the new API.

Yes, SetNames should not be used anymore. IIUIC, the race is in reading all data, followed by writing all data. An add(), delete() could just take care of synchronization and callers don't have to worry.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 23, 2022

There was also an issue I can’t quickly find about store.CreateImage doing name updates and other changes atomically with other operations

#595

store.go Outdated Show resolved Hide resolved
@flouthoc
Copy link
Collaborator Author

If we have a consensus on new API then i guess its cool. We can create a new API.

@flouthoc flouthoc changed the title race, storage: Add SetNameWithOptions to make destructive nature of SetName optional race, storage: add independent AddNames and RemoveNames for images,layers and containers Feb 23, 2022
@flouthoc flouthoc marked this pull request as draft February 23, 2022 15:17
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Not at all a thorough review

containers.go Outdated Show resolved Hide resolved
containers.go Outdated Show resolved Hide resolved
containers.go Outdated Show resolved Hide resolved
flouthoc added a commit to flouthoc/podman that referenced this pull request Mar 23, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

Test manually backported from: containers@63f92d0

Signed-off-by: Aditya R <arajan@redhat.com>
kbaran1998 pushed a commit to gcalin/podman that referenced this pull request Mar 23, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
Signed-off-by: Krzysztof Baran <krysbaran@gmail.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

Test manually backported from: containers/podman@63f92d0

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

Test manually backported from: containers/podman@63f92d0

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

Test manually backported from: containers/podman@63f92d0

Signed-off-by: Aditya R <arajan@redhat.com>
kbaran1998 pushed a commit to gcalin/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
Signed-off-by: Krzysztof Baran <krysbaran@gmail.com>
kbaran1998 pushed a commit to gcalin/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
Signed-off-by: Krzysztof Baran <krysbaran@gmail.com>
keonchennl pushed a commit to gcalin/podman that referenced this pull request Mar 24, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
keonchennl pushed a commit to gcalin/podman that referenced this pull request Mar 29, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Apr 6, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Apr 6, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 17, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 18, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/buildah that referenced this pull request Aug 19, 2022
PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <arajan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants