Skip to content

Commit

Permalink
Changes based on the code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tczekajlo committed Nov 3, 2020
1 parent 29bff29 commit 3bd7939
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Validate that logging in works
run: |
TOKEN=$(curl --fail --data '{"username": "me", "password": "'${INITIAL_USER_PASSWORD}'"}' "http://localhost/api/auth" | jq -r '.access_token')
if [[ "${TOKEN}" == "" ]]; then
if [[ -z "${TOKEN}" ]]; then
echo "Access token is empty: ${TOKEN}" && exit 1
fi
echo "Access token: ${TOKEN}"
16 changes: 10 additions & 6 deletions charts/rasa-x/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ Return 'true' if required version to run the database migration service is corre
If version is not valid semantic version then not use the DB migration service.
*/}}
{{- define "db-migration-service.requiredVersion" -}}
{{- if and (not (regexMatch "^(v[0-9]|0|[1-9]\\d*).(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" (include "db-migration-service.version" .))) (not .Values.dbMigrationService.ignoreVersionCheck) -}}
{{- print "false" -}}
{{- else if .Values.dbMigrationService.ignoreVersionCheck -}}
{{- if .Values.dbMigrationService.ignoreVersionCheck -}}
{{- print "true" -}}
{{- else -}}
{{- if semverCompare ">= 0.33.0" (include "db-migration-service.version" .) -}}
Expand All @@ -245,6 +243,12 @@ If version is not valid semantic version then not use the DB migration service.
{{- end -}}
{{- end -}}

{{/*
Returns the database migration service address
*/}}
{{- define "db-migration-service.address" -}}
{{ .Release.Name }}{{- print "-db-migration-service-headless" -}}
{{- end -}}
{{/*
Return an init container for database migration.
*/}}
Expand All @@ -258,9 +262,9 @@ initContainers:
- '-c'
- "apk update --no-cache && \
apk add jq curl && \
until nslookup {{ .Release.Name }}-db-migration-service-headless 1> /dev/null; do echo Waiting for the database migration service; sleep 2; done && \
until [[ \"$(curl -s http://{{ .Release.Name }}-db-migration-service-headless:{{ .Values.dbMigrationService.port }} | jq -r .status)\" == \"completed\" ]]; do \
STATUS_JSON=$(curl -s http://{{ .Release.Name }}-db-migration-service-headless:{{ .Values.dbMigrationService.port }}); \
until nslookup {{ (include "db-migration-service.address" .) }} 1> /dev/null; do echo Waiting for the database migration service; sleep 2; done && \
until [[ \"$(curl -s http://{{ (include "db-migration-service.address" .) }}:{{ .Values.dbMigrationService.port }} | jq -r .status)\" == \"completed\" ]]; do \
STATUS_JSON=$(curl -s http://{{ (include "db-migration-service.address" .) }}:{{ .Values.dbMigrationService.port }}); \
PROGRESS_IN_PERCENT=$(echo $STATUS_JSON | jq -r .progress_in_percent); \
STATUS=$(echo $STATUS_JSON | jq -r .status); \
echo The database migration status: ${STATUS}...${PROGRESS_IN_PERCENT}%; \
Expand Down
4 changes: 1 addition & 3 deletions charts/rasa-x/templates/db-migration-service.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{ if eq "true" (include "db-migration-service.requiredVersion" .) }}
{{ if .Values.separateDBMigrationService }}
{{ if and (eq "true" (include "db-migration-service.requiredVersion" .)) .Values.separateDBMigrationService }}
apiVersion: "v1"
kind: "Service"
metadata:
Expand All @@ -18,4 +17,3 @@ spec:
{{- include "rasa-x.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: db-migration-service
{{end}}
{{end}}
5 changes: 3 additions & 2 deletions charts/rasa-x/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ rasa:
# dbMigrationService specifies settings for the database migration service
# The database migration service requires Rasa X >= 0.33.0
dbMigrationService:
# settings related to the init-db container used as a init container for services
# initContainer describes settings related to the init-db container used as a init container for deployments
initContainer:
# image is the Docker image which is used by the init container
image: alpine:latest
# command overrides the default command to run in the container
command: []
# args overrides the default arguments to run in the container
args: []
# name is a Docker image name
# name is the Docker image name which is used by the migration service
name: "rasa/rasa-x" # gcr.io/rasa-platform/rasa-x-ee
# tag refers to the Rasa X image tag (uses `appVersion` by default)
tag: ""
Expand Down

0 comments on commit 3bd7939

Please sign in to comment.