From bedf554898d38059094d772b09460c99a285db9c Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 17 Oct 2016 16:41:01 -0400 Subject: [PATCH 1/4] Good socat failure --- tests/haproxy.bats | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/haproxy.bats diff --git a/tests/haproxy.bats b/tests/haproxy.bats new file mode 100644 index 0000000..1ad8ab0 --- /dev/null +++ b/tests/haproxy.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ../common + +# These tests assume the pipeline will start and stop the container. + +@test "socat process exists" { + docker run -i haproxy which socat +} \ No newline at end of file From 8f483705ee4dbf92d7c61600159014f86b415e97 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 17 Oct 2016 17:05:56 -0400 Subject: [PATCH 2/4] socat available in haproxy cfg --- haproxy/Dockerfile | 2 ++ tests/haproxy.bats | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/haproxy/Dockerfile b/haproxy/Dockerfile index ab58561..e33097a 100644 --- a/haproxy/Dockerfile +++ b/haproxy/Dockerfile @@ -10,4 +10,6 @@ LABEL ImageType="haproxy" LABEL ImageName=$imagename LABEL ImageOS=centos7 LABEL Version=$version + +RUN apt-get update && apt-get install -y socat copy conf/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg diff --git a/tests/haproxy.bats b/tests/haproxy.bats index 1ad8ab0..5374922 100644 --- a/tests/haproxy.bats +++ b/tests/haproxy.bats @@ -5,5 +5,5 @@ load ../common # These tests assume the pipeline will start and stop the container. @test "socat process exists" { - docker run -i haproxy which socat + docker exec -i haproxy which socat } \ No newline at end of file From a0019cc2bc26d8272f7be8a0d0b947fba2e34dab Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Tue, 18 Oct 2016 16:26:06 -0400 Subject: [PATCH 3/4] Adding socat to the haproxy container --- haproxy/Dockerfile | 1 + haproxy/conf/haproxy.cfg | 1 + haproxy/container_files/bin/haproxycfg.sh | 2 ++ tests/haproxy.bats | 7 ++++++- 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 haproxy/container_files/bin/haproxycfg.sh diff --git a/haproxy/Dockerfile b/haproxy/Dockerfile index e33097a..b983a39 100644 --- a/haproxy/Dockerfile +++ b/haproxy/Dockerfile @@ -12,4 +12,5 @@ LABEL ImageOS=centos7 LABEL Version=$version RUN apt-get update && apt-get install -y socat +COPY container_files/ /opt copy conf/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg diff --git a/haproxy/conf/haproxy.cfg b/haproxy/conf/haproxy.cfg index bcb15b5..8e9bb29 100644 --- a/haproxy/conf/haproxy.cfg +++ b/haproxy/conf/haproxy.cfg @@ -2,6 +2,7 @@ global log 127.0.0.1 local0 log 127.0.0.1 local1 notice + stats socket /usr/local/etc/haproxysock level admin defaults log global diff --git a/haproxy/container_files/bin/haproxycfg.sh b/haproxy/container_files/bin/haproxycfg.sh new file mode 100755 index 0000000..efb7ce6 --- /dev/null +++ b/haproxy/container_files/bin/haproxycfg.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "$@" | socat unix-connect:/usr/local/etc/haproxysock stdio \ No newline at end of file diff --git a/tests/haproxy.bats b/tests/haproxy.bats index 5374922..44b8a6b 100644 --- a/tests/haproxy.bats +++ b/tests/haproxy.bats @@ -6,4 +6,9 @@ load ../common @test "socat process exists" { docker exec -i haproxy which socat -} \ No newline at end of file +} + +@test "socat helper process exists" { + docker exec -i haproxy /opt/bin/haproxycfg.sh show stat +} + From 494d9c5b6b8d033e526cbd0534a5a8d9e16faeb3 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Tue, 18 Oct 2016 16:31:17 -0400 Subject: [PATCH 4/4] Better cleanup --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b2f78c6..d0421b9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,7 +50,6 @@ node('docker') { dir('haproxy'){ sh 'docker build --rm -t my/haproxy . > debug' sh 'rm debug' - sh 'docker rm haproxy' } } catch(error) { def error_details = readFile('haproxy/debug'); @@ -124,6 +123,8 @@ def handleError(String message, String tag, Boolean doCleanup = true){ def cleanup(String tag) { try{ sh 'bin/decompose.sh &> debug' + sh 'docker rm haproxy' + sh 'docker rmi my/haproxy' sh 'bin/prune.sh &> debug' } catch(error) { def error_details = readFile('./debug');