Skip to content

Commit

Permalink
Merge pull request #27 from FalkorDB/25-create-separate-service-plan-…
Browse files Browse the repository at this point in the history
…per-pr

25 create separate service plan per pr
  • Loading branch information
dudizimber authored Jun 2, 2024
2 parents 1734804 + bbbca5e commit 115a3d8
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 116 deletions.
51 changes: 51 additions & 0 deletions .github/actions/delete-omnistrate-service-plan/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Delete Omnistrate Service Plan
description: "Delete an Omnistrate service plan"

inputs:
username:
description: "The username to use for authentication"
required: true
password:
description: "The password to use for authentication"
required: true
service-id:
description: "The ID of the service"
required: true
environment-id:
description: "The ID of the environment"
required: true
product-tier-name:
description: "The name of the product tier to delete"
required: true

runs:
using: composite
steps:
- name: Login
shell: bash
run: |
curl "https://api.omnistrate.cloud/2022-09-01-00/signin" \
-X POST \
-H "Content-Type: application/json" \
-d "{\"email\":\"${{ inputs.username }}\",\"password\":\"${{ inputs.password }}\"}" \
-o token.json
echo "OMNISTRATE_TOKEN=$(jq -r .jwtToken token.json)" >> $GITHUB_ENV
- name: Find product tier ID
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y jq
curl "https://api.omnistrate.cloud/2022-09-01-00/service/${{ inputs.service-id }}/environment/${{ inputs.environment-id }}/service-plan" \
-X GET \
-H "Authorization: Bearer $OMNISTRATE_TOKEN" \
-o service-plans.json
jq -r ".servicePlans[] | select(.productTierName == \"${{ inputs.product-tier-name }}\") | .id" service-plans.json > product-tier-id.txt
echo "PRODUCT_TIER_ID=$(cat product-tier-id.txt)" >> $GITHUB_ENV
- name: Delete product tier
shell: bash
run: |
curl "https://api.omnistrate.cloud/2022-09-01-00/service/${{ inputs.service-id }}/product-tier/${{ env.PRODUCT_TIER_ID }}" \
-X DELETE \
-H "Authorization: Bearer $OMNISTRATE_TOKEN"
57 changes: 7 additions & 50 deletions .github/workflows/build-release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ jobs:
if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }}
uses: actions/checkout@v3

- name: Replace Variables
run: |
sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' omnistrate.${{ matrix.plans.key}}.yaml
sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' omnistrate.${{ matrix.plans.key}}.yaml
sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' omnistrate.${{ matrix.plans.key}}.yaml
sed -i 's/$FalkorDBNodeImage/falkordb\/falkordb-node:${{ github.ref_name }}/g' omnistrate.${{ matrix.plans.key}}.yaml
- name: Update Omnistrate plan
if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }}
uses: ./.github/actions/update-omnistrate-plan
Expand All @@ -75,53 +82,3 @@ jobs:
password: ${{ secrets.OMNISTRATE_PASSWORD }}
file: ${{ matrix.plans.file }}
plan-name: ${{ matrix.plans.name }}

omnistrate-update-image:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
needs: omnistrate-update-plans
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
tiers:
# - name: single zone - node
# serviceId: s-xlHhDG3QlM
# serviceApiId: sa-uvMK5yOcSo
# productTierId: pt-Yemkrnavca
# imageConfigId: imgc-y2q3nWbnvt
# - name: single zone - sentinel
# serviceId: s-xlHhDG3QlM
# serviceApiId: sa-uvMK5yOcSo
# productTierId: pt-Yemkrnavca
# imageConfigId: imgc-2W3145VEcL
# - name: multi zone - node
# serviceId: s-xlHhDG3QlM
# serviceApiId: sa-uvMK5yOcSo
# productTierId: pt-Yemkrnavca
# imageConfigId: imgc-PRfAITshta
# - name: multi zone - sentinel
# serviceId: s-xlHhDG3QlM
# serviceApiId: sa-uvMK5yOcSo
# productTierId: pt-Yemkrnavca
# imageConfigId: imgc-C4HEeC6OZb
# - name: standalone - node
# serviceId: s-xlHhDG3QlM
# serviceApiId: sa-uvMK5yOcSo
# productTierId: pt-Yemkrnavca
# imageConfigId: imgc-ZcQDSLurfz
- name: free - node
serviceId: s-KgFDwg5vBS
serviceApiId: sa-dCmMhdrtu3
productTierId: pt-m2FKdsSXSi
imageConfigId: imgc-wAKebKdNdM
steps:
- name: Update Docker Image Tag on Omnistrate
uses: omnistrate/update-image-config@v1
with:
username: ${{ secrets.OMNISTRATE_USERNAME }}
password: ${{ secrets.OMNISTRATE_PASSWORD }}
service-id: ${{ matrix.tiers.serviceId }}
service-api-id: ${{ matrix.tiers.serviceApiId }}
product-tier-id: ${{ matrix.tiers.productTierId }}
image-config-id: ${{ matrix.tiers.imageConfigId }}
tag: ${{ github.ref_name }}
65 changes: 11 additions & 54 deletions .github/workflows/build-test-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

concurrency:
group: falkordb-node-tests
group: falkordb-node-branch-${{ github.ref_name }}
cancel-in-progress: false

