Skip to content

Commit

Permalink
Merge pull request #12 from epics-containers/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
gilesknap authored Nov 12, 2024
2 parents 3bc9002 + 167f9fd commit d01eef1
Show file tree
Hide file tree
Showing 28 changed files with 293 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 0.2.5b-8-g68f96c8
_commit: 4.0.2b1
_src_path: gh:epics-containers/services-template-helm
cluster_name: pollux
cluster_namespace: p47-beamline
Expand Down
41 changes: 39 additions & 2 deletions .github/workflows/ci_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,45 @@
# other future services that don't use ibek, we will need to add a standard
# entrypoint for validating the config folder mounted at /config.

ROOT=$(realpath $(dirname ${0})/../..)
HERE=$(realpath $(dirname ${0}))
ROOT=$(realpath ${HERE}/../..)
set -xe
rm -rf ${ROOT}/.ci_work/
mkdir -p ${ROOT}/.ci_work

# use docker if available else use podman
if ! docker version &>/dev/null; then docker=podman; else docker=docker; fi

for service in ${ROOT}/services/*
# copy the services to a temporary location to avoid dirtying the repo
cp -r ${ROOT}/services/* ${ROOT}/.ci_work/

for service in ${ROOT}/.ci_work/*/ # */ to skip files
do
### Lint each service chart and validate if schema given ###
service_name=$(basename $service)

# skip services appearing in ci_skip_checks
checks=${HERE}/ci_skip_checks
if [[ -f ${checks} ]] && grep -q ${service_name} ${checks}; then
echo "Skipping ${service_name}"
continue
fi

schema=$(cat ${service}/values.yaml | sed -rn 's/^# yaml-language-server: \$schema=(.*)/\1/p')
if [ -n "${schema}" ]; then
echo "{\"\$ref\": \"$schema\"}" > ${service}/values.schema.json
fi

$docker run --rm --entrypoint bash \
-v ${ROOT}/.ci_work:/services \
alpine/helm:3.14.3 \
-c "
helm lint /services/$service_name --values /services/values.yaml &&
helm dependency update /services/$service_name &&
rm -rf /services/$service_name/charts
"

### Valiate each ioc config ###
# Skip if subfolder has no config to validate
if [ ! -f "${service}/config/ioc.yaml" ]; then
continue
Expand All @@ -30,6 +61,9 @@ do
runtime=/tmp/ioc-runtime/$(basename ${service})
mkdir -p ${runtime}

# avoid issues with auto-gen genicam pvi files (ioc-adaravis only)
sed -i s/AutoADGenICam/ADGenICam/ ${service}/config/ioc.yaml

# This will fail and exit if the ioc.yaml is invalid
$docker run --rm --entrypoint bash \
-v ${service}/config:/config \
Expand All @@ -40,4 +74,7 @@ do
cat ${runtime}/st.cmd

fi

done

