Skip to content

Commit

Permalink
Fix db scripts (#1736)
Browse files Browse the repository at this point in the history
* Check for empty response before converting to int

* Fix restore script to specify directory for backup files

Also:
- remove WORKING_DIR from database image
- Change backups so that jobs (& logs) are visible for 1 day
- Add pull secret for database image
  • Loading branch information
jmgrady authored Sep 21, 2022
1 parent 65b8c4d commit 1f33e9a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ database/semantic_domains/*
_*.yml
_*.yaml
_*.j2
deploy/scripts/setup_files/**/dev_*.yaml

# Emacs backup files (this is Jim's fault)
*~
Expand Down
2 changes: 1 addition & 1 deletion database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mongo:5.0

WORKDIR /app
WORKDIR /

RUN mkdir /data/semantic-domains

Expand Down
11 changes: 10 additions & 1 deletion deploy/helm/thecombine/charts/database/templates/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ spec:
matchLabels:
combine-component: database
strategy:
type: Recreate
type: {{ .Values.global.updateStrategy }}
{{- if eq "RollingUpdate" .Values.global.updateStrategy }}
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
{{- end }}
template:
metadata:
creationTimestamp: null
Expand All @@ -48,6 +53,10 @@ spec:
- mountPath: /data/db
name: database-data
restartPolicy: Always
{{- if ne .Values.global.pullSecretName "None" }}
imagePullSecrets:
- name: {{ .Values.global.pullSecretName }}
{{- end }}
volumes:
- name: database-data
persistentVolumeClaim:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
metadata:
creationTimestamp: null
spec:
ttlSecondsAfterFinished: 300
ttlSecondsAfterFinished: 86400
template:
metadata:
creationTimestamp: null
Expand Down
14 changes: 9 additions & 5 deletions maintenance/scripts/combine_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ def main() -> None:
for i, backup_entry in enumerate(aws_backup_list):
print(f"{i+1}: {backup_entry[1]} ({backup_entry[0]})")

backup_num = int(
input("Enter the number of the backup you would like to restore (0 = None):")
response = input(
"Enter the number of the backup you would like to restore (0 = None):"
)
if backup_num == 0:
if response:
backup_num = int(response)
if not response or backup_num == 0:
print("No backup selected. Exiting.")
sys.exit(0)
backup = aws_backup_list[backup_num - 1][1]
Expand All @@ -123,10 +125,11 @@ def main() -> None:
if not db_pod:
print("Cannot find the database container.", file=sys.stderr)
sys.exit(1)
db_files_subdir = os.environ["db_files_subdir"]
combine.kubectl(
[
"cp",
os.environ["db_files_subdir"],
db_files_subdir,
f"{db_pod}:/",
]
)
Expand All @@ -138,14 +141,15 @@ def main() -> None:
"--drop",
"--gzip",
"--quiet",
f"--dir=/{db_files_subdir}",
],
)
combine.exec(
db_pod,
[
"rm",
"-rf",
os.environ["db_files_subdir"],
f"/{db_files_subdir}",
],
)

Expand Down

0 comments on commit 1f33e9a

Please sign in to comment.