Patchwork [kteam-tools] git-build-kernel: add elapsed/load status as a keepalive

login
register
mail settings
Submitter Kamal Mostafa
Date Aug. 6, 2013, 10:14 p.m.
Message ID <1375827245-19621-1-git-send-email-kamal@canonical.com>
Download mbox | patch
Permalink /patch/265253/
State New
Headers show

Comments

Kamal Mostafa - Aug. 6, 2013, 10:14 p.m.
Long-running builds appear to hang, because when git-build-kernel emits no
output for a long time, TCP or ssh timeouts kick in and hang the underlying
git-ssh connection (the builds do not actually hang but the client-side
'git push' does).

To defeat such timeouts, keep the connection alive by printing an elapsed
time and load average display every 11 seconds.

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 git-build-kernel/git-build-kernel | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
Tim Gardner - Aug. 8, 2013, 12:27 p.m.
Unless you really want the status output, you could always use
'ServerAliveInterval 60' in your ssh config.

rtg
Kamal Mostafa - Aug. 8, 2013, 3:07 p.m.
On Thu, 2013-08-08 at 06:27 -0600, Tim Gardner wrote:
> Unless you really want the status output, you could always use
> 'ServerAliveInterval 60' in your ssh config.
> 
> rtg

But then every user would have to make that ssh config change on each
machine that they want to be able to push-build from.  I think its
better to just implement the keepalive in git-build-kernel itself.

It could be implemented as a silent keepalive instead (by just emitting
e.g. "\r" every couple minutes) but it now that I've implemented it, I
find the displayed elapsed build-time plus load average status to be
quite handy.

 -Kamal
Tim Gardner - Aug. 8, 2013, 4:08 p.m.
On 08/08/2013 09:07 AM, Kamal Mostafa wrote:
> 
> On Thu, 2013-08-08 at 06:27 -0600, Tim Gardner wrote:
>> Unless you really want the status output, you could always use
>> 'ServerAliveInterval 60' in your ssh config.
>>
>> rtg
> 
> But then every user would have to make that ssh config change on each
> machine that they want to be able to push-build from.  I think its
> better to just implement the keepalive in git-build-kernel itself.
> 

Anyone who has long lived ssh connection has _already_ implemented this
config option.

> It could be implemented as a silent keepalive instead (by just emitting
> e.g. "\r" every couple minutes) but it now that I've implemented it, I
> find the displayed elapsed build-time plus load average status to be
> quite handy.

Continuing to believe that the real benefit of this patch is to keep
your connection alive is just muddy thinking. If you want status, then
write a patch that gives you status. ssh config is where you control
session behaviour, not some hack to a script whose purpose is something
entirely different.

rtg

Patch

diff --git a/git-build-kernel/git-build-kernel b/git-build-kernel/git-build-kernel
index df01673..a62d00c 100755
--- a/git-build-kernel/git-build-kernel
+++ b/git-build-kernel/git-build-kernel
@@ -94,7 +94,8 @@  mkdir "$WORKDIR" || exit
 
 BUILDDIR="$WORKDIR/build"
 LOG="$WORKDIR/build.log"
-trap "rm -rf $BUILDDIR" 0
+touch "$WORKDIR/building"
+trap "rm -rf $WORKDIR/building $BUILDDIR" 0
 
 [ $do_source_pkg = 1 ] && {
     orig_tarball="linux_${VERSION%%-*}.orig.tar.gz"
@@ -116,6 +117,19 @@  echo "      version: $DISTRO ($VERSION)"
 echo "      targets: $TARGETS"
 echo "  starting build in $HOSTNAME:$WORKDIR ..."
 
+function show_elapsed
+{
+	while [ -f $WORKDIR/building ]
+	do
+	    loadavg="`uptime`"
+	    loadavg="load${loadavg##*load}"
+	    elapsed=`date --utc --date="@$SECONDS" +%H:%M:%S`
+	    echo -n -e "\r  elapsed: $elapsed   $loadavg"
+	    sleep 11
+	done
+}
+show_elapsed &
+
 (
 	set -e
 	echo "+++gbk++++ git-build-kernel"
@@ -146,6 +160,8 @@  XXEOFXX
 ) > $LOG 2>&1
 STATUS=$?
 
+rm -f "$WORKDIR/building"
+echo
 
 ### Output information about the build status and products