|
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 |
7 | 13 |
|
8 | 14 | - name: Check if slurm database requires an upgrade
|
9 | 15 | ansible.builtin.command: slurmdbd -u
|
|
12 | 18 | failed_when: >-
|
13 | 19 | _openhpc_slurmdbd_check.rc > 1 or
|
14 | 20 | '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 |
16 | 23 |
|
17 | 24 | - name: Set fact for slurm database upgrade
|
18 | 25 | # If -u option doesn't exist it can't be a major upgrade due to existing
|
19 | 26 | # appliance version
|
20 | 27 | # 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 |
22 | 29 | set_fact:
|
23 | 30 | _openhpc_slurmdb_upgrade: >-
|
24 | 31 | {{ false
|
|
0 commit comments