@@ -37,20 +37,25 @@ save_all_pod_logs(){
37
37
38
38
droute_send () {
39
39
if [[ " ${OPENSHIFT_CI} " != " true" ]]; then return 0; fi
40
- temp_kubeconfig=$( mktemp) # Create temporary KUBECONFIG to open second `oc` session
40
+ local original_context
41
+ original_context=$( oc config current-context) # Save original context
41
42
( # Open subshell
42
43
if [ -n " ${PULL_NUMBER:- } " ]; then
43
44
set +e
44
45
fi
45
- export KUBECONFIG=" $temp_kubeconfig "
46
46
local droute_version=" 1.2.2"
47
47
local release_name=$1
48
48
local project=$2
49
49
local droute_project=" droute"
50
50
local metadata_output=" data_router_metadata_output.json"
51
51
52
- oc login --token=" ${RHDH_PR_OS_CLUSTER_TOKEN} " --server=" ${RHDH_PR_OS_CLUSTER_URL} "
52
+ oc config set-credentials temp-user --token=" ${RHDH_PR_OS_CLUSTER_TOKEN} "
53
+ oc config set-cluster temp-cluster --server=" ${RHDH_PR_OS_CLUSTER_URL} "
54
+ oc config set-context temp-context --user=temp-user --cluster=temp-cluster
55
+ oc config use-context temp-context
53
56
oc whoami --show-server
57
+ trap ' oc config use-context "$original_context"' RETURN
58
+
54
59
local droute_pod_name=$( oc get pods -n droute --no-headers -o custom-columns=" :metadata.name" | grep ubi9-cert-rsync)
55
60
local temp_droute=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c " mktemp -d" )
56
61
@@ -97,19 +102,21 @@ droute_send() {
97
102
98
103
# Send test by rsync to bastion pod.
99
104
local max_attempts=5
100
- local wait_seconds=4
105
+ local wait_seconds_step=1
101
106
for (( i = 1 ; i <= max_attempts; i++ )) ; do
102
107
echo " Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod."
103
108
if output=$( oc rsync --progress=true --include=" ${metadata_output} " --include=" ${JUNIT_RESULTS} " --exclude=" *" -n " ${droute_project} " " ${ARTIFACT_DIR} /${project} /" " ${droute_project} /${droute_pod_name} :${temp_droute} /" 2>&1 ) ; then
104
109
echo " $output "
105
110
break
106
- fi
107
- if (( i == max_attempts)) ; then
111
+ elif (( i == max_attempts)) ; then
108
112
echo " Failed to rsync test results after ${max_attempts} attempts."
109
113
echo " Last rsync error details:"
110
114
echo " ${output} "
111
115
echo " Troubleshooting steps:"
112
116
echo " 1. Restart $droute_pod_name in $droute_project project/namespace"
117
+ return 1
118
+ else
119
+ sleep $(( wait_seconds_step * i))
113
120
fi
114
121
done
115
122
@@ -120,33 +127,33 @@ droute_send() {
120
127
&& ${temp_droute} /droute-linux-amd64 version"
121
128
122
129
# Send test results through DataRouter and save the request ID.
123
- local max_attempts=5
124
- local wait_seconds =1
130
+ local max_attempts=10
131
+ local wait_seconds_step =1
125
132
for (( i = 1 ; i <= max_attempts; i++ )) ; do
126
133
echo " Attempt ${i} of ${max_attempts} to send test results through Data Router."
127
- if output=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
134
+ output=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
128
135
${temp_droute} /droute-linux-amd64 send --metadata ${temp_droute} /${metadata_output} \
129
136
--url '${DATA_ROUTER_URL} ' \
130
137
--username '${DATA_ROUTER_USERNAME} ' \
131
138
--password '${DATA_ROUTER_PASSWORD} ' \
132
139
--results '${temp_droute} /${JUNIT_RESULTS} ' \
133
- --verbose" 2>&1 ) ; then
134
- if DATA_ROUTER_REQUEST_ID=$( echo " $output " | grep " request:" | awk ' {print $2}' ) &&
135
- [ -n " $DATA_ROUTER_REQUEST_ID " ]; then
136
- echo " Test results successfully sent through Data Router."
137
- echo " Request ID: $DATA_ROUTER_REQUEST_ID "
138
- break
139
- fi
140
- fi
141
-
142
- if (( i == max_attempts)) ; then
140
+ --verbose" 2>&1 )
141
+ if DATA_ROUTER_REQUEST_ID=$( echo " $output " | grep " request:" | awk ' {print $2}' ) &&
142
+ [ -n " $DATA_ROUTER_REQUEST_ID " ]; then
143
+ echo " Test results successfully sent through Data Router."
144
+ echo " Request ID: $DATA_ROUTER_REQUEST_ID "
145
+ break
146
+ elif (( i == max_attempts)) ; then
143
147
echo " Failed to send test results after ${max_attempts} attempts."
144
148
echo " Last Data Router error details:"
145
149
echo " ${output} "
146
150
echo " Troubleshooting steps:"
147
151
echo " 1. Restart $droute_pod_name in $droute_project project/namespace"
148
152
echo " 2. Check the Data Router documentation: https://spaces.redhat.com/pages/viewpage.action?pageId=115488042"
149
153
echo " 3. Ask for help at Slack: #forum-dno-datarouter"
154
+ return 1
155
+ else
156
+ sleep $(( wait_seconds_step * i))
150
157
fi
151
158
done
152
159
@@ -180,7 +187,7 @@ droute_send() {
180
187
set -e
181
188
fi
182
189
) # Close subshell
183
- rm -f " $temp_kubeconfig " # Destroy temporary KUBECONFIG
190
+ oc config use-context " $original_context " # Restore original context
184
191
oc whoami --show-server
185
192
}
186
193
0 commit comments