Commit Graph

31 Commits

Author SHA1 Message Date
Gregory Szorc
22bb4e9510 Bug 1460475 - Use stream_reader API; r=dustin
python-zstandard 0.9 has an API that exposes a file object interface
for compression and decompression. This means we can remove our
stream wrapper in order to consume a zstandard compressed tar file.

MozReview-Commit-ID: DeWWKnigJVa
2018-05-11 10:10:41 -07:00
Gregory Szorc
72c3e2770c Bug 1460475 - Install zstandard 0.9.0 in mach; r=dustin
The latest python-zstandard uses a newer zstandard that is faster.
It also has wheels available, which means installation doesn't require
Python development headers, etc.

MozReview-Commit-ID: 5gRq81KYmX4
2018-05-09 20:13:28 -07:00
Mike Hommey
4205149863 Bug 1432390 - Make mach taskcluster-build-image talk directly to the docker socket in the image builder. r=dustin
Now that `mach taskcluster-build-image` can, we can avoid all the manual
handling based on curl and jq in the image builder.

An additional advantage on relying on `mach taskcluster-build-image`
doing more is that less changes to the build-image.sh script will be
necessary, and thus less updates of the image builder docker image.
2018-01-25 13:36:47 +09:00
Mike Hommey
955ae944fd Bug 1432390 - Directly call the docker API over its unix socket instead of calling docker build. r=dustin
This allows to avoid writing out a tar file to then extract it to feed
it to `docker build`. This is essentially what the image-builder docker
image does, except it uses a temporary file for the tar.
2018-01-24 15:55:31 +09:00
Mike Hommey
0b7483ef26 Bug 1432390 - Directly call the docker API over its unix socket instead of calling docker load. r=dustin
While spawning `docker load` is likely to work on developer machines,
on automation, it requires a docker client that is the exact same
version as the server running on the taskcluster worker for
docker-in-docker, which is not convenient. The API required for `docker
load` is rather simple, though, and can be mimicked quite easily.

While this change in itself is not necessary for developer machines,
it will allow to re-use the same command for the image-builder to
load a parent docker images when deriving one from another. We could
keep a code branch using `docker load` but it seems wasteful to maintain
two branches when one can work for both use cases.
2018-01-24 14:25:09 +09:00
Mike Hommey
dc67eb5cba Bug 1432390 - Use zstandard and requests modules instead of spawning curl | zstd in docker.load_image. r=dustin
The zstd command we spawn, if available at all, might be the wrong
version: zstd changed its stream format in an incompatible way at some
point, and the version shipped in e.g. Ubuntu 16.04 uses the old format,
while the version taskcluster relies on uses the new format.

Relying on gps's zstandard library allows to ensure we use the right
version. Another advantage is that we can trivially pip install it in a
virtualenv if it isn't available on the system running the command.

If we're ridding ourselves of the subprocess spawning for zstd, we might
as well cover curl as well. Especially considering the error handling
when subprocesses are involved is not trivial, such that the current
error handling code is actually broken and leads to dead-lock
conditions, when, for example, curl is still waiting for the python side
to read data, but the python side is not reading data anymore because
an exception was thrown in the tar reading loop.
2018-01-24 11:18:13 +09:00
Mike Hommey
4c27793876 Bug 1432390 - Remove explicit exception handling in docker.load_image(). r=dustin
The used pattern:
  except Exception:
    error = sys.exc_info()[0]
  finally:
    ...
    if error:
      raise error

