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

fix: v2 deployment fixes #143

Merged
merged 8 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/cloudbuild.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/rc-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: rc-release-version
on:
push:
branches:
- release-v*.*.*-rc*
jobs:
release-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Verify version is a release candidate"
run: |
cat "setup.py" | grep "version = .*-rc*"
- uses: actions/setup-python@master
with:
python-version: '3.x'
architecture: 'x64'

- name: Run all tests
run: make
env:
MIN_VALID_EVENTS: "10"
GOOGLE_APPLICATION_CREDENTIALS: tests/unit/fixtures/fake_credentials.json

- name: Release PyPI package
run: make deploy
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
release-gcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: Build Docker container and publish on GCR
run: make cloudbuild
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
21 changes: 18 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
tags:
- v*.*.*
jobs:
release-version:
release-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
- uses: actions/checkout@v2
- uses: actions/setup-python@master
with:
python-version: '3.x'
architecture: 'x64'
Expand All @@ -25,3 +25,18 @@ jobs:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
release-gcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: Build Docker container and publish on GCR
run: make cloudbuild
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ cloudrun:
--args=api \
--args=--signature-type="${SIGNATURE_TYPE}" \
--min-instances 1 \
--allow-unauthenticated
--allow-unauthenticated \
--project=${CLOUDRUN_PROJECT_ID}
3 changes: 1 addition & 2 deletions slo_generator/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ def run_compute(request):
# Get SLO config
if API_SIGNATURE_TYPE == 'http':
timestamp = None
data = str(request.get_json())
data = str(request.data.decode('utf-8'))
LOGGER.info('Loading SLO config from Flask request')
elif API_SIGNATURE_TYPE == 'cloudevent':
timestamp = int(
datetime.strptime(request["time"], TIME_FORMAT).timestamp())
data = base64.b64decode(request.data).decode('utf-8')
LOGGER.info(f'Loading SLO config from Cloud Event "{request["id"]}"')

slo_config = load_config(data)

# Get slo-generator config
Expand Down