-
Notifications
You must be signed in to change notification settings - Fork 19
Add support for upgrading database #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e1afa2f
add support for upgrading database
sjpb a5f15e7
fix db upgrade check for initial deploy
sjpb 7358916
add mysql tool to support checking db status
sjpb 5c784c5
make slurm db service consistent
sjpb 0d372fb
make backup optional
sjpb 2a8cfa8
fix ansible-lint whinging
sjpb 55914fe
fix upgrade code for mariadb in CI
sjpb 0ca5b0f
fix mariadb connections
sjpb a3275a7
fix upgrade logic
sjpb 9d3143f
Fix readme typo
sjpb 3050291
fix upgrade logic
sjpb 1a55f61
Merge branch 'feat/upgrade-db' of github.com:stackhpc/ansible-role-op…
sjpb 362e3fc
explain upgrade logic
sjpb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
- name: Check if slurm database has been initialised | ||
# DB is initialised on the first slurmdbd startup (without -u option). | ||
# If it is not initialised, `slurmdbd -u` errors with something like | ||
# > Slurm Database is somehow higher than expected '4294967294' but I only | ||
# > know as high as '16'. Conversion needed. | ||
community.mysql.mysql_query: | ||
login_db: "{{ openhpc_slurmdbd_mysql_database }}" | ||
login_user: "{{ openhpc_slurmdbd_mysql_username }}" | ||
login_password: "{{ openhpc_slurmdbd_mysql_password }}" | ||
login_host: "{{ openhpc_slurmdbd_host }}" | ||
query: SHOW TABLES | ||
config_file: '' | ||
register: _openhpc_slurmdb_tables | ||
|
||
- name: Check if slurm database requires an upgrade | ||
ansible.builtin.command: slurmdbd -u | ||
register: _openhpc_slurmdbd_check | ||
changed_when: false | ||
failed_when: >- | ||
_openhpc_slurmdbd_check.rc > 1 or | ||
'Slurm Database is somehow higher than expected' in _openhpc_slurmdbd_check.stdout | ||
# from https://github.com/SchedMD/slurm/blob/master/src/plugins/accounting_storage/mysql/as_mysql_convert.c | ||
when: _openhpc_slurmdb_tables.query_result | flatten | length > 0 # i.e. when db is initialised | ||
|
||
- name: Set fact for slurm database upgrade | ||
# Explanation of ifs below: | ||
# - `slurmdbd -u` rc == 0 then no conversion required (from manpage) | ||
# - default of 0 on rc skips upgrade steps if check was skipped because | ||
# db is not initialised | ||
# - Usage message (and rc == 1) if -u option doesn't exist, in which case | ||
# it can't be a major upgrade due to existing openhpc versions | ||
set_fact: | ||
_openhpc_slurmdb_upgrade: >- | ||
{{ false | ||
if ( | ||
( _openhpc_slurmdbd_check.rc | default(0) == 0) | ||
or | ||
( 'Usage: slurmdbd' in _openhpc_slurmdbd_check.stderr ) | ||
) else | ||
true | ||
}} | ||
|
||
- name: Ensure Slurm database service stopped | ||
ansible.builtin.systemd: | ||
name: "{{ openhpc_slurm_accounting_storage_service }}" | ||
state: stopped | ||
register: _openhpc_slurmdb_state | ||
when: | ||
- _openhpc_slurmdb_upgrade | ||
- openhpc_slurm_accounting_storage_service != '' | ||
|
||
- name: Backup Slurm database | ||
ansible.builtin.shell: # noqa: command-instead-of-shell | ||
cmd: "{{ openhpc_slurm_accounting_storage_backup_cmd }}" | ||
delegate_to: "{{ openhpc_slurm_accounting_storage_backup_host }}" | ||
become: "{{ openhpc_slurm_accounting_storage_backup_become }}" | ||
changed_when: true | ||
run_once: true | ||
when: | ||
- _openhpc_slurmdb_upgrade | ||
- openhpc_slurm_accounting_storage_backup_cmd != '' | ||
|
||
- name: Ensure Slurm database service started | ||
ansible.builtin.systemd: | ||
name: "{{ openhpc_slurm_accounting_storage_service }}" | ||
state: started | ||
when: | ||
- openhpc_slurm_accounting_storage_service != '' | ||
- _openhpc_slurmdb_state.changed | default(false) | ||
|
||
- name: Run slurmdbd in foreground for upgrade | ||
ansible.builtin.expect: | ||
command: /usr/sbin/slurmdbd -D -vvv | ||
responses: | ||
(?i)Everything rolled up: | ||
# See https://wiki.fysik.dtu.dk/Niflheim_system/Slurm_installation/#upgrade-slurmdbd | ||
# and | ||
# https://github.com/SchedMD/slurm/blob/0ce058c5adcf63001ec2ad211c65e67b0e7682a8/src/plugins/accounting_storage/mysql/as_mysql_usage.c#L1042 | ||
become: true | ||
become_user: slurm | ||
when: _openhpc_slurmdb_upgrade |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.