debugging a postStart hook

2,478 views
Skip to first unread message

Kurt T Stam

unread,
Oct 13, 2016, 3:59:12 PM10/13/16
to fab...@googlegroups.com
Hey guys,

We are using a postStart hook to run the postStart.sh
(https://github.com/fabric8io/jenkins-docker/blob/master/postStart.sh).
I can't find errors produced in this script in the log. I'm forced to
redirect stdout and stderr on every cmd in this script to a file to see
any errors. Is there a better way to get the errors in our logs? Can we
redirect to a file in /var/logs so it *does* end up in the logs?

Does anyone know how this is supposed to work?

--Kurt

Jimmi Dyson

unread,
Oct 13, 2016, 4:08:49 PM10/13/16
to Kurt T Stam, fab...@googlegroups.com
Supposedly output of failed lifecycle hooks should be surfaced as events on the pod. Can you see any output on the pod you're describing?

I'd encourage all scripts to be run with the recommended  bash options in http://redsymbol.net/articles/unofficial-bash-strict-mode/ - really helps with finding errors early in scripts. tl;dr:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kurt T Stam

unread,
Oct 13, 2016, 4:22:08 PM10/13/16
to Jimmi Dyson, fab...@googlegroups.com
Thanks Jimmy, and 'events' show up where? --K

Kurt T Stam

unread,
Oct 13, 2016, 4:28:25 PM10/13/16
to Jimmi Dyson, fab...@googlegroups.com
ahh 'kubectl get events' - very nifty. Will try that out :) --K

Jimmi Dyson

unread,
Oct 13, 2016, 4:32:18 PM10/13/16
to Kurt T Stam, fab...@googlegroups.com
yeah either that or in describe pod you should see a list of events for the specific pod.

Kurt T Stam

unread,
Oct 13, 2016, 7:32:00 PM10/13/16
to Jimmi Dyson, fab...@googlegroups.com
No events are fired by the postStart script :(. I'm proposing to wrap our postStart.sh scripts and call it from the wrapper.sh:

#!/usr/bin/env bash

./postStart.sh &>  /proc/1/fd/1

This way postStart.sh script output gets logged.

-Kurt

p.s. redirecting to /dev/console did not work for me.

Jimmi Dyson

unread,
Oct 14, 2016, 2:02:15 AM10/14/16
to Kurt T Stam, fab...@googlegroups.com

Are you running openshift or kubernetes? What version?

If the defined behaviour is not working (events on failed lifecycle hooks) then please can you report that as a bug & help with resolution if possible.

Reply all
Reply to author
Forward
0 new messages