2
2
3
3
set -e
4
4
5
+ max_tries=60
6
+ sleep_between_tries=10
5
7
component=hive
6
8
TEST_IMAGE=$( eval " echo $IMAGE_FORMAT " )
7
9
component=installer
@@ -15,17 +17,69 @@ curl -O -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.0
15
17
mv kustomize_2.0.0_linux_amd64 kustomize
16
18
chmod u+x kustomize
17
19
18
- oc new-project cluster-test
20
+
21
+ i=1
22
+ while [ $i -le ${max_tries} ]; do
23
+ if [ $i -gt 1 ]; then
24
+ # Don't sleep on first loop
25
+ echo " sleeping ${sleep_between_tries} seconds"
26
+ sleep ${sleep_between_tries}
27
+ fi
28
+
29
+ echo -n " Creating project cluster-test. Try #${i} /${max_tries} ... "
30
+ if oc new-project cluster-test ; then
31
+ echo " Success"
32
+ break
33
+ else
34
+ echo -n " Failed, "
35
+ fi
36
+
37
+ i=$(( i + 1 ))
38
+ done
39
+
40
+ if [ $i -ge ${max_tries} ] ; then
41
+ # Failed the maximum amount of times.
42
+ echo " exiting"
43
+ exit 10
44
+ fi
45
+
19
46
20
47
# Install Hive
21
48
make deploy DEPLOY_IMAGE=" ${TEST_IMAGE} "
22
49
23
50
CLOUD_CREDS_DIR=" /tmp/cluster"
51
+ CLUSTER_DEPLOYMENT_FILE=" /tmp/cluster-deployment.json"
52
+
53
+
54
+ i=1
55
+ while [ $i -le ${max_tries} ]; do
56
+ if [ $i -gt 1 ]; then
57
+ # Don't sleep on first loop
58
+ echo " sleeping ${sleep_between_tries} seconds"
59
+ sleep ${sleep_between_tries}
60
+ fi
61
+
62
+ echo -n " Getting cluster name. Try #${i} /${max_tries} ... "
63
+ if CLUSTER_NAME=" $( oc get clusters.machine.openshift.io -n openshift-machine-api -o jsonpath=' { .items[].metadata.name }' ) -1" ; then
64
+ echo " Success"
65
+ break
66
+ else
67
+ echo -n " Failed, "
68
+ fi
69
+
70
+ i=$(( i + 1 ))
71
+ done
72
+
73
+ if [ $i -ge ${max_tries} ] ; then
74
+ # Failed the maximum amount of times.
75
+ echo " exiting"
76
+ exit 10
77
+ fi
78
+
24
79
25
80
# Create a new cluster deployment
26
81
# TODO: Determine which domain to use to create Hive clusters
27
82
export BASE_DOMAIN=" hive-ci.openshift.com"
28
- export CLUSTER_NAME=" $( oc get cluster.cluster.k8s.io -n openshift-cluster-api -o jsonpath=' { .items[].metadata.name }' ) -1"
29
83
export SSH_PUB_KEY=" $( cat ${CLOUD_CREDS_DIR} /ssh-publickey) "
30
84
export PULL_SECRET=" $( cat ${CLOUD_CREDS_DIR} /pull-secret) "
31
85
export AWS_ACCESS_KEY_ID=" $( cat ${CLOUD_CREDS_DIR} /.awscred | awk ' /aws_access_key_id/ { print $3; exit; }' ) "
@@ -42,19 +96,68 @@ trap 'teardown' EXIT
42
96
# TODO: Determine how to wait for readiness of the validation webhook
43
97
sleep 120
44
98
45
- echo " Creating ClusterDeployment ${CLUSTER_NAME} "
46
-
47
- oc process -f config/templates/cluster-deployment.yaml \
48
- CLUSTER_NAME=" ${CLUSTER_NAME} " \
49
- SSH_KEY=" ${SSH_PUB_KEY} " \
50
- PULL_SECRET=" ${PULL_SECRET} " \
51
- AWS_ACCESS_KEY_ID=" ${AWS_ACCESS_KEY_ID} " \
52
- AWS_SECRET_ACCESS_KEY=" ${AWS_SECRET_ACCESS_KEY} " \
53
- BASE_DOMAIN=" ${BASE_DOMAIN} " \
54
- INSTALLER_IMAGE=" ${INSTALLER_IMAGE} " \
55
- OPENSHIFT_RELEASE_IMAGE=" " \
56
- TRY_INSTALL_ONCE=" true" \
57
- | oc apply -f -
99
+
100
+ i=1
101
+ while [ $i -le ${max_tries} ]; do
102
+ if [ $i -gt 1 ]; then
103
+ # Don't sleep on first loop
104
+ echo " sleeping ${sleep_between_tries} seconds"
105
+ sleep ${sleep_between_tries}
106
+ fi
107
+
108
+ echo " Generating ClusterDeployment File ${CLUSTER_NAME} . Try #${i} /${max_tries} :"
109
+ if oc process -f config/templates/cluster-deployment.yaml \
110
+ CLUSTER_NAME=" ${CLUSTER_NAME} " \
111
+ SSH_KEY=" ${SSH_PUB_KEY} " \
112
+ PULL_SECRET=" ${PULL_SECRET} " \
113
+ AWS_ACCESS_KEY_ID=" ${AWS_ACCESS_KEY_ID} " \
114
+ AWS_SECRET_ACCESS_KEY=" ${AWS_SECRET_ACCESS_KEY} " \
115
+ BASE_DOMAIN=" ${BASE_DOMAIN} " \
116
+ INSTALLER_IMAGE=" ${INSTALLER_IMAGE} " \
117
+ OPENSHIFT_RELEASE_IMAGE=" " \
118
+ TRY_INSTALL_ONCE=" true" \
119
+ > ${CLUSTER_DEPLOYMENT_FILE} ; then
120
+ echo " Success"
121
+ break
122
+ else
123
+ echo -n " Failed, "
124
+ fi
125
+
126
+ i=$(( i + 1 ))
127
+ done
128
+
129
+ if [ $i -ge ${max_tries} ] ; then
130
+ # Failed the maximum amount of times.
131
+ echo " exiting"
132
+ exit 10
133
+ fi
134
+
135
+
136
+ i=1
137
+ while [ $i -le ${max_tries} ]; do
138
+ if [ $i -gt 1 ]; then
139
+ # Don't sleep on first loop
140
+ echo " sleeping ${sleep_between_tries} seconds"
141
+ sleep ${sleep_between_tries}
142
+ fi
143
+
144
+ echo " Applying ClusterDeployment File ${CLUSTER_NAME} . Try #${i} /${max_tries} :"
145
+ if oc apply -f ${CLUSTER_DEPLOYMENT_FILE} ; then
146
+ echo " Success"
147
+ break
148
+ else
149
+ echo -n " Failed, "
150
+ fi
151
+
152
+ i=$(( i + 1 ))
153
+ done
154
+
155
+ if [ $i -ge ${max_tries} ] ; then
156
+ # Failed the maximum amount of times.
157
+ echo " exiting"
158
+ exit 10
159
+ fi
160
+
58
161
59
162
# Wait for the cluster deployment to be installed
60
163
SRC_ROOT=$( git rev-parse --show-toplevel)
0 commit comments