@@ -94,38 +94,42 @@ jobs:
94
94
- name : Set up kubeconfig
95
95
run : aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}
96
96
97
+ - name : Download eksctl
98
+ uses : ./.github/workflows/actions/execute_and_retry
99
+ with :
100
+ pre-command : ' mkdir ${{ github.workspace }}/eksctl'
101
+ command : ' curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"'
102
+
97
103
- name : Install eksctl
98
104
run : |
99
- source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
100
- mkdir ${{ github.workspace }}/eksctl
101
- curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
102
- execute_and_retry 2 "tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz"
105
+ tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz
103
106
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
104
107
105
108
- name : Create role for AWS access from the sample app
106
109
id : create_service_account
107
- run : |
108
- eksctl create iamserviceaccount \
110
+ uses : ./.github/workflows/actions/execute_and_retry
111
+ with :
112
+ command : " eksctl create iamserviceaccount \
109
113
--name service-account-${{ env.TESTING_ID }} \
110
114
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
111
115
--cluster ${{ inputs.test-cluster-name }} \
112
116
--role-name eks-s3-access-${{ env.TESTING_ID }} \
113
117
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
114
118
--region ${{ inputs.aws-region }} \
115
- --approve
119
+ --approve"
116
120
117
121
- name : Set up terraform
118
- run : |
119
- source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
120
- execute_and_retry 2 "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
121
- echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
122
- sudo apt update && sudo apt install terraform
122
+ uses : ./.github/workflows/actions/execute_and_retry
123
+ with :
124
+ command : " wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
125
+ post-command : ' echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list \
126
+ sudo apt update && sudo apt install terraform'
123
127
124
128
- name : Initiate Terraform
125
- working-directory : terraform/eks
126
- run : |
127
- source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
128
- execute_and_retry 2 "terraform init && terraform validate" "rm -rf .terraform && rm -rf .terraform.lock.hcl"
129
+ uses : ./.github/workflows/actions/execute_and_retry
130
+ with :
131
+ command : " cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/eks && terraform init && terraform validate "
132
+ cleanup : " rm -rf .terraform && rm -rf .terraform.lock.hcl"
129
133
130
134
- name : Deploy sample app via terraform and wait for the endpoint to come online
131
135
id : deploy-sample-app
@@ -152,27 +156,50 @@ jobs:
152
156
-var="sample_remote_app_image=${{ env.ACCOUNT_ID }}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com/${{ secrets.APP_SIGNALS_E2E_RE_SA_IMG }}" \
153
157
|| deployment_failed=$?
154
158
155
- if [ $deployment_failed -eq 1 ]; then
159
+ if [ $deployment_failed -ne 0 ]; then
156
160
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
157
161
fi
158
162
159
163
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint
160
164
# after installing App Signals. Attempts to connect will be made for up to 10 minutes
161
165
if [ $deployment_failed -eq 0 ]; then
162
- echo "Installing app signals to the sample app"
163
- ${GITHUB_WORKSPACE}/enablement-script/scripts/eks/appsignals/enable-app-signals.sh \
166
+ source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
167
+ execute_and_retry 2 \
168
+ "${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/scripts/eks/appsignals/enable-app-signals.sh \
164
169
${{ inputs.test-cluster-name }} \
165
170
${{ inputs.aws-region }} \
166
- ${{ env.SAMPLE_APP_NAMESPACE }}
171
+ ${{ env.SAMPLE_APP_NAMESPACE }}" \
172
+ "${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/scripts/eks/appsignals/clean-app-signals.sh \
173
+ ${{ inputs.test-cluster-name }} \
174
+ ${{ inputs.aws-region }} \
175
+ ${{ env.SAMPLE_APP_NAMESPACE }} && \
176
+ aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}"
167
177
168
178
kubectl delete pods --all -n ${{ env.SAMPLE_APP_NAMESPACE }}
169
179
kubectl wait --for=condition=Ready pod --all -n ${{ env.SAMPLE_APP_NAMESPACE }}
170
180
171
- echo "Attempting to connect to the endpoint"
172
- sample_app_endpoint=http://$(terraform output sample_app_endpoint)
181
+ echo "Attempting to connect to the main sample app endpoint"
182
+ main_sample_app_endpoint=http://$(terraform output sample_app_endpoint)
183
+ attempt_counter=0
184
+ max_attempts=30
185
+ until $(curl --output /dev/null --silent --head --fail $(echo "$main_sample_app_endpoint" | tr -d '"')); do
186
+ if [ ${attempt_counter} -eq ${max_attempts} ];then
187
+ echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
188
+ deployment_failed=1
189
+ break
190
+ fi
191
+
192
+ printf '.'
193
+ attempt_counter=$(($attempt_counter+1))
194
+ sleep 10
195
+ done
196
+
197
+ echo "Attempting to connect to the remote sample app endpoint"
198
+ remote_sample_app_endpoint=http://$(terraform output sample_remote_app_endpoint)/healthcheck
199
+ echo $remote_sample_app_endpoint
173
200
attempt_counter=0
174
- max_attempts=60
175
- until $(curl --output /dev/null --silent --head --fail $(echo "$sample_app_endpoint " | tr -d '"')); do
201
+ max_attempts=30
202
+ until $(curl --output /dev/null --silent --head --fail $(echo "$remote_sample_app_endpoint " | tr -d '"')); do
176
203
if [ ${attempt_counter} -eq ${max_attempts} ];then
177
204
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
178
205
deployment_failed=1
@@ -196,7 +223,7 @@ jobs:
196
223
197
224
# Running clean-app-signal.sh removes the current cluster from the config. Update the cluster again for subsequent runs.
198
225
aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}
199
-
226
+
200
227
echo "Destroying terraform"
201
228
terraform destroy -auto-approve \
202
229
-var="test_id=${{ env.TESTING_ID }}" \
@@ -248,9 +275,10 @@ jobs:
248
275
curl -S -s http://${{ env.APP_ENDPOINT }}/client-call/
249
276
250
277
- name : Build Gradlew
251
- run : |
252
- source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
253
- execute_and_retry 2 "./gradlew"
278
+ uses : ./.github/workflows/actions/execute_and_retry
279
+ with :
280
+ max_retry : 4
281
+ command : " ./gradlew"
254
282
255
283
# Validation for app signals telemetry data
256
284
- name : Call endpoint and validate generated EMF logs
0 commit comments