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:
|
recreateParams:
|
||||||
timeoutSeconds: 600
|
timeoutSeconds: 600
|
||||||
mid:
|
mid:
|
||||||
failurePolicy: Abort
|
failurePolicy: Retry
|
||||||
execNewPod:
|
execNewPod:
|
||||||
containerName: release-monitoring-web
|
containerName: release-monitoring-web
|
||||||
command:
|
command: [ python3, "/etc/anitya/check_db.py" ]
|
||||||
- /bin/bash
|
env:
|
||||||
args:
|
- name: ANITYA_WEB_CONFIG
|
||||||
- /etc/anitya/wait_for_web_service.sh
|
value: /etc/anitya/anitya.toml
|
||||||
volumes:
|
volumes:
|
||||||
- config-volume
|
- config-volume
|
||||||
resources: {}
|
resources: {}
|
||||||
|
@ -203,13 +203,13 @@ items:
|
||||||
recreateParams:
|
recreateParams:
|
||||||
timeoutSeconds: 600
|
timeoutSeconds: 600
|
||||||
mid:
|
mid:
|
||||||
failurePolicy: Abort
|
failurePolicy: Retry
|
||||||
execNewPod:
|
execNewPod:
|
||||||
containerName: release-monitoring-web
|
containerName: release-monitoring-web
|
||||||
command:
|
command: [ python3, "/etc/anitya/check_db.py" ]
|
||||||
- /bin/bash
|
env:
|
||||||
args:
|
- name: ANITYA_WEB_CONFIG
|
||||||
- /etc/anitya/wait_for_web_service.sh
|
value: /etc/anitya/anitya.toml
|
||||||
volumes:
|
volumes:
|
||||||
- config-volume
|
- config-volume
|
||||||
resources: {}
|
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) }}
|
{{ load_file('httpd.conf') | indent(6) }}
|
||||||
anitya.wsgi: |-
|
anitya.wsgi: |-
|
||||||
{{ load_file('anitya.wsgi') | indent(6) }}
|
{{ load_file('anitya.wsgi') | indent(6) }}
|
||||||
wait_for_web_service: |-
|
check_db.py: |-
|
||||||
{{ load_file('wait_for_web_service.sh') | indent(6) }}
|
{{ load_file('check_db.py') | indent(6) }}
|
||||||
- apiVersion: v1
|
- apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
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