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

Add SET/RESET ROLE to migrations #82

Merged
merged 12 commits into from
Apr 29, 2021
Merged

Add SET/RESET ROLE to migrations #82

merged 12 commits into from
Apr 29, 2021

Conversation

rod-glover
Copy link
Contributor

@rod-glover rod-glover commented Feb 4, 2021

Resolves #81

Note to reviewers: The vast majority of the changes in this PR are documentation, formatting, and test updates. The significant changes are confined to a few lines in:

  • pycds/alembic/extensions/operation_plugins.py
  • pycds/alembic/versions/4a2f1879293a_create_functions.py
  • pycds/util.py

This PR wraps revision 42af upgrade operations (create SPs) in a SET/RESET role pair to enable creating SPs with sufficiently high privilege in real databases.

The user in the tests is already at maximum privilege and I have not added infrastructure to create and use a lower-privileged user to test this aspect. Nominally, in tests, all migration operations are executed by a limited-privilege user testuser and privilege is only escalated to role pcicdba for the wrapped operations. However, it proved extremely difficult to verify whether the user was being set properly in tests, so this cannot quite be taken as definitive.



@pytest.mark.usefixtures('new_db_left')
logger = logging.getLogger("tests")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: All changes in this file due to Black. No algorithmic changes.

@rod-glover
Copy link
Contributor Author

This code has also been run successfully against a test database cloned from metnorth.

@rod-glover rod-glover requested a review from corviday April 28, 2021 20:02
Copy link
Contributor

@corviday corviday left a comment

Choose a reason for hiding this comment

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

Looks good to me. Your explanations and documentation are clear. Good solution to a complicated problem, and heroic testing efforts. :)

@rod-glover rod-glover merged commit a6c21b9 into master Apr 29, 2021
@rod-glover rod-glover deleted the i81-set-role-su branch April 29, 2021 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SET ROLE to migrations
2 participants