actually loses everything that is interesting about the original
exception. Not catching the exception just makes it thrown up the stack,
except when a different exception is thrown from the finally block,
which is what that if error: raise error is attempting to do... except
it doesn't throw the original exception, but its type only.
2018-01-24 11:17:27 +09:00
Mike Hommey
c24e9c981a Bug 1419638 - Allow to share docker image definitions. r=dustin
Instead of duplicating Dockerfiles between taskcluster/docker/*
directories, which can be error prone for very close images, it can be
desirable to use the same file. This change allows to set the
`definition` keyword on a docker image definition in kind.yml that
will make the task use the files from taskcluster/docker/<definition>
instead of taskcluster/docker/<image_name>.
2017-12-24 07:58:08 +09:00
Mike Hommey
e44088c7ce Bug 1419638 - Allow to pass arguments to docker when building docker-images. r=dustin
Ideally, we'd simply use the --build-arg docker argument along with ARG
in the Dockerfile, but that's only supported from Docker API 1.21, and
we're stuck on 1.18 for the moment.

So we add another hack to how we handle the Dockerfile, by adding a
commented syntax that allows to declare arguments to the Dockerfile.

The arguments can be defined in the docker images kind.yml file through
the `args` keyword. Under the hood, they are passed down to the docker
image task through the environment. The mach taskcluster-build-image
command then uses the corresponding values from the environment to
generate a "preprocessed" Dockerfile for its context.
2017-12-24 07:51:29 +09:00
Tom Prince
77355aa59f Bug 1415619: Add a separate trust-domain to cached tasks. r=dustin,gps
This allows firefox and thunderbird builds to avoid using each others bits.

MozReview-Commit-ID: KYQYDd2tkGj
2017-11-09 17:15:29 -07:00
Tom Prince
db87e0dbc8 Bug 1415619: Use gecko.caches for indexing docker tasks. r=dustin
MozReview-Commit-ID: IN17XmVk7HJ
2017-11-09 17:08:41 -07:00
Mike Hommey
59882266b7 Bug 1341214 - Add a small API to handle taskcluster queue and index requests. r=dustin
Various modules under taskcluster are doing ad-hoc url formatting or
requests to taskcluster services. While we could use the taskcluster
client python module, it's kind of overkill for the simple requests done
here. So instead of vendoring that module, create a smaller one with
a limited set of functions we need.

This changes the behavior of the get_artifact function to return a
file-like object when the file is neither a json nor a yaml, but that
branch was never used (and was actually returning an unassigned
variable, so it was broken anyways).

At the same time, make the function that does HTTP requests more
error-resistant, using urllib3's Retry with a backoff factor.

Also add a function that retrieves the list of artifacts, that while
currently unused, will be used by `mach artifact` shortly.
2017-02-17 12:04:48 +09:00
Mike Hommey
32f26de395 Bug 1341214 - Define GECKO in a single location. r=dustin
Instead of every file trying to get the top source directory having an
ad-hoc definition that gets wrong if the files gets moved around for
some reason, define it in a more central location.
2017-02-17 11:56:12 +09:00
Carsten "Tomcat" Book
20a26945dc Backed out changeset d8122277e9fd (bug 1341214) for causing on m-c problems in vp tc tasks 2017-02-22 15:33:42 +01:00
Carsten "Tomcat" Book
711501d98d Backed out changeset 5ffd6c7264ce (bug 1341214) 2017-02-22 15:33:17 +01:00
Mike Hommey
c7945d8ea1 Bug 1341214 - Add a small API to handle taskcluster queue and index requests. r=dustin
Various modules under taskcluster are doing ad-hoc url formatting or
requests to taskcluster services. While we could use the taskcluster
client python module, it's kind of overkill for the simple requests done
here. So instead of vendoring that module, create a smaller one with
a limited set of functions we need.

This changes the behavior of the get_artifact function to return a
file-like object when the file is neither a json nor a yaml, but that
branch was never used (and was actually returning an unassigned
variable, so it was broken anyways).

At the same time, make the function that does HTTP requests more
error-resistant, using urllib3's Retry with a backoff factor.

Also add a function that retrieves the list of artifacts, that while
currently unused, will be used by `mach artifact` shortly.
2017-02-17 12:04:48 +09:00
Mike Hommey
eb5916da95 Bug 1341214 - Define GECKO in a single location. r=dustin
Instead of every file trying to get the top source directory having an
ad-hoc definition that gets wrong if the files gets moved around for
some reason, define it in a more central location.
2017-02-17 11:56:12 +09:00
CuriousLearner
f27a0ad144 Bug 1302763 - Move docker images out of testing/docker into taskcluster/docker; r=dustin r=CuriousLearner
MozReview-Commit-ID: 7v1uCDB5qoN
2016-10-20 18:25:34 +05:30
Jonas Finnemann Jensen
e09600726d Bug 1324414 - Reference prebuilt docker images by HASH. r=dustin
This adds a HASH file next to the VERSION file in the image
context folders for prebuilt docker images. And uses the
HASH for referencing the image in the tasks created by
the decision task.

This way docker will validate the image hash when pulling it
in production. Thus, attackers won't be able to inject code
by compromising the remote docker registries we use to store
prebuilt images. Further more, this makes validation of the
Chain-Of-Trust artifacts easier as this eliminates the need
for whitelists and hash validation.

MozReview-Commit-ID: FD3B9MyeU9Q
2016-12-19 11:31:56 +01:00
Sebastian Hengst
a30693c808 Backed out changeset fe7303de56be (bug 1302763) for failing webdriver tests on Linux x64 debug (geckodriver.manifest fetch failed). r=backout 2016-12-19 21:15:07 +01:00
CuriousLearner
5ad707be1b Bug 1302763 - Move docker images out of testing/docker into taskcluster/docker; r=CuriousLearner
MozReview-Commit-ID: 7v1uCDB5qoN
2016-10-20 18:25:34 +05:30
Jonas Finnemann Jensen
6a00728363 Bug 1316446 - Improve mach taskcluster-load-image r=gps
MozReview-Commit-ID: 3Y8fI5WXP1Y
2016-11-10 18:05:52 -08:00
Jonas Finnemann Jensen
2bae2cad08 Bug 1316183 - Compress docker images with zstd. r=dustin
* Compress docker images with zstd
 * Removed need for context.tar from decision task
 * Index images by level rather than project

MozReview-Commit-ID: 4RL4QXNWmpd
2016-11-07 11:26:27 -08:00
Gregory Szorc
c4aaaa805b Bug 1290531 - Build Docker images from custom tar contexts; r=dustin
Now that Docker image building is called from Python, we can start to
do advanced stuff with it.

With this commit, we switch from building Docker images directly from
the source directory ("the Docker way") to using our custom Docker image
build contexts.

The main advantage of this is that locally-built Docker images can now
use our custom Dockerfile syntax to include extra files in the build
context!

The code for building a Docker image from a context has been extracted
to its own standalone function. I have nefarious plans for this in the
future, such as the ability to override the FROM syntax to specify
URLs of images. This would allow us to host base images on our own
server, which removes a dependency on Docker Hub and improves
determinism, since images on Docker Hub change all the time.

MozReview-Commit-ID: 5lTdV8yEHkc
2016-07-29 13:41:59 -07:00
Gregory Szorc
62f4d481c2 Bug 1290531 - Invoke docker from Python, remove build.sh; r=dustin
build.sh had been reduced to invoking `docker`. We move that invocation
to Python and remove build.sh. Long live build.sh!

MozReview-Commit-ID: FQBDJv4HSaU
2016-07-29 13:22:06 -07:00
Gregory Szorc
67aa547f7e Bug 1290531 - Move image tag resolution to Python; r=dustin
We already had code for resolving the image registry and tag. We
refactored it slightly to be more useful then changed build.sh to
accept the tag as an argument.

At this point, build.sh is basically a wrapper around `docker`. But
there's a special case for executing custom "build.sh" files we
need to eliminate first...

MozReview-Commit-ID: A9HVvxgCdG2
2016-07-29 13:06:10 -07:00
Gregory Szorc
c5501b72a5 Bug 1290531 - Move image name verification to Python; r=dustin
MozReview-Commit-ID: 8KJZH5vjANS
2016-07-29 12:59:46 -07:00
Gregory Szorc
594ff4f3ad Bug 1290531 - Move docker validation from build.sh to Python; r=dustin
Now that we have a mach command and Python code for doing Docker image
building, we can start moving code from build.sh to Python.

We start with searching for and validating the `docker` binary works.

MozReview-Commit-ID: 2DCc3b8UyZ3
2016-07-29 12:58:39 -07:00
Gregory Szorc
f1364a2a25 Bug 1290531 - Add mach taskcluster-build-image command; r=dustin
Docker image building will soon need to use Python in order to produce
the image build context archive.

As the first step towards this, we introduce a Python function that
calls out to build.sh. We also implement a mach command that calls it
so we can test the functionality.

I'm not keen about introducing a new mach command. I'd prefer to have
a sub-command instead. I'm not sure what all uses
`mach taskcluster-load-image`. Perhaps we could make a `taskcluster`
top-level command. Or perhaps we could fold these image commands into
`mach taskgraph`? Either way, the mach side of this isn't terribly
important to the commit series: most of the code will live inside a
Python module outside of mach.

MozReview-Commit-ID: AI8p6H4psNh
2016-07-29 12:45:25 -07:00
Gregory Szorc
1498dcf793 Bug 1288567 - Use create_context_tar in generate_context_hash; r=dustin
This restores order to only having a single hash for a context
directory.

Using a tempfile here is a bit unfortunate. It can be optimized later,
if needed.

MozReview-Commit-ID: LMNsvt3fDYx
2016-07-22 12:46:06 -07:00
Dustin J. Mitchell
8bc81a73e8 Bug 1275409: remove taskcluster_graph.image_builder; r=wcosta
MozReview-Commit-ID: 21HBtcDVPXC
2016-06-06 18:55:10 +00:00