From e6140dfbc0c980786c662cd9e58b5cb71b9f2db0 Mon Sep 17 00:00:00 2001 From: Michael Johann Date: Thu, 1 Jun 2017 12:10:50 +0200 Subject: [PATCH 1/4] Fix for 403 error in watch_routes --- libexec/watcher | 13 ++++++++++--- share/common.sh | 3 +++ template.yaml | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libexec/watcher b/libexec/watcher index bc5c4b9..bdbb723 100755 --- a/libexec/watcher +++ b/libexec/watcher @@ -7,12 +7,19 @@ set -euo pipefail process_routes() { local domainname selfLink local tmpl='.object.spec.host + ":" + .object.metadata.selfLink' + log "watching routes with selector $LETSENCRYPT_ROUTE_SELECTOR" + log "$(watch_routes)" + watch_routes | jq -er --unbuffered "$tmpl" \ | while IFS=: read -r domainname selfLink; do - log "Processing route $selfLink with domain $domainname." - get_certificate "$domainname" "$selfLink" - done + if [ -n domainname ] && [ -n selfLink ]; then + log "Processing route $selfLink with domain $domainname." + get_certificate "$domainname" "$selfLink" + else + log watch_routes + fi + done } while true diff --git a/share/common.sh b/share/common.sh index 7d05465..81bbf8e 100644 --- a/share/common.sh +++ b/share/common.sh @@ -54,6 +54,7 @@ is_true() { ;; esac } + api_call() { local uri="${1##/}"; shift curl --fail -sSH "Authorization: Bearer $SA_TOKEN" \ @@ -71,9 +72,11 @@ api_call() { watch_routes() { local routes_uri routes_uri="$(route_uri)?watch" + if [ -n "$LETSENCRYPT_ROUTE_SELECTOR" ]; then routes_uri="$routes_uri&labelSelector=$LETSENCRYPT_ROUTE_SELECTOR" fi + api_call "$routes_uri" -N } diff --git a/template.yaml b/template.yaml index 64fe16c..d503eae 100644 --- a/template.yaml +++ b/template.yaml @@ -30,7 +30,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest imagePullPolicy: Always name: watcher volumeMounts: @@ -45,7 +45,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest name: cron terminationMessagePath: /dev/termination-log volumeMounts: From 37c7792f4c07ae79d14383eeeaef3d2dbeb1baa7 Mon Sep 17 00:00:00 2001 From: Michael Johann Date: Thu, 1 Jun 2017 12:18:23 +0200 Subject: [PATCH 2/4] Removed redundant logging --- libexec/watcher | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libexec/watcher b/libexec/watcher index bdbb723..7ab32ce 100755 --- a/libexec/watcher +++ b/libexec/watcher @@ -9,7 +9,6 @@ process_routes() { local tmpl='.object.spec.host + ":" + .object.metadata.selfLink' log "watching routes with selector $LETSENCRYPT_ROUTE_SELECTOR" - log "$(watch_routes)" watch_routes | jq -er --unbuffered "$tmpl" \ | while IFS=: read -r domainname selfLink; do @@ -17,7 +16,7 @@ process_routes() { log "Processing route $selfLink with domain $domainname." get_certificate "$domainname" "$selfLink" else - log watch_routes + log "$(watch_routes)" fi done } From 7f2621162cb5f0e41e8f6b0061eac2b7066565f9 Mon Sep 17 00:00:00 2001 From: Michael Johann Date: Thu, 1 Jun 2017 12:20:06 +0200 Subject: [PATCH 3/4] Reverted crossb0w docker namespace to ibotty --- template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index d503eae..64fe16c 100644 --- a/template.yaml +++ b/template.yaml @@ -30,7 +30,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: crossb0w/openshift-letsencrypt:latest + image: ibotty/openshift-letsencrypt:latest imagePullPolicy: Always name: watcher volumeMounts: @@ -45,7 +45,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: crossb0w/openshift-letsencrypt:latest + image: ibotty/openshift-letsencrypt:latest name: cron terminationMessagePath: /dev/termination-log volumeMounts: From 484eeef1850edfe2a37ad962063115dd0b0af7ee Mon Sep 17 00:00:00 2001 From: Michael Johann Date: Thu, 1 Jun 2017 12:22:07 +0200 Subject: [PATCH 4/4] Changed back to namespace crossb0w --- template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index 64fe16c..d503eae 100644 --- a/template.yaml +++ b/template.yaml @@ -30,7 +30,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest imagePullPolicy: Always name: watcher volumeMounts: @@ -45,7 +45,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest name: cron terminationMessagePath: /dev/termination-log volumeMounts: