release-monitoring: wait till the db head is newest
Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
parent
0741be6d2a
commit
010377f72e
4 changed files with 35 additions and 22 deletions
|
@ -115,13 +115,13 @@ items:
|
|||
recreateParams:
|
||||
timeoutSeconds: 600
|
||||
mid:
|
||||
failurePolicy: Abort
|
||||
failurePolicy: Retry
|
||||
execNewPod:
|
||||
containerName: release-monitoring-web
|
||||
command:
|
||||
- /bin/bash
|
||||
args:
|
||||
- /etc/anitya/wait_for_web_service.sh
|
||||
command: [ python3, "/etc/anitya/check_db.py" ]
|
||||
env:
|
||||
- name: ANITYA_WEB_CONFIG
|
||||
value: /etc/anitya/anitya.toml
|
||||
volumes:
|
||||
- config-volume
|
||||
resources: {}
|
||||
|
@ -203,13 +203,13 @@ items:
|
|||
recreateParams:
|
||||
timeoutSeconds: 600
|
||||
mid:
|
||||
failurePolicy: Abort
|
||||
failurePolicy: Retry
|
||||
execNewPod:
|
||||
containerName: release-monitoring-web
|
||||
command:
|
||||
- /bin/bash
|
||||
args:
|
||||
- /etc/anitya/wait_for_web_service.sh
|
||||
command: [ python3, "/etc/anitya/check_db.py" ]
|
||||
env:
|
||||
- name: ANITYA_WEB_CONFIG
|
||||
value: /etc/anitya/anitya.toml
|
||||
volumes:
|
||||
- config-volume
|
||||
resources: {}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/python3
|
||||
|
||||
from alembic import config, script
|
||||
from alembic.runtime import migration
|
||||
from sqlalchemy import engine
|
||||
|
||||
from anitya.config import config
|
||||
|
||||
|
||||
def check_current_head(alembic_cfg, connectable):
|
||||
# type: (config.Config, engine.Engine) -> bool
|
||||
directory = script.ScriptDirectory.from_config(alembic_cfg)
|
||||
with connectable.begin() as connection:
|
||||
context = migration.MigrationContext.configure(connection)
|
||||
return set(context.get_current_heads()) == set(directory.get_heads())
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Main
|
||||
engine = create_engine(config["DB_URL"], echo=config.get("SQL_DEBUG", False))
|
||||
cfg = config.Config("/etc/anitya/alembic.ini")
|
||||
if(not check_current_head(cfg, e)):
|
||||
print("ERROR: Current database head is not newest")
|
||||
exit(1)
|
|
@ -21,8 +21,8 @@ items:
|
|||
{{ load_file('httpd.conf') | indent(6) }}
|
||||
anitya.wsgi: |-
|
||||
{{ load_file('anitya.wsgi') | indent(6) }}
|
||||
wait_for_web_service: |-
|
||||
{{ load_file('wait_for_web_service.sh') | indent(6) }}
|
||||
check_db.py: |-
|
||||
{{ load_file('check_db.py') | indent(6) }}
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
{% if env == 'staging' %}
|
||||
until $(curl --output /dev/null --silent --head --fail https://stg.release-monitoring.org); do
|
||||
{% else %}
|
||||
until $(curl --output /dev/null --silent --head --fail https://release-monitoring.org); do
|
||||
{% endif %}
|
||||
sleep 5
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue