Skip to content

Commit 73baafc

Browse files
author
Tom Barnes
committed
introspect test update - use a kubectl run helper instead of a job
1 parent e6cf704 commit 73baafc

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/integration-tests/introspector/util_krun.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,40 @@ VCOMMA=''
3030
CMFILES=''
3131
VOLUMECOUNT=0
3232

33+
TMPDIR='/tmp'
34+
3335
EXITCODE=0
3436

3537
usage_exit() {
3638
cat << EOF
3739
38-
Usage: $(basename $0) [-i image] [-n namespace] [-c command]
39-
[-m pvc-name:mount-path]
40-
[-f local-file-name]
41-
[-t timeout]
40+
Usage: $(basename $0) ...options...
4241
43-
Run a 'one-off' command on a kubernetes cluster via a temporary pod,
44-
optionally specify pvc mounts and additional files to load.
42+
Runs a 'one-off' command on a kubernetes cluster via a temporary pod.
43+
Provides options to specify pvc mounts, hostpath mounts, or additional
44+
files to load.
4545
4646
Parameters:
4747
4848
-i imagename - Image, default is "$IMAGE".
4949
-l imagepullpolicy - Image pull policy, default is "$IMAGEPULLPOLICY".
5050
-s imagesecret - Image pull secret. No default.
51+
5152
-n namespace - Namespace, default is "$NAMESPACE".
5253
-p podname - Pod name, default is "$PODNAME".
54+
5355
-c command - Command, default is "$COMMAND".
54-
-t timeout - Timeout in seconds, default is $MAXSECS seconds.
56+
5557
-m pvc-name:mount-path - PVC name and mount location. No default.
5658
-m host-path:mount-path- Remote host-path and mount location. No default.
5759
Host-path must begin with a '/'.
5860
-f /path/filename - Copies local file to pod at /tmpmount/filename
5961
62+
-t timeout - Timeout in seconds, default is $MAXSECS seconds.
63+
64+
-d tmpdir - Location to put tmp file(s). Default is "$TMPDIR".
65+
Use this if your command's output might be large.
66+
6067
You can specify -f, -m, and -s more than once.
6168
6269
Limitation:
@@ -103,7 +110,7 @@ delete_pod_and_cm() {
103110
kubectl delete -n ${NAMESPACE} cm ${PODNAME}-cm --ignore-not-found > /dev/null 2>&1
104111
}
105112

106-
while getopts m:t:i:c:n:f:p:l:s: OPT
113+
while getopts m:t:i:c:n:f:p:l:s:d: OPT
107114
do
108115
case $OPT in
109116
i) IMAGE=$OPTARG
@@ -121,6 +128,8 @@ do
121128
;;
122129
t) MAXSECS=$OPTARG
123130
;;
131+
d) TMPDIR=$OPTARG
132+
;;
124133
f) # local file to make available in /tmpmount
125134
if [ "$CMFILES" = "" ]; then
126135
VOL_MOUNTS="${VOL_MOUNTS}${VCOMMA}{\"name\": \"my-config-map-vol\",\"mountPath\": \"/tmpmount\"}"
@@ -161,7 +170,9 @@ shift $(($OPTIND - 1))
161170

162171
# setup a tmp file /tmp/[script-file-name].[name-space].[pod-name].tmp.[pid]
163172

164-
TEMPFILE="/tmp/$(basename $0).${NAMESPACE}.${PODNAME}.tmp.$$"
173+
[ ! -d "$TMPDIR" ] && echo "Error: temp dir \"$TMPDIR\" not found. Check parameters." && exit 1
174+
175+
TEMPFILE="${TMPDIR}/$(basename $0).${NAMESPACE}.${PODNAME}.tmp.$$"
165176

166177
# cleanup anything from previous run
167178

@@ -253,3 +264,5 @@ cat $TEMPFILE | sed 's/{EXITCODE=0}//' \
253264
rm -f $TEMPFILE
254265

255266
exit $EXITCODE
267+
268+

0 commit comments

Comments
 (0)