Skip to content

Commit ba1715f

Browse files
committed
[openstack/nova] Nanny for orphaned migrations
Since we should only have few migrations ongoing, the query should be quite fast. We trigger it often as it will be a blocker to re-installing kvm hosts, as they get decomissioned each time, but have to wait for no migrations being associated with the compute-host.
1 parent e2575f5 commit ba1715f

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

openstack/nova/templates/bin-configmap.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ data:
1717
{{ include (include "job_bin_path" (tuple . "nanny-db-purge" "nanny")) . | indent 4 }}
1818
nanny-db-soft-delete-excessive-instance-faults: |
1919
{{ include (include "job_bin_path" (tuple . "nanny-db-soft-delete-excessive-instance-faults" "nanny")) . | indent 4 }}
20+
nanny-db-error-out-orphaned-migrations: |
21+
{{ include (include "job_bin_path" (tuple . "nanny-db-error-out-orphaned-migrations" "nanny")) . | indent 4 }}
22+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "INFO: Erroring out all orphaned migrations"
5+
exec nova-manage db error_out_orphaned_migrations
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{{- if .Values.nanny.error_out_orphaned_migrations.enabled }}
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: nova-nanny-db-error-out-orphaned-migrations
6+
labels:
7+
system: openstack
8+
component: nova
9+
type: nanny
10+
spec:
11+
schedule: {{ .Values.nanny.error_out_orphaned_migrations.schedule | quote }}
12+
concurrencyPolicy: Forbid
13+
jobTemplate:
14+
spec:
15+
template:
16+
metadata:
17+
{{- tuple . "nanny-db-error-out-orphaned-migrations" "nanny" | include "job_metadata" | indent 10 }}
18+
spec:
19+
restartPolicy: OnFailure
20+
podFailurePolicy:
21+
rules:
22+
- action: Ignore
23+
onExitCodes:
24+
operator: In
25+
values: [1]
26+
volumes:
27+
- name: container-init
28+
configMap:
29+
name: nova-bin
30+
defaultMode: 0755
31+
items:
32+
- key: nanny-db-error-out-orphaned-migrations
33+
path: nanny-script
34+
{{- include "utils.trust_bundle.volumes" . | indent 10 }}
35+
- name: nova-etc
36+
projected:
37+
sources:
38+
- configMap:
39+
name: nova-etc
40+
items:
41+
- key: nova.conf
42+
path: nova.conf
43+
- key: logging.ini
44+
path: logging.ini
45+
- key: release
46+
path: release
47+
- secret:
48+
name: nova-etc
49+
items:
50+
- key: api-db.conf
51+
path: nova.conf.d/api-db.conf
52+
initContainers:
53+
{{- tuple . (dict "service" (include "nova.helpers.database_services" .)) | include "utils.snippets.kubernetes_entrypoint_init_container" | indent 10 }}
54+
containers:
55+
- name: nanny
56+
image: {{ tuple . "nanny" | include "container_image_nova" }}
57+
imagePullPolicy: IfNotPresent
58+
command:
59+
- /bin/sh
60+
- -c
61+
- |
62+
/container.init/nanny-script
63+
exit_code=$?
64+
{{- include "utils.script.job_finished_hook" . | nindent 14 }}
65+
exit $exit_code
66+
env:
67+
{{- if .Values.sentry.enabled }}
68+
{{- include "utils.sentry_config" . | nindent 12 }}
69+
{{- end }}
70+
- name: PYTHONWARNINGS
71+
value: {{ .Values.python_warnings | quote }}
72+
volumeMounts:
73+
- mountPath: /etc/nova
74+
name: nova-etc
75+
- mountPath: /container.init
76+
name: container-init
77+
{{- include "utils.trust_bundle.volume_mount" . | indent 12 }}
78+
resources:
79+
requests:
80+
memory: "500Mi"
81+
cpu: "100m"
82+
{{- end }}

openstack/nova/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,3 +1036,7 @@ nanny:
10361036
schedule: "30 * * * *"
10371037
max_faults: 10
10381038
max_rows: 25
1039+
error_out_orphaned_migrations:
1040+
enabled: true
1041+
# cron schedule (minute | hour | day of month | month | day of week)
1042+
schedule: "7,22,37,52 * * * *"

0 commit comments

Comments
 (0)