Skip to content

Commit a5f15e7

Browse files
committed
fix db upgrade check for initial deploy
1 parent e1afa2f commit a5f15e7

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

tasks/runtime.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,16 @@
164164
state: "{{ 'restarted' if _openhpc_munge_key_copy.changed else 'started' }}"
165165
when: openhpc_slurm_service_started | bool
166166

167-
- name: Ensure slurm database is upgraded
167+
- name: Check slurmdbd state
168+
command: systemctl is-active slurmdbd
169+
changed_when: false
170+
failed_when: false # rc = 0 when active
171+
register: _openhpc_slurmdbd_state
172+
173+
- name: Ensure slurm database is upgraded if slurmdbd inactive
168174
import_tasks: upgrade.yml # need import for conditional support
169175
when:
176+
- "_openhpc_slurmdbd_state.stdout == 'inactive'"
170177
- openhpc_enable.database | default(false)
171178
- openhpc_slurm_accounting_storage_service != ''
172179

tasks/upgrade.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
- name: Check slurmdbd is inactive
2-
# only even check for upgrade if slurmdbd isn't already started
3-
command: systemctl is-active slurmdbd
4-
changed_when: false
5-
failed_when: false # rc = 0 when active
6-
register: _openhpc_slurmdbd_state
1+
- name: Check if slurm database has been initialised
2+
# DB is initialised on the first slurmdbd startup (without -u option).
3+
# If it is not initialised, `slurmdbd -u` errors with something like
4+
# > Slurm Database is somehow higher than expected '4294967294' but I only
5+
# > know as high as '16'. Conversion needed.
6+
community.mysql.mysql_query:
7+
login_db: "{{ openhpc_slurmdbd_mysql_database }}"
8+
login_user: "{{ openhpc_slurmdbd_mysql_username }}"
9+
login_password: "{{ openhpc_slurmdbd_mysql_password }}"
10+
#login_host:
11+
query: SHOW TABLES
12+
register: _openhpc_slurmdb_tables
713

814
- name: Check if slurm database requires an upgrade
915
ansible.builtin.command: slurmdbd -u
@@ -12,13 +18,14 @@
1218
failed_when: >-
1319
_openhpc_slurmdbd_check.rc > 1 or
1420
'Slurm Database is somehow higher than expected' in _openhpc_slurmdbd_check.stdout
15-
when: "_openhpc_slurmdbd_state.stdout == 'inactive'"
21+
# from https://github.com/SchedMD/slurm/blob/master/src/plugins/accounting_storage/mysql/as_mysql_convert.c
22+
when: _openhpc_slurmdb_tables.query_result != [[]] # i.e. when db is initialised
1623

1724
- name: Set fact for slurm database upgrade
1825
# If -u option doesn't exist it can't be a major upgrade due to existing
1926
# appliance version
2027
# Otherwise from manpage, rc 0 = no conversion, 1 = conversion required
21-
# Default skips upgrade steps if slurmdbd is running
28+
# Default skips upgrade steps if slurmdbd is running or db not initialised
2229
set_fact:
2330
_openhpc_slurmdb_upgrade: >-
2431
{{ false

0 commit comments

Comments
 (0)