env:
Expand Down Expand Up @@ -53,78 +53,35 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Replace GCP Variables
- name: Replace Variables
run: |
sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' omnistrate.free.yaml
sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' omnistrate.free.yaml
sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' omnistrate.free.yaml
sed -i 's/$FalkorDBNodeImage/falkordb\/falkordb-node:dev-${{ github.event.head_commit.id }}/g' omnistrate.free.yaml
sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' omnistrate.pro.yaml
sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' omnistrate.pro.yaml
sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' omnistrate.pro.yaml
sed -i 's/$FalkorDBNodeImage/falkordb\/falkordb-node:dev-${{ github.event.head_commit.id }}/g' omnistrate.pro.yaml
- name: Merge omnistrate composes
run: sudo add-apt-repository ppa:rmescandon/yq && sudo apt update && sudo apt install yq -y && yq ea '. as $item ireduce ({}; . * $item )' omnistrate.pro.yaml omnistrate.free.yaml | sed 's/FalkorDB Free/FalkorDB Internal/' > merged.yaml
run: |
sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y
yq ea '. as $item ireduce ({}; . * $item )' omnistrate.pro.yaml omnistrate.free.yaml | sed 's/FalkorDB Free/${{ github.ref_name }}/' > merged.yaml
- name: Update Omnistrate plan
uses: ./.github/actions/update-omnistrate-plan
id: update_omnistrate_plan
with:
username: ${{ secrets.OMNISTRATE_USERNAME }}
password: ${{ secrets.OMNISTRATE_PASSWORD }}
file: merged.yaml
service-name: "FalkorDB Internal"

omnistrate-update-image:
needs: omnistrate-update-plans
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
tiers:
- name: node-sz
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-kIAclNV7Pt
- name: sentinel-sz
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-jChPv7D4wM
- name: node-mz
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-A5OTVYi7D8
- name: sentinel-mz
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-x0nEVUZbIm
- name: node-s
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-wSJ2umk0E7
- name: node-f
serviceId: s-iBKzmR5obS
serviceApiId: sa-FF7Ckx3VC3
productTierId: pt-vnVxCsPEcV
imageConfigId: imgc-FhmFmFh9XF
steps:
- name: Update Docker Image Tag on Omnistrate
id: update-image-config
uses: omnistrate/update-image-config@v1
with:
username: ${{ secrets.OMNISTRATE_USERNAME }}
password: ${{ secrets.OMNISTRATE_PASSWORD }}
service-id: ${{ matrix.tiers.serviceId }}
service-api-id: ${{ matrix.tiers.serviceApiId }}
product-tier-id: ${{ matrix.tiers.productTierId }}
image-config-id: ${{ matrix.tiers.imageConfigId }}
tag: dev-${{ github.event.head_commit.id }}

promote-pt-version:
needs: omnistrate-update-image
needs: omnistrate-update-plans
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/delete-omnistrate-service-plan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Delete Omnistrate Service Plan

on:
workflow_dispatch:
pull_request:
types: [closed]
delete:

jobs:
delete-service-plan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Delete Service Plan
uses: ./.github/actions/delete-omnistrate-service-plan
continue-on-error: true
with:
username: ${{ secrets.OMNISTRATE_USERNAME }}
password: ${{ secrets.OMNISTRATE_PASSWORD }}
service-id: ${{ vars.OMNISTRATE_INTERNAL_SERVICE_ID }}
environment-id: ${{ vars.OMNISTRATE_INTERNAL_DEV_ENVIRONMENT }}
product-tier-name: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion omnistrate.free.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ services:

node-f:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCount: 1
instanceTypes:
Expand Down
10 changes: 5 additions & 5 deletions omnistrate.pro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ services:

node-s:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCount: 1
instanceTypes:
Expand Down Expand Up @@ -441,7 +441,7 @@ services:

node-sz:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCountAPIParam: numReplicas
instanceTypes:
Expand Down Expand Up @@ -613,7 +613,7 @@ services:

sentinel-sz:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCount: 1
instanceTypes:
Expand Down Expand Up @@ -807,7 +807,7 @@ services:

node-mz:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCountAPIParam: numReplicas
instanceTypes:
Expand Down Expand Up @@ -979,7 +979,7 @@ services:

sentinel-mz:
x-omnistrate-mode-internal: true
image: falkordb/falkordb-node:v0.0.45
image: $FalkorDBNodeImage
x-omnistrate-compute:
replicaCount: 1
instanceTypes:
Expand Down
12 changes: 6 additions & 6 deletions tests/classes/omnistrate_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _get_token(self):
}
print("Getting token")
response = requests.post(
self.api_url + self.api_sign_in_path, headers=headers, timeout=5
self.api_url + self.api_sign_in_path, headers=headers, timeout=15
)

self._handle_response(response, "Failed to get token")
Expand Down Expand Up @@ -121,7 +121,7 @@ def create(
self.api_url + self.api_path + self.subscription_id_query,
headers=headers,
data=json.dumps(data),
timeout=5,
timeout=15,
)

self._handle_response(response, f"Failed to create instance {name}")
Expand Down Expand Up @@ -153,7 +153,7 @@ def delete(self, wait_for_delete: bool):
+ self.instance_id
+ self.subscription_id_query,
headers=headers,
timeout=5,
timeout=15,
)

self._handle_response(response, f"Failed to delete instance {self.instance_id}")
Expand Down Expand Up @@ -197,7 +197,7 @@ def trigger_failover(
url,
headers=headers,
data=json.dumps(data),
timeout=5,
timeout=15,
)

self._handle_response(
Expand Down Expand Up @@ -226,7 +226,7 @@ def _get_network_topology(self):
+ self.instance_id
+ self.subscription_id_query,
headers=headers,
timeout=5,
timeout=15,
)

self._handle_response(
Expand Down Expand Up @@ -309,7 +309,7 @@ def _get_instance_state(self):
+ self.instance_id
+ self.subscription_id_query,
headers=headers,
timeout=5,
timeout=15,
)

self._handle_response(
Expand Down

0 comments on commit 115a3d8

Please sign in to comment.