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

feat(cli): add new migrate-secret-key command (#240) #240

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

mdonadoni
Copy link
Member

@mdonadoni mdonadoni commented Nov 19, 2024

Closes reanahub/reana-server#695

How to test:

  1. Deploy 0.9.3
  2. Save your REANA token
  3. Deploy 0.9.4 (alpha)
  4. Firstly, migrate invenio's secret key to the current one: invenio instance migrate-secret-key --old-key CHANGE_ME
  5. Change the secret key and re-deploy
  6. Restart reana-server: kubectl rollout restart deployment reana-server
  7. Restart reana-workflow-controller: kubectl rollout restart deployment reana-workflow-controller
  8. Migrate invenio's and REANA's secret keys: invenio instance migrate-secret-key --old-key <old_key> and reana-db migrate-secret-key --old-key <old_key> (if you didn't set a secret key in (1) and (3), then the old secret key is secret_key)
  9. Test that you can see your token in the profile page of the web UI and that it's the same as (2)

@@ -612,3 +612,33 @@ def update_workflows_disk_quota() -> None:
for workflow in workflows:
store_workflow_disk_quota(workflow)
timer.count_event()


def change_key_encrypted_columns(old_key):
Copy link
Member

Choose a reason for hiding this comment

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

praise: ‏I tested both scenarios (with a without the fix) and it works very nicely 👍

Copy link
Member

Choose a reason for hiding this comment

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

suggestion: ‏One observation about the smoothness of the operation for the site admin. I tested a situtaion when the admin does migrate the Invenio DB, but not the REANA DB, following the change of the secret key. In this case, the user cannot login via the web interface, and sees a nice message saying that something went wrong with the application. That's good. However, when the admin looks into reana-server logs, the admin only sees a Python traceback regrading SQLAlchemy padding error (see below). Could we catch the exception in the reana-server in order to provide a better phrased hint to the admin about what is happening?

$ k logs reana-server-568fcf5d48-kqvx2
...
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/orm/loading.py", line 725, in _populate_full
    dict_[key] = getter(row)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/sql/type_api.py", line 1278, in process
    return process_value(impl_processor(value), dialect)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 479, in process_result_value
    value = super().process_result_value(value=value, dialect=dialect)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 424, in process_result_value
    decrypted_value = self.engine.decrypt(value)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 123, in decrypt
    decrypted = self.padding_engine.unpad(decrypted)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/padding.py", line 44, in unpad
    raise InvalidPaddingError()
sqlalchemy_utils.types.encrypted.padding.InvalidPaddingError

Copy link
Member Author

Choose a reason for hiding this comment

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

I have pushed a new commit on top of reana-server/towards-release: reanahub/reana-server@d50c508

Alputer added a commit to Alputer/reana-db that referenced this pull request Nov 20, 2024
@tiborsimko tiborsimko merged commit efcbe72 into reanahub:maint-0.9 Nov 20, 2024
15 checks passed
tiborsimko added a commit to tiborsimko/reana-db that referenced this pull request Dec 4, 2024
chore(maint-0.9): release 0.9.5 (reanahub#219)
feat(cli): add new `migrate-secret-key` command (reanahub#240)
ci(python): test more Python versions (reanahub#239)
ci(actions): pin setuptools 70 (reanahub#239)

Note: The merge commit removes the changes related to pinning
`setuptools` to version 70, because this was only necessary for the
`maint-0.9` branches, as well as other 0.9.4 release-related changes.
tiborsimko added a commit to tiborsimko/reana-db that referenced this pull request Dec 4, 2024
chore(maint-0.9): release 0.9.5 (reanahub#219)
feat(cli): add new `migrate-secret-key` command (reanahub#240)
ci(python): test more Python versions (reanahub#239)
ci(actions): pin setuptools 70 (reanahub#239)

Note: The merge commit removes the changes related to pinning
`setuptools` to version 70, because this was only necessary for the
`maint-0.9` branches, as well as other 0.9.4 release-related changes.
tiborsimko added a commit to tiborsimko/reana-db that referenced this pull request Dec 4, 2024
chore(maint-0.9): release 0.9.5 (reanahub#219)
feat(cli): add new `migrate-secret-key` command (reanahub#240)
ci(python): test more Python versions (reanahub#239)
ci(actions): pin setuptools 70 (reanahub#239)

Note: The merge commit removes the changes related to pinning
`setuptools` to version 70, because this was only necessary for the
`maint-0.9` branches, as well as other 0.9.4 release-related changes.
@mdonadoni mdonadoni deleted the migrate-secret-key branch December 5, 2024 09:52
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.

2 participants