Docker changes to support public vs private builder container build
BUG=None
TEST=CQ
Cq-Depend: chromium:5632314
Cq-Depend: chromium:5634672
Change-Id: I44c15e42a4a7a700aa499ec59d35fab91cc1f5aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/5632274
Tested-by: Varun Srivastav <[email protected]>
Commit-Queue: Varun Srivastav <[email protected]>
Reviewed-by: Azizur Rahman <[email protected]>
(cherry picked from commit d22df985424c84d8e477ed5bd6f5a16c2ab65f71)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/5784774
Tested-by: Derek Beckett <[email protected]>
Commit-Queue: Derek Beckett <[email protected]>
Reviewed-by: Chris DeLaGarza <[email protected]>
diff --git a/src/chromiumos/test/dockerfiles/cros-test/Dockerfile b/src/chromiumos/test/dockerfiles/cros-test/Dockerfile
index 7fadb02..861fecc 100644
--- a/src/chromiumos/test/dockerfiles/cros-test/Dockerfile
+++ b/src/chromiumos/test/dockerfiles/cros-test/Dockerfile
@@ -115,6 +115,16 @@
# Copy ChromeOS Omnilab Gateway Client
COPY --chown=chromeos-test:chromeos-test chromeos_omnilab_gateway/gateway_go /usr/bin/
+ARG public
+RUN if [ "$public" = "True" ]; then \
+ echo 'Skipping chromeos_omnilab_gateway/gateway_go for public builder' && \
+ rm -f /usr/bin/gateway_go; \
+ else \
+ echo 'Including chromeos_omnilab_gateway/gateway_go'; \
+ fi
+
+
+
# ###############################################################################
# Everything above this point should not change per BOARD
# Everything below this point is possible/likely to change per BOARD
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_callbox/cros_callbox_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_callbox/cros_callbox_prep.py
index 21242ef..20c0d9b 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_callbox/cros_callbox_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_callbox/cros_callbox_prep.py
@@ -42,7 +42,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosCallboxArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_dut/cros_dut_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_dut/cros_dut_prep.py
index 7f8a1b9..a2a5a2d 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_dut/cros_dut_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_dut/cros_dut_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosDutArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_fw_provision/cros_fw_provision_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_fw_provision/cros_fw_provision_prep.py
index 8e97623..ed66152 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_fw_provision/cros_fw_provision_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_fw_provision/cros_fw_provision_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosFWProvisionArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_publish/cros_publish_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_publish/cros_publish_prep.py
index cf53915..ca33376 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_publish/cros_publish_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_publish/cros_publish_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosPublishArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_pvs/cros_pvs_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_pvs/cros_pvs_prep.py
index 535aa0e..94c06d6 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_pvs/cros_pvs_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_pvs/cros_pvs_prep.py
@@ -39,7 +39,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosPvsArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_servod/cros_servod_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_servod/cros_servod_prep.py
index 2fc4da6..488db9c 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_servod/cros_servod_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_servod/cros_servod_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosServodArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/container_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/container_prep.py
index a8e9851..c92432e 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/container_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/container_prep.py
@@ -40,9 +40,10 @@
service=service,
)
- def prep(self):
+ def prep(self, is_public: bool = False):
"""Run the steps needed to prep the container artifacts."""
- self.download_omnilab_gateway_client()
+ if not is_public:
+ self.download_omnilab_gateway_client()
self.create_tarball()
self.copy_service()
self.copy_metadata()
@@ -91,7 +92,7 @@
def download_vpython3(self):
self.cipd_install("infra/tools/luci/vpython3/linux-amd64", "latest")
- abs_artifact_path = os.path.join(self.full_out, 'vpython3')
+ abs_artifact_path = os.path.join(self.full_out, "vpython3")
os.chmod(abs_artifact_path, 0o755)
def download_omnilab_gateway_client(self):
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/cros_test_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/cros_test_prep.py
index e97a538..911efac 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/cros_test_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test/cros_test_prep.py
@@ -40,12 +40,12 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosTestArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
sysroot=self.sysroot,
path=self.full_out_dir,
force_path=True,
- service=self.service
- ).prep()
+ service=self.service,
+ ).prep(is_public)
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test_finder/cros_test_finder_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test_finder/cros_test_finder_prep.py
index ce3a6f2..e8232b6 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test_finder/cros_test_finder_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/cros_test_finder/cros_test_finder_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
CrosTestFinderArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/pre_process/pre_process_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/pre_process/pre_process_prep.py
index 6796e8f..764c13c 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/pre_process/pre_process_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/pre_process/pre_process_prep.py
@@ -40,7 +40,7 @@
service=service,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
PreProcessArtifactPrep(
chroot=self.chroot,
out_path=self.out_path,
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_prep.py
index c1c90d2..09ce9d4 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_prep.py
@@ -27,6 +27,7 @@
"--cache-copy-layers",
"--cache-ttl=366h",
"--image-fs-extract-retry=2",
+ "{build_arg}",
{destinations}
{labels}
]
@@ -73,11 +74,11 @@
out_path=self.out_path,
)
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
"""To be implemented by child class."""
raise NotImplementedError
- def build_yaml(self):
+ def build_yaml(self, is_public: bool = False):
"""Construct and write the YAML into the docker context dir"""
subs = ""
destinations = ""
@@ -95,8 +96,13 @@
subs += SUB_TEMPLATE.format(var=var)
labels += LABEL_VAR.format(var=var)
+ build_arg = "--build-arg=public=True" if is_public else ""
+
cloudbuild_yaml = YAML_TEMPLATE.format(
- subs=subs, destinations=destinations, labels=labels
+ subs=subs,
+ destinations=destinations,
+ labels=labels,
+ build_arg=build_arg,
)
with open(
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_service_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_service_prep.py
index 9eb0638..c5b3c8b 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_service_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/base_service_prep.py
@@ -37,8 +37,7 @@
service=service,
)
-
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
"""Will ONLY cp the dockerfile + context to the build context."""
if os.path.exists(self.full_out_dir):
print(f"Deleting existing prepdir {self.full_out_dir}")
diff --git a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/common_service_prep.py b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/common_service_prep.py
index 052b88c..df5ba76 100644
--- a/src/chromiumos/test/python/src/docker_libs/build_libs/shared/common_service_prep.py
+++ b/src/chromiumos/test/python/src/docker_libs/build_libs/shared/common_service_prep.py
@@ -39,7 +39,7 @@
# TODO, better src discovery.
- def prep_container(self):
+ def prep_container(self, is_public: bool = False):
"""Will ONLY cp the given service and dockerfile to the build context."""
if os.path.exists(self.full_out_dir):
print(f"Deleting existing prepdir {self.full_out_dir}")
diff --git a/src/chromiumos/test/python/src/docker_libs/cli/build-dockerimages.py b/src/chromiumos/test/python/src/docker_libs/cli/build-dockerimages.py
index 914b7ec..7d0574e 100755
--- a/src/chromiumos/test/python/src/docker_libs/cli/build-dockerimages.py
+++ b/src/chromiumos/test/python/src/docker_libs/cli/build-dockerimages.py
@@ -103,9 +103,7 @@
BUILD_RETRIES = 1
RETRIES_WAIT = 31
# callbox is not used (and a bit heavy) so do not build until its needed.
-DO_NOT_BUILD = set(
- ["cros-callbox", "cros-servod", "cros-hpt"]
-)
+DO_NOT_BUILD = set(["cros-callbox", "cros-servod", "cros-hpt"])
# NOTE: when promoting a service from DO_NOT_BUILD, it should be added to
# NON_CRITICAL for at least a short time to verify health.
NON_CRITICAL = set(
@@ -204,6 +202,12 @@
default=RETRIES_WAIT,
help="How long to wait between retries.",
)
+ parser.add_argument(
+ "--is_public",
+ dest="is_public",
+ action="store_true",
+ help="If builder is public",
+ )
args = parser.parse_intermixed_args()
return args
@@ -247,10 +251,10 @@
service=service,
)
- prepper.prep_container()
+ prepper.prep_container(args.is_public)
gcloud_build = isCloudBuild(args, info)
if gcloud_build:
- prepper.build_yaml()
+ prepper.build_yaml(args.is_public)
builder = GcloudDockerBuilder if gcloud_build else LocalDockerBuilder
err = False