rm -r ${ROOT}/.ci_work
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ venv*
**/charts
**/*copy
*.code-workspace
.ci_work
49 changes: 49 additions & 0 deletions experiments/debug_pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: v1
kind: Pod
metadata:
name: debug-adaravis
labels:
is_ioc: "true"
spec:
serviceAccountName: default-full-access-mounted
containers:
- name: debug-adaravis
image: ghcr.io/epics-containers/ioc-adaravis-developer:2024.11.1
command:
- bash
args:
- "-c"
- |
echo "keep running indefinetely"
while true; do sleep 5; done
resources:
limits:
memory: "2Gi"
cpu: "4"
requests:
memory: "1Gi"
cpu: "1"

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: beamline
operator: In
values:
- bl47p

tolerations:
- key: beamline
operator: Equal
value: bl47p
effect: NoSchedule
- key: location
operator: Equal
value: bl47p
effect: NoSchedule
- key: nodetype
operator: Equal
value: training-rig
effect: NoSchedule
59 changes: 59 additions & 0 deletions experiments/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python

"""
Prints out some information about the pods in a namespace
"""

import argparse

from kubernetes import client, config


def get_ioc_ips(v1: client.CoreV1Api):
"""Get the list cluster IPs of IOCs running in a namespace
Args:
v1: kubernetes client
namespace: namespace to get the IOCs from
"""
ips = set()

# get the current namespace
ns_path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
with open(ns_path) as f:
current_namespace = f.read().strip()

# get the pods in the namespace
ret = v1.list_namespaced_pod(current_namespace)
for pod in ret.items:
print(pod.metadata.name, pod.status.pod_ip)
if "is_ioc" in pod.metadata.labels:
ips.add(pod.status.pod_ip)

return ips


def main():
args = parse_args()

# configure K8S and make a Core API client
config.load_incluster_config()
v1 = client.CoreV1Api()

ips = get_ioc_ips(v1)
ipstr = " ".join(ips)

command = f'/epics/ca-gateway/bin/linux-x86_64/gateway -sport {args.port} -cip "{ipstr}" -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1'

# print(f"Running command: {command}")
# subprocess.run(["bash", "-c", command], check=True)


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=5064)
return parser.parse_args()


if __name__ == "__main__":
main()
8 changes: 4 additions & 4 deletions opi/p47-beamline.bob
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>http://172.23.168.217/bl47p-ea-dcam-02/index.bob</file>
<file>https://p47-opis.diamond.ac.uk/bl47p-ea-dcam-02/index.bob</file>
<macros>
<P>BL47P-EA-DET-01</P>
<R>:DET:</R>
Expand All @@ -317,7 +317,7 @@
<name>OpenDisplay_1</name>
<actions>
<action type="open_display">
<file>http://172.23.168.217/bl47p-ea-dcam-01/index.bob</file>
<file>https://p47-opis.diamond.ac.uk/bl47p-ea-dcam-01/index.bob</file>
<macros>
<P>BL47P-EA-DET-01</P>
<R>:TX:</R>
Expand All @@ -344,7 +344,7 @@
<name>OpenDisplay_2</name>
<actions>
<action type="open_display">
<file>http://172.23.168.217/bl47p-mo-ioc-01/index.bob</file>
<file>https://p47-opis.diamond.ac.uk/bl47p-mo-ioc-01/index.bob</file>
<macros>
<P>BL47P-EA-DET-01</P>
<R>:HDF5:</R>
Expand All @@ -371,7 +371,7 @@
<name>OpenDisplay_3</name>
<actions>
<action type="open_display">
<file>http://172.23.168.217/bl47p-ea-panda-01/index.bob</file>
<file>https://p47-opis.diamond.ac.uk/bl47p-ea-panda-01/index.bob</file>
<macros>
<P>BL47P-EA-DET-01</P>
<R>:HDF5:</R>
Expand Down
93 changes: 55 additions & 38 deletions opi/phoebus-launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,61 @@
thisdir=$(realpath $(dirname ${BASH_SOURCE[0]}))
workspace=$(realpath ${thisdir}/..)

if [[ $(docker --version 2>/dev/null) == *Docker* ]]; then
docker=docker
if module load phoebus 2>/dev/null; then
echo "Using phoebus module"

# settings for p47
settings="
-resource ${workspace}/opi/p47-beamline.opi
-settings ${workspace}/opi/settings.ini
"

set -x
phoebus.sh ${settings} "${@}"
else
docker=podman
args="--security-opt=label=type:container_runtime_t"
echo "No phoebus module found, using a container"

if [[ $(docker --version 2>/dev/null) == *Docker* ]]; then
docker=docker
else
docker=podman
args="--security-opt=label=type:container_runtime_t"
fi

XSOCK=/tmp/.X11-unix # X11 socket (but we mount the whole of tmp)
XAUTH=/tmp/.container.xauth.$USER
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
chmod 777 $XAUTH

x11="
-e DISPLAY
-v $XAUTH:$XAUTH
-e XAUTHORITY=$XAUTH
--net host
"

args=${args}"
-it
"

export MYHOME=/home/${USER}
# mount in your own home dir in same folder for access to external files
mounts="
-v=/tmp:/tmp
-v=${MYHOME}/.ssh:/root/.ssh
-v=${MYHOME}:${MYHOME}
-v=${workspace}:/workspace
"

# settings for p47
settings="
-resource /workspace/opi/p47-beamline.opi
-settings /workspace/opi/settings.ini
"

set -x
$docker run ${mounts} ${args} ${x11} ghcr.io/epics-containers/ec-phoebus:latest ${settings} "${@}"

fi

XSOCK=/tmp/.X11-unix # X11 socket (but we mount the whole of tmp)
XAUTH=/tmp/.container.xauth.$USER
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
chmod 777 $XAUTH

x11="
-e DISPLAY
-v $XAUTH:$XAUTH
-e XAUTHORITY=$XAUTH
--net host
"

args=${args}"
-it
"

export MYHOME=/home/${USER}
# mount in your own home dir in same folder for access to external files
mounts="
-v=/tmp:/tmp
-v=${MYHOME}/.ssh:/root/.ssh
-v=${MYHOME}:${MYHOME}
-v=${workspace}:/workspace
"

# settings for p47
settings="
-resource /workspace/opi/p47-beamline.opi
-settings /workspace/opi/settings.ini
"

set -x
$docker run ${mounts} ${args} ${x11} ghcr.io/epics-containers/ec-phoebus:latest ${settings} "${@}"
4 changes: 2 additions & 2 deletions services/.ioc_template/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 3.5.2+b102
repository: "oci://ghcr.io/epics-containers"
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
2 changes: 1 addition & 1 deletion services/bl47p-ea-dcam-01/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 3.5.2+b102
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
7 changes: 5 additions & 2 deletions services/bl47p-ea-dcam-01/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-adaravis/releases/download/2024.7.2b1/ibek.ioc.schema.json
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-adaravis/releases/download/2024.11.1/ibek.ioc.schema.json

ioc_name: "{{ _global.get_env('IOC_NAME') }}"

Expand All @@ -16,12 +16,15 @@ entities:
IOC: "{{ ioc_name | upper }}"

- type: ADAravis.aravisCamera
CLASS: AVT_Mako_G234B
CLASS: AutoADGenICam
ID: 192.168.250.3
P: BL47P-EA-DET-01
PORT: DET.CAM
R: ":DET:"

- type: ADAravis.aravisSettings
camera: DET.CAM

- type: ADCore.NDPvaPlugin
NDARRAY_PORT: DET.CAM
P: BL47P-EA-DET-01
Expand Down
2 changes: 1 addition & 1 deletion services/bl47p-ea-dcam-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service

ioc-instance:
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.9.1
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.11.2b1
2 changes: 1 addition & 1 deletion services/bl47p-ea-dcam-02/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type: application

dependencies:
- name: ioc-instance
version: 3.5.2+b102
version: 4.1.2
repository: "oci://ghcr.io/epics-containers"
5 changes: 4 additions & 1 deletion services/bl47p-ea-dcam-02/config/ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ entities:
IOC: "{{ ioc_name | upper }}"

- type: ADAravis.aravisCamera
CLASS: AVT_Mako_G234C
CLASS: AutoADGenICam
ID: 192.168.250.28
P: BL47P-EA-DET-02
PORT: DET2.CAM
R: ":DET:"

- type: ADAravis.aravisSettings
camera: DET2.CAM

- type: ADCore.NDPvaPlugin
ENABLED: 1
NDARRAY_ADDR: 0
Expand Down
2 changes: 1 addition & 1 deletion services/bl47p-ea-dcam-02/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ec-helm-charts/releases/download/3.4.4/ioc-instance.schema.json#/$defs/service

ioc-instance:
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.9.1
image: ghcr.io/epics-containers/ioc-adaravis-runtime:2024.11.2b1
Loading

0 comments on commit d01eef1

Please sign in to comment.