Returns a new container. logdir - subdirectory to create under self.log_dir, which will get mounted to /logs logname - name of file in logdir that will be created extras - extra arguments to pass to docker entrypoint - entrypoint arguments, as a list.
(self, image, name, logdir, logname, entrypoint, extras=None)
| 503 | self.suite_runners = [TestSuiteRunner(self, suite) for suite in suites] |
| 504 | |
| 505 | def _create_container(self, image, name, logdir, logname, entrypoint, extras=None): |
| 506 | """Returns a new container. |
| 507 | |
| 508 | logdir - subdirectory to create under self.log_dir, |
| 509 | which will get mounted to /logs |
| 510 | logname - name of file in logdir that will be created |
| 511 | extras - extra arguments to pass to docker |
| 512 | entrypoint - entrypoint arguments, as a list. |
| 513 | """ |
| 514 | if extras is None: |
| 515 | extras = [] |
| 516 | if self.test_mode: |
| 517 | extras = ["-e", "TEST_TEST_WITH_DOCKER=true"] + extras |
| 518 | |
| 519 | # According to localtime(5), /etc/localtime is supposed |
| 520 | # to be a symlink to somewhere inside /usr/share/zoneinfo. |
| 521 | # Note that sometimes the symlink tree may be |
| 522 | # complicated, e.g.: |
| 523 | # /etc/localtime -> |
| 524 | # /usr/share/zoneinfo/America/Los_Angeles -> (readlink) |
| 525 | # ../US/Pacific-New (realpath) |
| 526 | # Using both readlink and realpath should work, but we've |
| 527 | # encountered one scenario (centos:6) where the Java tzdata |
| 528 | # database doesn't have US/Pacific-New, but has America/Los_Angeles. |
| 529 | # This is deemed sufficient to tip the scales to using readlink. |
| 530 | assert os.path.islink("/etc/localtime") |
| 531 | localtime_link_target = os.readlink("/etc/localtime") |
| 532 | assert localtime_link_target.startswith("/usr/share/zoneinfo") |
| 533 | |
| 534 | # Workaround for what appears to be https://github.com/moby/moby/issues/13885 |
| 535 | # Namely, if we run too many "docker create" at the same time, one |
| 536 | # of them hangs forever. To avoid the issue, we serialize the invocations |
| 537 | # of "docker create". |
| 538 | with self.docker_lock: |
| 539 | container_id = _check_output([ |
| 540 | "docker", "create", |
| 541 | # Required for some of the ntp handling in bootstrap and Kudu; |
| 542 | # requirement may be lifted in newer Docker versions. |
| 543 | "--privileged", |
| 544 | "--name", name, |
| 545 | # Whereas the container names vary across containers, we use the same |
| 546 | # hostname repeatedly, so that the build container and the test |
| 547 | # containers have the same hostnames. Kudu errors out with "Remote |
| 548 | # error: Service unavailable: Timed out: could not wait for desired |
| 549 | # snapshot timestamp to be consistent: Tablet is lagging too much to be |
| 550 | # able to serve snapshot scan." if reading with READ_AT_SNAPSHOT |
| 551 | # if the hostnames change underneath it. |
| 552 | "--hostname", self.name, |
| 553 | # Label with the git root directory for easier cleanup |
| 554 | "--label=pwd=" + self.git_root, |
| 555 | # Consistent locales |
| 556 | "-e", "LC_ALL=C.UTF-8", |
| 557 | "-e", "IMPALAD_MEM_LIMIT_BYTES=" + |
| 558 | str(self.impalad_mem_limit_bytes), |
| 559 | # Mount the git directory so that clones can be local. |
| 560 | # We use /repo to have access to certain scripts, |
| 561 | # and we use /git_common_dir to have local clones, |
| 562 | # even when "git worktree" is being used. |
no test coverage detected