1
0
mirror of https://github.com/containers/buildah.git synced 2025-07-30 04:23:09 +03:00

bud: teach --platform to take a list

Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.

Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.

Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.

In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).

In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it.  In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on.  Two processes could still try to create the same list
twice, but it's an incremental improvement.

Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai
2021-06-22 10:52:49 -04:00
parent 0022921a99
commit ae08e01e49
24 changed files with 400 additions and 138 deletions

View File

@ -183,6 +183,12 @@ func (b *Builder) addManifest(ctx context.Context, manifestName string, imageSpe
create = true
list = manifests.Create()
} else {
locker, err := manifests.LockerForImage(b.store, manifestList.ID())
if err != nil {
return "", err
}
locker.Lock()
defer locker.Unlock()
_, list, err = manifests.LoadFromImage(b.store, manifestList.ID())
if err != nil {
return "", err