Skip to content

Commit da68870

Browse files
authored
Merge pull request #119 from chaen/gubbins
Gubbins
2 parents 7c03f04 + c2f85ec commit da68870

File tree

4 files changed

+79
-28
lines changed

4 files changed

+79
-28
lines changed

demo/values.tpl.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ global:
22
# Override the imagePullPolicy to always so we can using latest image tags
33
# without risking them being outdated.
44
imagePullPolicy: Always
5+
# Keep the job log for 1h for investigations
6+
batchJobTTL: 3600
57

68
developer:
79
urls:

diracx/templates/diracx/deployment-cli.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ spec:
9292
value: {{ .Values.developer.urls.diracx }}
9393
- name: DIRACX_CA_PATH
9494
value: /ca/demo-ca.pem
95-
- name: CHRIS_TEST
96-
value: /ca/demo-ca.pem
9795
resources:
9896
{{- toYaml .Values.resources | nindent 12 }}
9997
{{- with .Values.nodeSelector }}

diracx/templates/diracx/init-sql/job.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ spec:
6161
name: diracx-sql-root-connection-urls
6262
key: DIRACX_DB_URL_{{ $dbName | upper }}
6363
{{- end }}
64+
# The secrets are needed for the extension to appear
6465
resources:
6566
{{- toYaml .Values.initSql.resources | nindent 12 }}
6667
volumes:

run_demo.sh

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,25 @@ function element_not_in_array() {
9797
return $found
9898
}
9999

100-
usage="${0##*/} [-h|--help] [--exit-when-done] [--offline] [--enable-coverage] [--no-mount-containerd] [--set-value key=value] [--ci-values=values.yaml] [--] [source directories]"
100+
usage="${0##*/} [-h|--help] [--exit-when-done] [--offline] [--enable-coverage] [--no-mount-containerd] [--set-value key=value] [--ci-values=values.yaml] [--load-docker-image=<image_name:tag>] [--] [source directories]"
101101
usage+="\n\n"
102102
usage+=" -h|--help: Print this help message and exit\n"
103+
usage+=" --ci-values: Path to a values.yaml file which contains diracx dev settings only enabled for CI\n"
103104
usage+=" --exit-when-done: Exit after the demo has been started (it will be left running in the background)\n"
104105
usage+=" --enable-coverage: Enable coverage reporting (used by diracx CI)\n"
106+
usage+=" --enable-open-telemetry: lauches OpenTelemetry collection.\n"
107+
usage+=" WARNING: experimental and resource hungry.\n"
108+
usage+=" --load-docker-image: Mount a local docker image into kind\n"
109+
usage+=" WARNING: the ImagePullPolicy MUST not be Always for this to work\n"
105110
usage+=" --no-editable-python: Do not install Python source directories in editable mode\n"
106-
usage+=" --offline: Run in a mode which is suitable for fully offline use.\n"
107-
usage+=" WARNING: This may result in some weird behaviour, see the demo documentation for details.\n"
108-
usage+=" Implies: --mount-containerd\n"
109111
usage+=" --no-mount-containerd: Mount a directory on the host for the kind containerd storage.\n"
110112
usage+=" This option avoids needing to pull container images every time the demo is started.\n"
111113
usage+=" WARNING: There is no garbage collection so the directory will grow without bound.\n"
112-
usage+=" --enable-open-telemetry: lauches OpenTelemetry collection.\n"
113-
usage+=" WARNING: experimental and resource hungry.\n"
114+
usage+=" --offline: Run in a mode which is suitable for fully offline use.\n"
115+
usage+=" WARNING: This may result in some weird behaviour, see the demo documentation for details.\n"
116+
usage+=" Implies: --mount-containerd\n"
114117
usage+=" --set-value: Set a value in the Helm values file. This can be used to override the default values.\n"
115118
usage+=" For example, to enable coverage reporting pass: --set-value developer.enableCoverage=true\n"
116-
usage+=" --ci-values: Path to a values.yaml file which contains diracx dev settings only enabled for CI\n"
117119
usage+=" source directories: A list of directories containing Python packages to mount in the demo cluster.\n"
118120

119121
# Parse command-line switches
@@ -124,7 +126,8 @@ declare -a helm_arguments=()
124126
enable_coverage=0
125127
editable_python=1
126128
open_telemetry=0
127-
ci_values_file=""
129+
declare -a ci_values_files=()
130+
declare -a docker_images_to_load=()
128131

129132
while [ -n "${1:-}" ]; do case $1 in
130133
# Print a brief usage summary and exit
@@ -197,6 +200,16 @@ while [ -n "${1:-}" ]; do case $1 in
197200
shift
198201
continue ;;
199202

203+
--load-docker-image)
204+
shift
205+
if [[ -z "${1:-}" ]]; then
206+
printf "%b Error: --load-docker-image requires an argument\n" ${SKULL_EMOJI}
207+
exit 1
208+
fi
209+
docker_images_to_load+=("${1}")
210+
shift
211+
continue ;;
212+
200213
--ci-values)
201214
shift
202215
if [[ -z "${1:-}" ]]; then
@@ -208,6 +221,7 @@ while [ -n "${1:-}" ]; do case $1 in
208221
printf "%b Error: --ci-values does not point to a file\n" ${SKULL_EMOJI}
209222
exit 1;
210223
fi
224+
ci_values_files+=("${ci_values_file}")
211225
shift
212226
continue ;;
213227

@@ -234,7 +248,7 @@ done
234248
declare -a pkg_dirs=()
235249
declare -a python_pkg_names=()
236250
node_pkg_name=""
237-
diracx_src_dir=""
251+
declare -a diracx_and_extensions_pkgs=()
238252

