Skip to content

Commit 9f3cefd

Browse files
feat: Add secret for pilots in CI
1 parent 5af196f commit 9f3cefd

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Building wheels
6363
run: |
6464
# Clone diracx
65-
git clone --single-branch --branch robin-pilot-management https://github.com/Robin-Van-de-Merghel/diracx.git $GITHUB_WORKSPACE/diracx
65+
git clone --single-branch --branch robin-pilot-registrations https://github.com/Robin-Van-de-Merghel/diracx.git $GITHUB_WORKSPACE/diracx
6666
6767
# Create dist dir
6868
mkdir -p $GITHUB_WORKSPACE/diracx-dist

tests/.dirac-ci-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config:
44
CLIENT_UPLOAD_BASE64: SSBsaWtlIHBpenphIQo=
55
CLIENT_UPLOAD_LFN: LFN:/vo/test_lfn.txt
66
CLIENT_UPLOAD_FILE: test_lfn.txt
7-
PILOT_INSTALLATION_COMMAND: dirac-pilot.py --modules /home/dirac/LocalRepo/ALTERNATIVE_MODULES/DIRAC -M 2 -N jenkins.cern.ch -Q jenkins-queue_not_important -n DIRAC.Jenkins.ch --pilotUUID=whatever12345 --CVMFS_locations=/home/dirac/ -o diracInstallOnly --wnVO=vo --debug
7+
PILOT_INSTALLATION_COMMAND: dirac-pilot.py --modules /home/dirac/LocalRepo/ALTERNATIVE_MODULES/DIRAC -M 2 -N jenkins.cern.ch -Q jenkins-queue_not_important -n DIRAC.Jenkins.ch --pilotUUID=whatever12345 --CVMFS_locations=/home/dirac/ -o diracInstallOnly --wnVO=vo --debug --diracx_URL=http://diracx:8000 --clientID=072afab5-ed92-46e0-a61d-4ecbc96e0770
88
PILOT_JSON: "{
99
\"timestamp\": \"2023-02-13T14:34:26.725499\",
1010
\"CEs\": {
@@ -37,7 +37,7 @@ config:
3737
\"https://server:9135/Configuration/Server\"
3838
]
3939
}"
40-
PILOT_DOWNLOAD_COMMAND: "git clone --single-branch --branch master https://github.com/DIRACGrid/Pilot.git && mv Pilot/Pilot/*.py . && rm -rf Pilot"
40+
PILOT_DOWNLOAD_COMMAND: "git clone --single-branch --branch adding-jwt-support https://github.com/Robin-Van-de-Merghel/Pilot.git && mv Pilot/Pilot/*.py . && rm -rf Pilot"
4141

4242
# List of feature variables which must be passed when preparing
4343
required-feature-flags: []

tests/CI/install_client.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,14 @@ if [[ -z "${INSTALLATION_BRANCH}" ]]; then
9494
echo " JobName = \"${GITHUB_JOB}_$(date +"%Y-%m-%d_%T" | sed 's/://g')\"" >> test_dl.jdl
9595
echo "]" >> test_dl.jdl
9696
dirac-wms-job-submit test_dl.jdl "${DEBUG}" |& tee -a clientTestOutputs.txt
97+
98+
#-------------------------------------------------------------------------------#
99+
if [[ "${TEST_DIRACX:-}" = "Yes" ]]; then
100+
echo -e "*** $(date -u) **** Creates DiracX credentials to run commands ****\n"
101+
installDIRACX cli
102+
setDiracXCreds prod
103+
# Generate secrets
104+
secret=$(dirac pilots generate-pilot-secrets vo 1 | jq -r '.[0].pilot_secret')
105+
echo "$secret" > /ca/certs/pilot_secret.txt
106+
fi
97107
fi

tests/CI/run_pilot.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@ elif command -v python2 &> /dev/null; then
4242
py='python2'
4343
fi
4444

45+
additional_params=""
46+
47+
if [[ -n "$TEST_DIRACX" && "$TEST_DIRACX" == "Yes" ]]; then
48+
# Read the pilot secret from file
49+
secret=$(cat /ca/certs/pilot_secret.txt)
50+
additional_params="--pilotSecret $secret"
51+
fi
52+
4553
# shellcheck disable=SC2086
46-
$py ${PILOT_INSTALLATION_COMMAND}
54+
$py ${PILOT_INSTALLATION_COMMAND} ${additional_params}

tests/Jenkins/utilities.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,3 +729,45 @@ stopRunsv() {
729729

730730
echo '==> [Done stopRunsv]'
731731
}
732+
733+
734+
735+
#.............................................................................
736+
#
737+
# setDiracXCreds
738+
#
739+
# gets creds from x509, extract token, and put it in the right place
740+
#
741+
#.............................................................................
742+
setDiracXCreds() {
743+
# $1 = DIRAC group
744+
local group="$1"
745+
local cache_dir="$HOME/.cache/diracx"
746+
local creds_file="$cache_dir/credentials.json"
747+
local tmpfile
748+
749+
if [[ -z "$group" ]]; then
750+
echo "Usage: setDiracXCreds <DIRAC_GROUP>" >&2
751+
return 1
752+
fi
753+
754+
# 1. Init DIRAC proxy
755+
dirac-proxy-init -g "$group"
756+
757+
# 2. Extract DiracX token from proxy PEM
758+
tmpfile=$(mktemp)
759+
python - <<'EOF' > "$tmpfile"
760+
from DIRAC.Core.Security.DiracX import diracxTokenFromPEM
761+
from DIRAC.Core.Security.Locations import getProxyLocation
762+
import json
763+
pem_location = getProxyLocation()
764+
token = diracxTokenFromPEM(pem_location)
765+
if token:
766+
print(json.dumps(token))
767+
EOF
768+
769+
# 3. Move to ~/.cache/diracx/credentials.json
770+
mkdir -p "$cache_dir"
771+
mv "$tmpfile" "$creds_file"
772+
echo "DiracX credentials updated at $creds_file"
773+
}

0 commit comments

Comments
 (0)