Offload entry point and command from image

... to engine side. This allows operators to prepare multiple images
with less steps.

Change-Id: I279f4ad10c19e4121d4906469c989a935e504552
This commit is contained in:
Takashi Kajinami 2023-12-11 13:38:28 +09:00
parent ef064bb1ef
commit a9ad3a967e
5 changed files with 33 additions and 99 deletions

View File

@ -1,31 +0,0 @@
#!/bin/bash
# Copyright IBM Corp. 2015, 2015 All Rights Reserved
# Copyright (c) 2010-2016 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is the our docker ENTRYPOINT
# $1 determines between debug mode running mode
# For debug mode $2 is a command to execute
# Otherwise $2,$3 are as follows
# $2 is the path to the factory pipe , e.g. /channels/factory_pipe
# This path must be mapped by docker run -v option
# $3 is assumed to be the factory debug level, e.g. DEBUG
if [ $1 == "debug" ]; then
$2
else
PYTHONPATH='/usr/local/lib/storlets/python' /usr/local/libexec/storlets/storlets-daemon-factory $2 $3 $HOSTNAME
fi

View File

@ -198,11 +198,11 @@ function create_base_jre_image {
mkdir -p ${TMP_REGISTRY_PREFIX}/repositories/"$STORLETS_DOCKER_BASE_IMG_NAME"_jre${STORLETS_JDK_VERSION}
_generate_jre_dockerfile
cd ${TMP_REGISTRY_PREFIX}/repositories/"$STORLETS_DOCKER_BASE_IMG_NAME"_jre${STORLETS_JDK_VERSION}
sudo docker build -t ${STORLETS_DOCKER_BASE_IMG_NAME}_jre${STORLETS_JDK_VERSION} .
sudo docker build -t storlet_engine_image .
cd -
}
function _generate_logback_xml {
function create_logback_xml {
sudo tee /usr/local/lib/storlets/logback.xml <<EOF >/dev/null
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
@ -231,29 +231,6 @@ EOF
sudo chmod 0744 /usr/local/lib/storlets/logback.xml
}
function _generate_jre_storlet_dockerfile {
cat <<EOF > ${TMP_REGISTRY_PREFIX}/repositories/"$STORLETS_DOCKER_BASE_IMG_NAME"_jre${STORLETS_JDK_VERSION}_storlets/Dockerfile
FROM ${STORLETS_DOCKER_BASE_IMG_NAME}_jre${STORLETS_JDK_VERSION}
MAINTAINER root
RUN [ "groupadd", "-g", "$STORLETS_DOCKER_SWIFT_GROUP_ID", "swift" ]
RUN [ "useradd", "-u" , "$STORLETS_DOCKER_SWIFT_USER_ID", "-g", "$STORLETS_DOCKER_SWIFT_GROUP_ID", "swift" ]
CMD ["prod", "/mnt/channels/factory_pipe", "DEBUG"]
ENTRYPOINT ["/usr/local/libexec/storlets/init_container.sh"]
EOF
}
function create_storlet_engine_image {
echo "Create Storlet engine image"
mkdir -p ${TMP_REGISTRY_PREFIX}/repositories/"$STORLETS_DOCKER_BASE_IMG_NAME"_jre${STORLETS_JDK_VERSION}_storlets
_generate_logback_xml
_generate_jre_storlet_dockerfile
cd ${TMP_REGISTRY_PREFIX}/repositories/"$STORLETS_DOCKER_BASE_IMG_NAME"_jre${STORLETS_JDK_VERSION}_storlets
sudo docker build -t storlet_engine_image .
cd -
}
function install_storlets_code {
echo "Installing storlets"
cd $REPO_DIR
@ -271,6 +248,7 @@ function install_storlets_code {
# NOTE(takashi): We need --no-deps to avoid enum34 installed in py 2 env,
# which causes failure in py3 execution.
pip_install . -t /usr/local/lib/storlets/python --no-compile --no-deps
sudo mkdir -p -m 755 /usr/local/libexec/storlets
for bin_file in storlets-daemon storlets-daemon-factory ; do
sudo cp `which ${bin_file}` /usr/local/libexec/storlets/
done
@ -359,9 +337,11 @@ function install_storlets {
echo "Create Docker images"
create_base_jre_image
create_storlet_engine_image
create_default_tenant_image
echo "Create logback xml file"
create_logback_xml
echo "Create test configuration file"
create_test_config_file

View File

@ -183,47 +183,15 @@ with the following content:
apt-get install openjdk-11-jre-headless ant && \
apt-get clean
Build the image
Build the image and name it *storlet_engine_image*.
::
cd $HOME/docker_repos/ubuntu_22.04_jre11
sudo docker build -t ubuntu_22.04_jre11 .
cd -
Step 3: Augment the above created image with the storlets stuff
::
mkdir -p $HOME/docker_repos/storlet_engine_image
cd -
Create the file: $HOME/docker_repos/storlet_engine_image/Dockerfile
with the following content:
::
FROM ubuntu_22.04_jre11
MAINTAINER root
RUN [ "groupadd", "-g", "1003", "swift" ]
RUN [ "useradd", "-u" , "1003", "-g", "1003", "swift" ]
CMD ["prod", "/mnt/channels/factory_pipe", "DEBUG"]
ENTRYPOINT ["/usr/local/libexec/storlets/init_container.sh"]
Build the image
::
cd $HOME/docker_repos/storlet_engine_image
sudo docker build -t storlet_engine_image .
cd -
Step 4: Create a tenant specific image. The engine looks for images
Step 3: Create a tenant specific image. The engine looks for images
having the name <tenand id>.
First, we get the tenant id. Using the Swift cli and the above create user do:

View File

@ -13,9 +13,3 @@ cd -
# Install java library
ant install
# Install container side scripts
SRC=bin
DST=/usr/local/libexec/storlets
mkdir -p -m 755 $DST
cp "$SRC/init_container.sh" $DST

View File

@ -153,6 +153,10 @@ class RunTimePaths(object):
def host_factory_pipe(self):
return os.path.join(self.host_pipe_dir, self.factory_pipe_name)
@property
def sandbox_factory_pipe(self):
return os.path.join(self.sandbox_pipe_dir, self.factory_pipe_name)
def get_host_storlet_pipe(self, storlet_id):
return os.path.join(self.host_pipe_dir, storlet_id)
@ -228,6 +232,8 @@ class RunTimeSandbox(object):
# TODO(add line in conf)
self.storlet_daemon_thread_pool_size = \
int(conf.get('storlet_daemon_thread_pool_size', 5))
self.storlet_daemon_factory_debug_level = \
conf.get('storlet_daemon_factory_debug_level', 'DEBUG')
self.storlet_daemon_debug_level = \
conf.get('storlet_daemon_debug_level', 'DEBUG')
@ -334,8 +340,25 @@ class RunTimeSandbox(object):
# Start the new one
client.containers.run(
docker_image_name, detach=True, name=docker_container_name,
network_disabled=True, mounts=mounts, user='swift',
docker_image_name, detach=True,
command=[
self.paths.sandbox_factory_pipe,
self.storlet_daemon_factory_debug_level,
docker_container_name
],
entrypoint=[
os.path.join(
self.paths.sandbox_storlet_native_bin_dir,
'storlets-daemon-factory'
)
],
environment={
'PYTHONPATH': os.path.join(
self.paths.sandbox_storlet_native_lib_dir, 'python'
)
},
name=docker_container_name, network_disabled=True,
mounts=mounts, user=os.getuid(),
auto_remove=True, stop_signal='SIGHUP',
labels={'managed_by': 'storlets'})
except docker.errors.ImageNotFound: