10
10
# Credit:
11
11
# - This script is an expansion of https://gist.github.com/yuanying/3aa7d59dcce65470804ab43def646ab6
12
12
#
13
- # TBD:
14
- # - Image secret parameter hasn't been tested.
15
- #
16
13
17
14
IMAGE=' store/oracle/serverjre:8'
18
15
IMAGEPULLPOLICY=' IfNotPresent'
105
102
exit 1
106
103
}
107
104
108
- delete_pod_and_cm () {
109
- kubectl delete -n ${NAMESPACE} pod ${PODNAME} --ignore-not-found > /dev/null 2>&1
110
- kubectl delete -n ${NAMESPACE} cm ${PODNAME} -cm --ignore-not-found > /dev/null 2>&1
111
- }
112
-
113
105
while getopts m:t:i:c:n:f:p:l:s:d: OPT
114
106
do
115
107
case $OPT in
@@ -176,6 +168,11 @@ TEMPFILE="${TMPDIR}/$(basename $0).${NAMESPACE}.${PODNAME}.tmp.$$"
176
168
177
169
# cleanup anything from previous run
178
170
171
+ delete_pod_and_cm () {
172
+ kubectl delete -n ${NAMESPACE} pod ${PODNAME} --ignore-not-found > /dev/null 2>&1
173
+ kubectl delete -n ${NAMESPACE} cm ${PODNAME} -cm --ignore-not-found > /dev/null 2>&1
174
+ }
175
+
179
176
delete_pod_and_cm
180
177
181
178
# create cm that contains any files the user specified on the command line:
199
196
\" containers\" :[
200
197
{
201
198
\" command\" : [\" bash\" ],
202
- \" args\" : [\" -c\" ,\" ${COMMAND} ; echo -n {EXITCODE=\$ ?}\" ],
199
+ \" args\" : [\" -c\" ,\" ${COMMAND} ; echo -n {{ EXITCODE=\$ ?=EXITCODE}} ; echo -n {{ID= \` id \` =ID}} ; echo -n {{PWD= \` pwd \` =PWD} }\" ],
203
200
\" stdin\" : true,
204
201
\" tty\" : true,
205
202
\" name\" : \" ${PODNAME} \" ,
237
234
sleep 0.1
238
235
done
239
236
240
- # If background task's out file doesn't contain '{EXITCODE=0}',
237
+ # If background task's out file doesn't contain '{{ EXITCODE=0=EXITCODE} }',
241
238
# then it didn't finish or it failed...
242
239
243
240
if [ $EXITCODE -eq 0 ]; then
244
- if [ ! " ` grep -c ' {EXITCODE=0}' $TEMPFILE ` " -eq 1 ]; then
241
+ if [ ! " ` grep -c ' {{ EXITCODE=0=EXITCODE} }' $TEMPFILE ` " -eq 1 ]; then
245
242
EXITCODE=99
246
243
fi
247
244
fi
@@ -254,7 +251,18 @@ delete_pod_and_cm
254
251
255
252
# Show output from pod (or from failing 'kubectl create cm' command above)
256
253
257
- cat $TEMPFILE | sed ' s/{EXITCODE=0}//' \
254
+ if [ $EXITCODE -eq 0 ]; then
255
+ IDFILTER=" {{ID=.*=ID}}"
256
+ PWDFILTER=" {{PWD=.*=PWD}}"
257
+ else
258
+ # Don't filter out ID and PWD - leave it in for debugging purposes...
259
+ IDFILTER=" {{DNE=DNE}}"
260
+ PWDFILTER=" {{DNE=DNE}}"
261
+ fi
262
+
263
+ cat $TEMPFILE | sed " s/{{EXITCODE=0=EXITCODE}}//" \
264
+ | sed " s/$IDFILTER //" \
265
+ | sed " s/$PWDFILTER //" \
258
266
| grep -v " Unable to use a TTY - input is not a terminal or the right kind of file" \
259
267
| grep -v " If you don't see a command prompt, try pressing enter." \
260
268
| grep -v " Error attaching, falling back to logs:"
0 commit comments