Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve availability check after deployment #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

5v3nn
Copy link

@5v3nn 5v3nn commented Apr 9, 2024

Problem:

  • If server is up, but not available, the curl command will still pass without error, and will only output that the service is unavailable
  • Thus the pipeline passes, which should not be (because server is unavailable)

Changes:

  • We want to check the curl answer
  • If the answer is that the server is unavailable, then the pipeline should fail. This is achieved with an exit 1 statement
  • If the answer is that the server is available, then the pipeline should pass. (Just outputs that the server is up and running).

Output on available response:

Run response=$(curl "***")
sponse=$(curl "***")
  echo $response
  if [[ "$response" == *"Service Unavailable"* ]]; then exit 1; else echo "App is up and running"; fi
  shell: /usr/bin/bash -e ***0***
  env:
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-deploy-appengine
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0
100    27  100    27    0     0      2      0  0:00:13  0:00:11  0:00:02     6
The application is running.
App is up and running

Output on unavailable response:

Run response=$(curl "***")
  response=$(curl "***")
  echo $response
  if [[ "$response" == *"Service Unavailable"* ]]; then exit 1; else echo "App is up and running"; fi
  shell: /usr/bin/bash -e ***0***
  env:
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-deploy-appengine
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
100    19  100    19    0     0      2      0  0:00:09  0:00:08  0:00:01     4
100    19  100    19    0     0      2      0  0:00:09  0:00:08  0:00:01     5
Service Unavailable
Error: Process completed with exit code 1.

Problem:
- If server is up, but not available, the `curl` command will still pass
  without error, and will only output that the service is unavailable
- Thus the pipeline passes, which should not be (because server is
  unavailable)

Changes:
- We want to check the curl answer
- If the answer is that the server is unavailable, then the pipeline
  should fail. This is achieved with an `exit 1` statement
- If the answer is that the server is available, then the pipeline
  should pass. (Just outputs that the server is up and running).

Output on available response:
```
Run response=$(curl "***")
sponse=$(curl "***")
  echo $response
  if [[ "$response" == *"Service Unavailable"* ]]; then exit 1; else echo "App is up and running"; fi
  shell: /usr/bin/bash -e ***0***
  env:
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-deploy-appengine
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0
100    27  100    27    0     0      2      0  0:00:13  0:00:11  0:00:02     6
The application is running.
App is up and running
```

Output on unavailable response:
```
Run response=$(curl "***")
  response=$(curl "***")
  echo $response
  if [[ "$response" == *"Service Unavailable"* ]]; then exit 1; else echo "App is up and running"; fi
  shell: /usr/bin/bash -e ***0***
  env:
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-deploy-appengine
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
100    19  100    19    0     0      2      0  0:00:09  0:00:08  0:00:01     4
100    19  100    19    0     0      2      0  0:00:09  0:00:08  0:00:01     5
Service Unavailable
Error: Process completed with exit code 1.
```
@mirovv mirovv self-assigned this Apr 9, 2024
@mirovv
Copy link
Collaborator

mirovv commented Apr 9, 2024

One student of my group found this bug in the template, where the pipeline of curl "${{ steps.deploy.outputs.url }}" passes, even though the services are not available.

I reviewed his PR and would recommend to update our template.

@isicu Please also take a look at the suggested change and feel free to merge it into the main branch.

@mirovv mirovv requested a review from isicu April 9, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants