Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit fba142b

Browse files
sgolightlymumoshu
sgolightly
authored andcommitted
Capture failures in decrypting assets (#1569)
"set -e" will capture when a line of code fails. However, for a pipeline such as "false | true", it will only handle the exit code of the last command. In this case, the exit code will always be 0. "set -o pipefail" will ensure that any failure in the pipeline results in the whole line failing, which will then be handled correctly by "set -e" For example: $ set +o pipefail ; false | true ; echo $? 0 $ set -o pipefail ; false | true ; echo $? 1
1 parent f054f87 commit fba142b

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

core/controlplane/config/templates/cloud-config-controller

+1
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,7 @@ write_files:
26572657
-ec \
26582658
'echo decrypting assets
26592659
shopt -s nullglob
2660+
set -o pipefail
26602661
for encKey in /etc/kubernetes/{ssl,additional-configs,{{ if or (.AssetsConfig.HasAuthTokens) ( and .Experimental.TLSBootstrap.Enabled .AssetsConfig.HasTLSBootstrapToken) }}auth{{end}}}/{,kiam/}*.enc; do
26612662
if [ ! -f $encKey ]; then
26622663
echo skipping non-existent file: $encKey 1>&2

core/etcd/config/templates/cloud-config-etcd

+1
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ coreos:
485485
-ec \
486486
'echo decrypting tls assets; \
487487
shopt -s nullglob; \
488+
set -o pipefail; \
488489
for encKey in /etc/ssl/certs/*.pem.enc; do \
489490
echo decrypting $encKey; \
490491
/usr/bin/aws \

core/nodepool/config/templates/cloud-config-worker

+1
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ write_files:
10641064
-ec \
10651065
'echo decrypting assets
10661066
shopt -s nullglob
1067+
set -o pipefail
10671068
for encKey in /etc/kubernetes/{ssl,{{ if and .Experimental.TLSBootstrap.Enabled .AssetsConfig.HasTLSBootstrapToken }}auth{{end}}}/*.enc; do
10681069
echo decrypting $encKey
10691070
f=$(mktemp $encKey.XXXXXXXX)

0 commit comments

Comments
 (0)