Skip to content
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

flux-account: add new update-db command #244

Merged
merged 3 commits into from
Jun 22, 2022

Conversation

cmoussa1
Copy link
Member

Background

Noted in #215, there is a need for supporting the ability to update the flux-accounting database when a new version of the database is released so that the existing DB does not have to be completely re-created and have all values re-inserted. This will be especially important when new columns are added to an already existing table or a new table is added. There currently exists both export-db and pop-db commands to export and import database information into .csv files, but these commands also involve creation of a new DB to migrate this information. It would be nice to have support to just update the database that currently resides on a system with any new potential tables or columns after a new release of flux-accounting.


This is a [WIP] PR that adds a new command to flux-accounting: update-db, which will look at the DB schema of the database currently residing on a system and update it to add any missing tables or add any missing columns within each of the tables. It does so by creating a temporary database to compare schema; it will then compare tables and then iterate through each table and compare columns. After the iteration is done, the temporary database is removed. For testing purposes, there is an optional argument for the update-db command to specify a path for the temporary database; if not specified (which should be the norm and is noted in the description of the command), the temporary database is created and removed from the current working directory.

Two helper scripts are added to the t/ directory to help with testing:

modify_accounting_db.py is a helper script that adds two columns to the association_table and a new table to the flux-accounting DB for testing the functionality of the flux account-update-db command.

check_db_info.py is a helper script that checks the names of the tables in a flux-accounting DB or the names of the columns within a table in a flux-accounting DB.

The sharness test file t1017-export-db.t uses these two helper scripts to modify a flux-accounting DB to simulate a newer DB being released with an additional table and two additional columns added to one of the existing tables. The test runs the update-db command and makes sure the missing table and columns are added to the flux-accounting DB successfully.

Fixes #215

Add a new command to flux-account: update-db, which will look at
tables and their existing columns in an already existing flux-accounting DB
and add any new tables or columns to existing tables.

It does so by creating a temporary database to compare schema; it will then
compare tables and then iterate through each table and compare columns. After
the iteration is done, the temporary database is removed. For testing purposes,
there is an optional argument for the update-db command to specify a path for
the temporary database; if not specified (which should be the norm and is noted
in the description of the command), the temporary database is created and
removed from the current working directory.
Add two helper scripts for running the sharness tests in t1017-update-db.t:

modify_accounting_db.py is a helper script that adds two columns to the
association_table and a new table to the flux-accounting DB for testing the
functionality of the flux account-update-db command.

check_db_info.py is a helper script that checks the names of the tables in a
flux-accounting DB or the names of the columns within a table in a
flux-accounting DB.
@cmoussa1 cmoussa1 added the new feature new feature label Jun 21, 2022
@cmoussa1 cmoussa1 changed the title [WIP] flux-account: add new update-db command flux-account: add new update-db command Jun 21, 2022
@cmoussa1 cmoussa1 marked this pull request as ready for review June 21, 2022 21:30
@cmoussa1 cmoussa1 requested a review from ryanday36 June 21, 2022 21:30
Copy link
Contributor

@ryanday36 ryanday36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thanks @cmoussa1.

@cmoussa1
Copy link
Member Author

Thanks @ryanday36! Looking forward to seeing this tool in action. Setting MWP shortly

@mergify mergify bot merged commit 678f1e8 into flux-framework:master Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support migrating data from one flux-accounting DB to another
2 participants