From 7e52e326226a1f5396be9c0cf3f1c43370e9b2f3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 25 2020 14:17:58 +0000 Subject: Allow logging into kerberos directly from the python code This solves the issue of ticket expiring underneath us, this way each run will have re-logged in using the keytab thus ensuring that we are good to proceed in that front. Signed-off-by: Pierre-Yves Chibon --- diff --git a/entrypoint.sh b/entrypoint.sh index 4bb2884..5c2d603 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,12 +10,10 @@ ln -s /opt/ssh/id_rsa /.ssh/id_rsa || true if [ -z ${PRODUCTION+x} ]; then # Staging info echo "Running in staging" -kinit monitor-gating/os-master01.stg.phx2.fedoraproject.org@STG.FEDORAPROJECT.ORG -kt /etc/keytabs/koji-keytab ssh-keyscan pkgs.stg.fedoraproject.org >> /.ssh/known_hosts else # Prod info echo "Running in production" -kinit packagerbot/os-master01.phx2.fedoraproject.org@FEDORAPROJECT.ORG -kt /etc/keytabs/monitor-gating-keytab ssh-keyscan pkgs.fedoraproject.org >> /.ssh/known_hosts fi diff --git a/monitor_gating.cfg b/monitor_gating.cfg index 69b9dc7..bb29e56 100644 --- a/monitor_gating.cfg +++ b/monitor_gating.cfg @@ -20,3 +20,9 @@ name_multi_2 = "dummy-test-package-rubino" branch = "master" pagure_token = "" koji_end_tag = "f33" + +# Those values are commented out as they will not work in a dev environment +# where it is advised that the developer runs kinit manually before running the +# project. +# kb_principal = "packagerbot/os-master01.phx2.fedoraproject.org@FEDORAPROJECT.ORG" +# kb_keytab_file = "/etc/keytabs/monitor-gating-keytab" diff --git a/runner.py b/runner.py index 3774f9a..26e6379 100644 --- a/runner.py +++ b/runner.py @@ -17,6 +17,7 @@ import toml import monitor_gating_single_build import monitor_gating_multi_builds +from utils import run_command s = sched.scheduler(time.time, time.sleep) conf = toml.load @@ -52,6 +53,12 @@ def notify(topic, message): def schedule(conf): """ Run the test and schedules the next one. """ + + if conf.get("kb_principal") and conf.get("kb_keytab_file"): + print(f"Logging into kerberos using: {conf['kb_keytab_file']}") + cmd = ["kinit", conf["kb_principal"], "-kt", conf["kb_keytab_file"]] + run_command(cmd) + delay = conf["delay"] delay_when_failing = conf["delay_when_failing"] blocker_tags = conf["blocker_tags"]