cft: move servod to common-builder, but not enabled
no ebuild yet, so don't turn it on. also remove util.sh as this was the
last dep on it (I think)
BUG=None
TEST=cq
Change-Id: Iece2c324ae200ff014fff97cf0606fff13f0e445
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/3647005
Reviewed-by: Sergey Frolov <sfrolov@google.com>
Commit-Queue: Derek Beckett <dbeckett@chromium.org>
Reviewed-by: Seewai Fu <seewaifu@google.com>
Reviewed-by: Deniz Kara <denizkara@google.com>
Tested-by: Derek Beckett <dbeckett@chromium.org>
diff --git a/src/chromiumos/test/servod/docker/Dockerfile b/src/chromiumos/test/dockerfiles/cros-servod/Dockerfile
similarity index 100%
rename from src/chromiumos/test/servod/docker/Dockerfile
rename to src/chromiumos/test/dockerfiles/cros-servod/Dockerfile
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 1ea3066..de2f2be 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
@@ -43,9 +43,15 @@
'prepper': CrosTestDockerPrepper, 'cloud': True},
'cros-test-finder': {
'prepper': CrosTestFinderDockerPrepper, 'cloud': True},
+ 'cros-servod': {
+ 'prepper': CommonServiceDockerPrepper, 'cloud': False},
}
-DO_NOT_BUILD = set(['cros-callbox'])
+# callbox currently fails building and was disabled per b/
+# cros-servod does not have a ebuild yet, thus is not ready for building.
+DO_NOT_BUILD = set(['cros-callbox', 'cros-servod'])
+# NOTE: when promoting a service from DO_NOT_BUILD, it should be added to
+# NON_CRITICAL for atleast a short time to verify health.
NON_CRITICAL = set(['cros-dut', 'cros-provision'])
diff --git a/src/chromiumos/test/servod/docker/build-dockerimage.sh b/src/chromiumos/test/servod/docker/build-dockerimage.sh
deleted file mode 100755
index aaa199e..0000000
--- a/src/chromiumos/test/servod/docker/build-dockerimage.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set -eE -o functrace
-
-# Print context information in the event of a failure to help debugging.
-failure() {
- local lineno=$1
- local msg=$2
- echo "failed at ${lineno}: ${msg}" >&2
-}
-trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
-
-readonly script_dir="$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
-
-source "${script_dir}/../../../../../test/docker/util.sh"
-
-usage() {
- echo "Usage: $0 <chroot> <sysroot> [options] [key=value...]"
- echo
- echo "Build a docker container for the cros-servod service."
- echo
- echo "Args:"
- echo " chroot - Path to the ChromeOS chroot on the host system."
- echo " sysroot - Path inside of the chroot to the board sysroot."
- echo " labels - Zero or more key=value strings to apply as labels to container."
- echo
- echo "Options:"
- echo " --tags/-t - Comma separated list of tag names to apply to container"
- echo " --output/-o - File to which to write ContainerImageInfo jsonproto"
- exit 1
-}
-
-if [[ $# -lt 3 ]]; then
- usage
-fi
-
-chroot="$1"; shift
-shift # don't care about sysroot
-
-host=""
-project=""
-tags=""
-output=""
-while [[ $# -gt 0 ]]; do
- case $1 in
- --host|-h)
- host="$2"
- shift 2
- ;;
- --project|-p)
- project="$2"
- shift 2
- ;;
- --tags|-t)
- tags="$2"
- shift 2
- ;;
- --output|-o)
- output="$2"
- shift 2
- ;;
- *)
- break
- ;;
- esac
-done
-
-build_server_image \
- --service "cros-servod" \
- --docker_file "${script_dir}/Dockerfile" \
- --chroot "${chroot}" \
- --tags "${tags}" \
- --output "${output}" \
- --host "${host}" \
- --project "${project}" \
- "${@}"
diff --git a/test/docker/util.sh b/test/docker/util.sh
deleted file mode 100644
index 24c139f..0000000
--- a/test/docker/util.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-#!/bin/bash
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-readonly current_dir="$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
-
-readonly chroot_default="${current_dir}/../../../../../chroot"
-
-validate () {
- # @FUNCTION: validate
- # @USAGE: validates inputs to build_*
- # @DESCRIPTION:
- #
- # Args:
- # $1: Server name (as built/installed into /usr/bin on the chroot)
- # $2: Dockerfile path for the build
- # $3: (optional) chroot path
- # $4: (optional) tags
- # $5: (optional) output file for metadata
- # $6: (optional) host
- # $7: (optional) project
- # $8+: (optional) labels
- server_name=""
- docker_file=""
- chroot_arg=""
- tags=""
- output_path=""
- registry_name=""
- cloud_project=""
- while [[ $# -gt 0 ]]; do
- case $1 in
- --service| -s)
- server_name="$2"
- shift 2
- ;;
- --docker_file| -d)
- docker_file="$2"
- shift 2
- ;;
- --chroot| -c)
- chroot_arg="$2"
- shift 2
- ;;
- --tags| -t)
- tags="$2"
- shift 2
- ;;
- --output| -o)
- output_path="$2"
- shift 2
- ;;
- --host| -h)
- registry_name="$2"
- shift 2
- ;;
- --project| -p)
- cloud_project="$2"
- shift 2
- ;;
- *)
- break
- ;;
- esac
- done
-
- if [[ "${server_name}" == "" || "${docker_file}" == "" ]]; then
- die "${FUNCNAME[0]}: Server name and Dockerfile path required"
- fi
- # Aggregate rest of CLI arguments as labels into an array
- labels=( "$@" )
-
- # shellcheck source=/dev/null
- if [[ -e ${CHROOT_VERSION_FILE} ]]; then
- echo "Script must run outside the chroot since this depends on docker"
- exit 1
- fi
-
- chroot="${chroot_arg}"
- if [ -z "${chroot}" ]; then
- echo "No chroot specified, so defaulting to: ${chroot_default}"
- chroot="${chroot_default}"
- fi
-
- if [ ! -d "${chroot}" ]; then
- echo "chroot path does not exist: ${chroot}"
- exit 1
- fi
-
- readonly default_tag="local-${USER}"
- if [[ "${tags}" == "" ]]; then
- echo "No tags specified, defaulting to: ${default_tag}"
- tags="${default_tag}"
- fi
-
- readonly default_registry_name="us-docker.pkg.dev"
- if [[ "${registry_name}" == "" ]]; then
- echo "No host specified, defaulting to: ${default_registry_name}"
- registry_name="${default_registry_name}"
- fi
-
- readonly default_cloud_project="cros-registry/test-services"
- if [[ "${cloud_project}" == "" ]]; then
- echo "No project specified, defaulting to: ${default_cloud_project}"
- cloud_project="${default_cloud_project}"
- fi
-
- readonly image_name="${server_name}"
- readonly image_path="${registry_name}/${cloud_project}/${image_name}"
-
- readonly server_name docker_file chroot_arg tags
-}
-
-ensure_gcloud_helpers() {
- # @FUNCTION: ensure_gcloud_helpers
- # @USAGE: ensure_gcloud_helpers
- # @DESCRIPTION:
- # Setup gcloud credential helpers for Google Cloud container registries.
-
- # First call sets up default GCR registries, second call sets up
- # Artifact Registry registries.
- gcloud --quiet --verbosity=error auth configure-docker
- gcloud --quiet --verbosity=error auth configure-docker us-docker.pkg.dev
-}
-
-build_image() {
- # @FUNCTION: build_image
- # @USAGE: Docker builds + uploads to the registry.
- # @DESCRIPTION:
-
- # Construct and execute build command
- args=(-f "${docker_file}")
-
- # Map tags into -t options
- ntag=0
- IFS=,
- for tag in ${tags}; do
- ntag="$((ntag+1))"
- args+=(-t "${image_path}:${tag}")
- done
-
- # Map labels into --label options
- for label in "${labels[@]}"; do
- args+=(--label "${label:Q}")
- done
- args+=("${build_context}")
-
- echo docker build "${args[@]}"
- docker build "${args[@]}"
-
- # Print debugging info
- ensure_gcloud_helpers
- echo
- echo "== Gcloud helper configuration"
- docker-credential-gcloud list
-
- echo
- echo "== User Authorization Scopes"
- curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
- https://www.googleapis.com/oauth2/v1/tokeninfo
-
- # Push image to registry
- docker push --all-tags "${image_path}"
-
- # write output if requested
- if [[ -n "${output_path}" ]]; then
- local digest
- digest=$(docker inspect --format='{{index .RepoDigests 0}}' "${image_path}:${tag[0]}" | cut -d@ -f2)
-
- cat <<EOF > "${output_path}"
-{
- "repository" : {
- "hostname": "${registry_name}",
- "project" : "${cloud_project}"
- },
- "name" : "${image_name}",
- "digest" : "${digest}",
- "tags" : [
-EOF
-
- ii=0
- local tag_block=""
- IFS=,
- for tag in ${tags}; do
- tag_block+=" \"${tag}\""
-
- ii="$((ii+1))"
- if [[ $ii -lt ${ntag} ]]; then
- tag_block+=",\n"
- fi
- done
- echo -e "${tag_block}" >> "${output_path}"
-
- cat <<EOF >> "${output_path}"
- ]
-}
-EOF
- fi
-}
-
-
-build_container_image(){
- # @FUNCTION: build_container_image
- # @USAGE: [server_name]
- # @DESCRIPTION:
- #
- # Args:
- # $1: Server name (as built/installed into /usr/bin on the chroot)
- # $2: Dockerfile path for the build
- # $3: (optional) chroot path
- # $4: (optional) tags
- # $5: (optional) output file for metadata
- # $6: (optional) host
- # $7: (optional) project
- # $8+: (optional) labels
-
- validate "$@"
- readonly build_context=$(dirname "${docker_file}")
- build_image
- trap 'rm -rf "${build_context}"' EXIT
-}
-
-
-build_server_image() {
- # @FUNCTION: build_server_image
- # @USAGE: [server_name]
- # @DESCRIPTION:
- #
- # Args:
- # $1: Server name (as built/installed into /usr/bin on the chroot)
- # $2: Dockerfile path for the build
- # $3: (optional) chroot path
- # $4: (optional) tags
- # $5: (optional) output file for metadata
- # $6: (optional) host
- # $7: (optional) project
- # $8+: (optional) labels
- validate "$@"
-
- readonly tmpdir=$(mktemp -d)
- trap 'rm -rf "${tmpdir}"' EXIT
- cp "${chroot}/usr/bin/${server_name}" "${tmpdir}"
-
- readonly build_context="${tmpdir}"
- build_image
-}