239253
for src_dir in "$@"; do
240254
if [ ${#pkg_dirs[@]} -gt 0 ] && ! element_not_in_array "$src_dir" "${pkg_dirs[@]}"; then
@@ -243,18 +257,30 @@ for src_dir in "$@"; do
243257
fi
244258
pkg_dirs+=("${src_dir}")
245259

246-
# DiracX itself
260+
261+
# Does that look like a namespace package with the structure we expect ?
262+
# i.e. is it diracx itself or an extension ?
247263
if [ -f "${src_dir}/pyproject.toml" ]; then
248-
if grep --quiet 'name = "diracx"' "${src_dir}/pyproject.toml"; then
249-
if [ "${diracx_src_dir}" != "" ]; then
250-
printf "%b Error: Source directory for DiracX was given twice!\n" "${SKULL_EMOJI}"
251-
exit 1
264+
# Name of the package
265+
pkg_name="$(basename "${src_dir}")"
266+
267+
# Do we find subdirectories called the same way as the package
268+
if [ -n "$(find "${src_dir}" -mindepth 3 -maxdepth 3 -type d -path "*src/${pkg_name}")" ]; then
269+
# And are there mulftiple pyprojects
270+
if [ -n "$(find "${src_dir}" -mindepth 2 -maxdepth 2 -type f -name "pyproject.toml")" ]; then
271+
# Then let's add all these
272+
while IFS= read -r sub_pkg_dir
273+
do
274+
diracx_and_extensions_pkgs+=("$(basename "${src_dir}")/$(basename "${sub_pkg_dir}")");
275+
done < <(find "${src_dir}" -mindepth 1 -maxdepth 1 -type d -name "${pkg_name}-*" )
276+
277+
continue;
278+
fi;
252279
fi
253-
diracx_src_dir="${src_dir}"
254-
continue
255-
fi
280+
256281
fi
257282

283+
258284
# Python packages
259285
if [ -f "${src_dir}/pyproject.toml" ]; then
260286
while IFS='' read -r pkg_dir; do
@@ -279,8 +305,9 @@ for src_dir in "$@"; do
279305
done < <(find "$src_dir" -mindepth 1 -maxdepth 1 -type f -name 'package.json')
280306
done
281307

282-
if [ "${diracx_src_dir}" != "" ]; then
283-
printf "%b Found DiracX directory: %s\n" ${UNICORN_EMOJI} "${diracx_src_dir}"
308+
309+
if [ ${#diracx_and_extensions_pkgs[@]} -gt 0 ]; then
310+
printf "%b Found Diracx/Extensions package directories for: %s\n" ${UNICORN_EMOJI} "${diracx_and_extensions_pkgs[*]}"
284311
fi
285312
if [ ${#python_pkg_names[@]} -gt 0 ]; then
286313
printf "%b Found Python package directories for: %s\n" ${UNICORN_EMOJI} "${python_pkg_names[*]}"
@@ -452,11 +479,12 @@ if [ ${#python_pkg_names[@]} -gt 0 ]; then
452479
json+="\"$pkg_name\","
453480
done
454481
fi
455-
if [ "${diracx_src_dir}" != "" ]; then
456-
for pkg_name in "$(basename "${diracx_src_dir}")/diracx-"{cli,client,api,core,routers,db}; do
457-
json+="\"$pkg_name\","
458-
done
459-
fi
482+
483+
for diracx_compatible_pkg in "${diracx_and_extensions_pkgs[@]}"; do
484+
json+="\"$diracx_compatible_pkg\","
485+
486+
done
487+
460488
json="${json%,}]"
461489
sed "s#{{ mounted_python_modules }}#${json}#g" "${demo_dir}/values.yaml.bak" > "${demo_dir}/values.yaml"
462490
mv "${demo_dir}/values.yaml" "${demo_dir}/values.yaml.bak"
@@ -470,6 +498,7 @@ if grep '{{' "${demo_dir}/values.yaml"; then
470498
exit 1
471499
fi
472500

501+
473502
# Add an ingress to the cluster
474503
printf "%b Creating an ingress...\n" ${UNICORN_EMOJI}
475504
# TODO: This should move to the chart itself
@@ -487,9 +516,30 @@ printf "%b Waiting for ingress controller to be created...\n" ${UNICORN_EMOJI}
487516
# Install the DiracX chart
488517
printf "%b Installing DiracX...\n" ${UNICORN_EMOJI}
489518
helm_arguments+=("--values" "${demo_dir}/values.yaml")
490-
if [[ -n "${ci_values_file}" ]]; then
491-
helm_arguments+=("--values" "${ci_values_file}")
519+
520+
if [ ${#ci_values_files[@]} -ne 0 ]; then
521+
printf "%b Adding extra values.yaml: ${ci_values_files[*]} \n" ${UNICORN_EMOJI}
522+
for ci_values_file in "${ci_values_files[@]}"
523+
do
524+
helm_arguments+=("--values" "${ci_values_file}")
525+
done
492526
fi
527+
528+
529+
# Load images into kind
530+
531+
if [ ${#docker_images_to_load[@]} -ne 0 ]; then
532+
printf "%b Loading docker images...\n" ${UNICORN_EMOJI}
533+
for img_name in "${docker_images_to_load[@]}"
534+
do
535+
"${demo_dir}/kind" --name diracx-demo load docker-image "${img_name}"
536+
done
537+
538+
539+
fi;
540+
541+
542+
493543
if ! "${demo_dir}/helm" install --debug diracx-demo "${script_dir}/diracx" "${helm_arguments[@]}"; then
494544
printf "%b Error using helm DiracX\n" ${WARN_EMOJI}
495545
echo "Failed to run \"helm install\"" >> "${demo_dir}/.failed"

0 commit comments

Comments
 (0)