mirror of
https://github.com/apache/impala.git
synced 2025-12-25 02:03:09 -05:00
IMPALA-8785: give debug docker images a different name
* Build scripts are generalised to have different targets for release and debug images. * Added new targets for the debug images: docker_debug_images, statestored_debug images. The release images still have the same names. * Separate build contexts are set up for the different base images. * The debug or release base image can be specified as the FROM for the daemon images. * start-impala-cluster.py picks the correct images for the build type Future work: We would like to generalise this to allow building from non-ubuntu-16.04 base images. This probably requires another layer of dockerfiles to specify a base image for impala_base with the required packages installed. Change-Id: I32d2e19cb671beacceebb2642aba01191bd7a244 Reviewed-on: http://gerrit.cloudera.org:8080/13905 Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
dfc968dff1
commit
def70c241d
@@ -72,7 +72,7 @@ start-impala-cluster.py --kill
|
||||
|
||||
# Build the docker images required to start the cluster.
|
||||
# parquet-reader is needed for e2e tests but not built for non-test build.
|
||||
make -j ${IMPALA_BUILD_THREADS} docker_images parquet-reader
|
||||
make -j ${IMPALA_BUILD_THREADS} docker_debug_images parquet-reader
|
||||
|
||||
source_impala_config
|
||||
|
||||
|
||||
@@ -575,7 +575,12 @@ class DockerMiniClusterOperations(object):
|
||||
"-e", "JAVA_TOOL_OPTIONS={0}".format(
|
||||
build_java_tool_options(DEFAULT_IMPALAD_JVM_DEBUG_PORT))]
|
||||
# The container build processes tags the generated image with the daemon name.
|
||||
image_tag = daemon
|
||||
debug_build = options.build_type == "debug" or (options.build_type == "latest" and
|
||||
os.path.basename(os.path.dirname(os.readlink("be/build/latest"))) == "debug")
|
||||
if debug_build:
|
||||
image_tag = daemon + "_debug"
|
||||
else:
|
||||
image_tag = daemon
|
||||
host_name = self.__gen_host_name__(daemon, instance)
|
||||
container_name = self.__gen_container_name__(daemon, instance)
|
||||
# Mount configuration into container so that we don't need to rebuild container
|
||||
|
||||
@@ -19,52 +19,77 @@ set(IMPALA_BASE_BUILD_CONTEXT_DIR
|
||||
${CMAKE_SOURCE_DIR}/docker/build_context
|
||||
)
|
||||
|
||||
# Build context depends on daemons and frontend jars
|
||||
# Sending the whole impala workspace including test binaries, testdata, etc
|
||||
# to the docker daemon can be very expensive, so we create a build context
|
||||
# with symlinks
|
||||
add_custom_target(impala_base_build_context
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/docker/setup_build_context.py
|
||||
DEPENDS daemons fe ${CMAKE_SOURCE_DIR}/docker/setup_build_context.py
|
||||
COMMENT "Creating impala base build context."
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Target for the base Impala image.
|
||||
add_custom_target(impala_base_image
|
||||
# Use tar with -h flag to assemble a tarball including all the symlinked files and
|
||||
# directories in the build context.
|
||||
COMMAND cd ${IMPALA_BASE_BUILD_CONTEXT_DIR} && tar cvh . | docker build -t impala_base -
|
||||
DEPENDS impala_base_build_context ${CMAKE_SOURCE_DIR}/docker/impala_base/Dockerfile
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/docker/daemon_entrypoint.sh
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/graceful_shutdown_backends.sh
|
||||
COMMENT "Building Impala base docker image."
|
||||
VERBATIM
|
||||
)
|
||||
# Add a target to build a base docker image for 'build_type'. 'build_context_args' are
|
||||
# passed to the setup_build_context.py script.
|
||||
function(add_base_image build_type build_context_args)
|
||||
# Build context depends on daemons and frontend jars
|
||||
# Sending the whole impala workspace including test binaries, testdata, etc
|
||||
# to the docker daemon can be very expensive, so we create a build context
|
||||
# with symlinks
|
||||
add_custom_target(impala_base_build_context_${build_type}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/docker/setup_build_context.py ${build_context_args}
|
||||
DEPENDS daemons fe ${CMAKE_SOURCE_DIR}/docker/setup_build_context.py
|
||||
COMMENT "Creating impala base build context build_type=${build_type}."
|
||||
VERBATIM
|
||||
)
|
||||
# Target for the base Impala image.
|
||||
add_custom_target(impala_base_image_${build_type}
|
||||
# Use tar with -h flag to assemble a tarball including all the symlinked files and
|
||||
# directories in the build context.
|
||||
COMMAND cd ${IMPALA_BASE_BUILD_CONTEXT_DIR}/${build_type} && tar cvh . | docker build -t impala_base_${build_type} -
|
||||
DEPENDS impala_base_build_context_${build_type} ${CMAKE_SOURCE_DIR}/docker/impala_base/Dockerfile
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/docker/daemon_entrypoint.sh
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/graceful_shutdown_backends.sh
|
||||
COMMENT "Building Impala base docker image build_type=${build_type}."
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
add_base_image(release "")
|
||||
add_base_image(debug "--debug-build")
|
||||
|
||||
# Target to build all docker images. Dependencies are added for each docker image
|
||||
# instantiated below.
|
||||
add_custom_target(docker_images)
|
||||
add_custom_target(docker_debug_images)
|
||||
|
||||
set(daemon_image_names "")
|
||||
|
||||
function(add_daemon_docker_image image_name)
|
||||
add_custom_target(${image_name}_image
|
||||
COMMAND cd ${CMAKE_SOURCE_DIR}/docker/${image_name} && docker build -t ${image_name} .
|
||||
DEPENDS impala_base_image ${CMAKE_SOURCE_DIR}/docker/${image_name}/Dockerfile
|
||||
# Add a target with name 'target' to build a daemon image for the daemon with
|
||||
# name 'daemon_name', e.g. "impalad_executor". The image is tagged as 'image_name'.
|
||||
# 'build_type' should be debug or release and determines which base image is used.
|
||||
function(add_daemon_docker_image target daemon_name image_name build_type)
|
||||
set(build_dir ${CMAKE_SOURCE_DIR}/docker/${daemon_name})
|
||||
add_custom_target(${target}
|
||||
# Supply the appropriate base image as an argument for the Dockerfile.
|
||||
COMMAND cd ${build_dir} && docker build --build-arg BASE_IMAGE=impala_base_${build_type} -t ${image_name} .
|
||||
DEPENDS impala_base_image_${build_type} ${build_dir}/Dockerfile
|
||||
COMMENT "Building ${image_name} docker image."
|
||||
VERBATIM
|
||||
)
|
||||
ADD_DEPENDENCIES(docker_images ${image_name}_image)
|
||||
set(daemon_image_names "${daemon_image_names} ${image_name}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Command and target for the various Impalad images.
|
||||
add_daemon_docker_image(impalad_coord_exec)
|
||||
add_daemon_docker_image(impalad_coordinator)
|
||||
add_daemon_docker_image(impalad_executor)
|
||||
add_daemon_docker_image(catalogd)
|
||||
add_daemon_docker_image(statestored)
|
||||
# Add debug and release docker image targets for the given daemon e.g. if called
|
||||
# with "statestored", targets "statestored_image" and "statestored_debug_image"
|
||||
# are added.
|
||||
function(add_daemon_docker_images daemon_name)
|
||||
set(release_image ${daemon_name})
|
||||
set(release_target ${daemon_name}_image)
|
||||
set(debug_image ${daemon_name}_debug)
|
||||
set(debug_target ${daemon_name}_debug_image)
|
||||
add_daemon_docker_image(${release_target} ${daemon_name} ${release_image} release)
|
||||
add_daemon_docker_image(${debug_target} ${daemon_name} ${debug_image} debug)
|
||||
ADD_DEPENDENCIES(docker_images ${release_target})
|
||||
ADD_DEPENDENCIES(docker_debug_images ${debug_target})
|
||||
set(daemon_image_names "${daemon_image_names} ${release_image}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Generate a test file with all the daemon images.
|
||||
# Stamp out image targets for all of the Impala daemons.
|
||||
add_daemon_docker_images(impalad_coord_exec)
|
||||
add_daemon_docker_images(impalad_coordinator)
|
||||
add_daemon_docker_images(impalad_executor)
|
||||
add_daemon_docker_images(catalogd)
|
||||
add_daemon_docker_images(statestored)
|
||||
|
||||
# Generate a text file with all of the release daemon images.
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/docker/docker-images.txt "${daemon_image_names}")
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FROM impala_base
|
||||
ARG BASE_IMAGE=impala_base
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Externally-facing ports
|
||||
# Debug webserver
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FROM impala_base
|
||||
ARG BASE_IMAGE=impala_base
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Externally-facing ports
|
||||
# Beeswax
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FROM impala_base
|
||||
ARG BASE_IMAGE=impala_base
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Externally-facing ports
|
||||
# Beeswax
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FROM impala_base
|
||||
ARG BASE_IMAGE=impala_base
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Externally-facing ports
|
||||
# Debug webserver
|
||||
|
||||
@@ -20,13 +20,23 @@
|
||||
# Most artifacts are symlinked so need to be dereferenced (e.g. with tar -h) before
|
||||
# being used as a build context.
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
from subprocess import check_call
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--debug-build", help="Setup build context for debug build",
|
||||
action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
IMPALA_HOME = os.environ["IMPALA_HOME"]
|
||||
OUTPUT_DIR = os.path.join(IMPALA_HOME, "docker/build_context")
|
||||
if args.debug_build:
|
||||
BUILD_TYPE = "debug"
|
||||
else:
|
||||
BUILD_TYPE = "release"
|
||||
OUTPUT_DIR = os.path.join(IMPALA_HOME, "docker/build_context", BUILD_TYPE)
|
||||
DOCKERFILE = os.path.join(IMPALA_HOME, "docker/impala_base/Dockerfile")
|
||||
|
||||
IMPALA_TOOLCHAIN = os.environ["IMPALA_TOOLCHAIN"]
|
||||
@@ -59,9 +69,15 @@ def symlink_file_into_dir(src_file, dst_dir):
|
||||
|
||||
|
||||
# Impala binaries and native dependencies.
|
||||
check_call([STRIP, "--strip-debug",
|
||||
os.path.join(IMPALA_HOME, "be/build/latest/service/impalad"),
|
||||
"-o", os.path.join(BIN_DIR, "impalad")])
|
||||
|
||||
# Strip debug symbols from release build to reduce image size. Keep them for
|
||||
# debug build.
|
||||
IMPALAD_BINARY = os.path.join(IMPALA_HOME, "be/build", BUILD_TYPE, "service/impalad")
|
||||
if args.debug_build:
|
||||
symlink_file_into_dir(IMPALAD_BINARY, BIN_DIR)
|
||||
else:
|
||||
check_call([STRIP, "--strip-debug", IMPALAD_BINARY,
|
||||
"-o", os.path.join(BIN_DIR, "impalad")])
|
||||
for lib in ["libstdc++", "libgcc"]:
|
||||
for so in glob.glob(os.path.join(GCC_HOME, "lib64/{0}*.so*".format(lib))):
|
||||
symlink_file_into_dir(so, LIB_DIR)
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FROM impala_base
|
||||
ARG BASE_IMAGE=impala_base
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Externally-facing ports
|
||||
# Debug webserver
|
||||
|
||||
Reference in New Issue
Block a user