25
25
esac
26
26
done
27
27
28
+
29
+ REFINERY_ALEMBIC_VERSION=" "
30
+ KUBERNETES_DEPLOYMENT_ALEMBIC_VERSION=" "
31
+
32
+ REFINERY_IMAGE_TAG_EXISTS=$( az acr repository show --name ${AZURE_CONTAINER_REGISTRY} --image ${REFINERY_DEPLOYMENT_NAME} :${TEST_IMAGE_TAG} 2> /dev/null || true)
33
+
34
+ downgrade_alembic_migrations () {
35
+ echo " ::group::Downgrade alembic migrations"
36
+ if [ $KUBERNETES_DEPLOYMENT_NAME != " refinery-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " gates-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " hosted-inference-api" ]; then
37
+ if [ -n " $REFINERY_IMAGE_TAG_EXISTS " ]; then
38
+ set +e
39
+ kubectl exec -i deployment/test-${REFINERY_DEPLOYMENT_NAME} -c test-${REFINERY_DEPLOYMENT_NAME} -- alembic downgrade $REFINERY_ALEMBIC_VERSION
40
+ if [ " $? " != " 0" ]; then
41
+ echo " ::error::Alembic downgrade failed. Please update your code to support downgrading the current alembic version"
42
+ kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
43
+ kubectl delete --kustomize infrastructure/test
44
+ exit 1
45
+ else
46
+ echo " ::notice::downgraded test-$REFINERY_DEPLOYMENT_NAME alembic version to $REFINERY_ALEMBIC_VERSION "
47
+ fi
48
+ set -e
49
+ fi
50
+ kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
51
+ else
52
+ set +e
53
+ kubectl exec -i deployment/test-${KUBERNETES_DEPLOYMENT_NAME} -c test-${KUBERNETES_DEPLOYMENT_NAME} -- alembic downgrade $KUBERNETES_DEPLOYMENT_ALEMBIC_VERSION
54
+ if [ " $? " != " 0" ]; then
55
+ echo " ::error::Alembic downgrade failed. Please update your code to support downgrading the current alembic version"
56
+ kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
57
+ kubectl delete --kustomize infrastructure/test
58
+ exit 1
59
+ else
60
+ echo " ::notice::downgraded test-$KUBERNETES_DEPLOYMENT_NAME alembic version to $REFINERY_ALEMBIC_VERSION "
61
+ fi
62
+ set -e
63
+ fi
64
+ echo " ::endgroup::"
65
+ }
66
+
28
67
__safe_migration_rollout () {
29
68
deploy=$1
30
69
@@ -48,24 +87,6 @@ __safe_migration_rollout() {
48
87
fi
49
88
}
50
89
51
- echo " ::group::Kubernetes Context & Test Infrastructure"
52
- kubectl config set-context --current --namespace=$KUBERNETES_NAMESPACE
53
- echo " Context set to namespace: \" $KUBERNETES_NAMESPACE \" "
54
- kubectl apply --kustomize infrastructure/test
55
- __safe_migration_rollout test-postgres
56
- until kubectl exec -i deployment/test-postgres -- sh -c pg_isready; do
57
- echo " Waiting for postgres to be ready..."
58
- sleep 3
59
- done
60
- kubectl exec -i deployment/test-postgres -- sh -c " psql -U postgres -c '$( cat infrastructure/test/deployment/assets/init.sql) '"
61
- echo " ::endgroup::"
62
-
63
-
64
- REFINERY_ALEMBIC_VERSION=" "
65
- KUBERNETES_DEPLOYMENT_ALEMBIC_VERSION=" "
66
-
67
- REFINERY_IMAGE_TAG_EXISTS=$( az acr repository show --name ${AZURE_CONTAINER_REGISTRY} --image ${REFINERY_DEPLOYMENT_NAME} :${TEST_IMAGE_TAG} 2> /dev/null || true)
68
-
69
90
upgrade_alembic_migrations () {
70
91
echo " ::group::Upgrade alembic migrations for test"
71
92
if [ $KUBERNETES_DEPLOYMENT_NAME != " refinery-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " gates-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " hosted-inference-api" ]; then
@@ -108,38 +129,18 @@ upgrade_alembic_migrations() {
108
129
echo " ::endgroup::"
109
130
}
110
131
111
- downgrade_alembic_migrations () {
112
- echo " ::group::Downgrade alembic migrations"
113
- if [ $KUBERNETES_DEPLOYMENT_NAME != " refinery-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " gates-gateway" ] && [ $KUBERNETES_DEPLOYMENT_NAME != " hosted-inference-api" ]; then
114
- if [ -n " $REFINERY_IMAGE_TAG_EXISTS " ]; then
115
- set +e
116
- kubectl exec -i deployment/test-${REFINERY_DEPLOYMENT_NAME} -c test-${REFINERY_DEPLOYMENT_NAME} -- alembic downgrade $REFINERY_ALEMBIC_VERSION
117
- if [ " $? " != " 0" ]; then
118
- echo " ::error::Alembic downgrade failed. Please update your code to support downgrading the current alembic version"
119
- kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
120
- kubectl delete --kustomize infrastructure/test
121
- exit 1
122
- else
123
- echo " ::notice::downgraded test-$REFINERY_DEPLOYMENT_NAME alembic version to $REFINERY_ALEMBIC_VERSION "
124
- fi
125
- set -e
126
- fi
127
- kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
128
- else
129
- set +e
130
- kubectl exec -i deployment/test-${KUBERNETES_DEPLOYMENT_NAME} -c test-${KUBERNETES_DEPLOYMENT_NAME} -- alembic downgrade $KUBERNETES_DEPLOYMENT_ALEMBIC_VERSION
131
- if [ " $? " != " 0" ]; then
132
- echo " ::error::Alembic downgrade failed. Please update your code to support downgrading the current alembic version"
133
- kubectl delete --kustomize apps/${REFINERY_DEPLOYMENT_NAME} /test
134
- kubectl delete --kustomize infrastructure/test
135
- exit 1
136
- else
137
- echo " ::notice::downgraded test-$KUBERNETES_DEPLOYMENT_NAME alembic version to $REFINERY_ALEMBIC_VERSION "
138
- fi
139
- set -e
140
- fi
141
- echo " ::endgroup::"
142
- }
132
+ echo " ::group::Kubernetes Context & Test Infrastructure"
133
+ kubectl config set-context --current --namespace=$KUBERNETES_NAMESPACE
134
+ echo " Context set to namespace: \" $KUBERNETES_NAMESPACE \" "
135
+ kubectl apply --kustomize infrastructure/test
136
+ __safe_migration_rollout test-postgres
137
+ until kubectl exec -i deployment/test-postgres -- sh -c pg_isready; do
138
+ echo " Waiting for postgres to be ready..."
139
+ sleep 3
140
+ done
141
+ kubectl exec -i deployment/test-postgres -- sh -c " psql -U postgres -c '$( cat infrastructure/test/deployment/assets/init.sql) '"
142
+ echo " ::endgroup::"
143
+
143
144
144
145
if [ " $ENABLE_ALEMBIC_MIGRATIONS " = " true" ]; then
145
146
upgrade_alembic_migrations
0 commit comments