-
Notifications
You must be signed in to change notification settings - Fork 74
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
[RT-5] Add migration script to examples #23
Conversation
redash_toolbelt/examples/migrate.py
Outdated
return get_paginated_resource(path, api_key) | ||
|
||
|
||
def import_users(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might fail due to rate limit (50/hr, 200/day). Worth at least documenting this if not add a backoff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a note to client.py about this. In the official instructions I'll recommend disabling rate limits for the migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to disable this, looks like it's hardcoded here.
As a side note, could it be useful to log the exception to help debug this issue?
try:
response = dest_client._post(f"api/users?no_invite=1", json=data)
except Exception as ex:
print(
f"Could not create user: {ex}"
)
continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to disable this, looks like it's hardcoded here.
You can disable rate limits with this setting.
log the exception to help debug this issue?
This is a good idea. Will implement it.
redash_toolbelt/examples/migrate.py
Outdated
for p in options.get('parameters', []): | ||
if 'queryId' in p: | ||
p['queryId'] = meta['queries'].get(str(p['queryId'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might fail if the query has no values. Worth triggering a refresh, wait for it to complete (with some timeout?) and then continue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitate to kick this off synchronously since we a) don't want to hammer databases with queries b) delay the rest of the migration if these queries are long-running.
@arikfr I had a go at testing some of this and there are a large number of issues that came up when trying to migrate. Their were some small formatting issues and incorrect calls to get/post, but the biggest one was that it didn't seem to recognize pending invitations to users as real users. So when you try to import queries after moving all the users over. The part with the following doesn't work correctly:
It gives a 400 error I think because technically that user doesn't exist yet. Is there any way around that or to face those users to be real users and not pending? |
Hi @JSpenced, thanks for your efforts! This PR is still WIP so it definitely doesn't work in its current form. We'll post both here and on our user form (discuss.redash.io) once it's ready for testing (sometime in August, probably). |
Force pushed changes from local dev. |
f1f813a
to
2b37f4d
Compare
Hi, first of all thanks for your efforts!
Regards |
Missing extra step after migrate queries and before dashboards
|
Fixed! Thanks :) |
I incorporated the chronological import for queries in 8a65452. Can you see how well this works for your needs? Yes, I think we can import disabled users. Just requires a separate request to the |
I think if the goal of the migration script is to get the destination instance as close as possible to the original state, then I would expect the disabled users to be migrated too. At the moment, if the user is disabled, the queries that are owned by that user are not migrated either. |
This is exactly what we need but in my opinion, implementing this feature to all migrated content (queries, users, dashboards etc.) will be much better.. |
Done! See 623323d |
Agreed. Disabled user import (and a command to disable them again) is part of f8a6f6e |
I'd like to merge these changes and put out documentation within the next week in advance of the V10 OSS Redash release. If you have more feedback best to provide it sooner than later 👍 |
I completed migrating data from the hosted version to a self-hosted OSS version (running on v8.0). Using the migration scripts was easy and I did not run into any errors. I noticed a few things that did not get migrated in the process or were incomplete:
|
Really grateful to have this script! We've completed migrating from hosted (version: 7b026a19) to AWS hosted using the AMI (v8.0.0). This script worked well, with 2 issues we've spotted so far:
Thanks all! |
@smaraf Thanks for your feedback. Important note: this migration script is only intended for migrating to OSS V10 (currently in beta). Would love to hear feedback from you if you've tried to move to V10. Your viz customisations should migrate just fine. Ditto the date-range parameters. I'm wrapping up the alert destination migration code right now. |
@ChloeConnor Thanks for your feedback. This migration script is only targeted at OSS V10. I would expect different things to break if trying to move to an older API. The AMI's will be updated to V10 once we release it (soon!). |
As a data point with that, make sure you have a security group set on the VM to only allow incoming traffic on the right ports. eg ssh and https. Docker can muck around with the firewall rules on the host it's running on, so having an AWS Security Group providing a safety layer is a good idea. 😄 |
@susodapop Would it feasible to enable the wiki for this repo? That'd make for a fairly wasy way to document the migration process, and let anyone update it as the migration script is improved. |
@susodapop Thank you for the feedback! I've updated to v10 (which I was excited to see came out of beta 🥳 ) and re-ran the migrations. I can confirm that the date-range params are no longer an issue and they've been migrated correctly. Unfortunately, I'm still seeing the same results on the Visualization Configurations. Column names, their format, and whether they should be displayed have not been migrated to v10.0.0. |
@smaraf Thank you for the valuable feedback. 😦 Can you provide more details about the exact steps you followed? Can you share an example visualisation configuration that was not moved? I'm going to see if I can reproduce. Would like to publish the migration script this week. |
The WIP alert destinations script is now up. I've also added a README file for this script. Now that the V10 release is up I'm using that as my target for testing. There are a few issues with destinations to sort out yet, which I will be working through this afternoon (CST). Targeting Friday this week for the final release of I still have not managed to replicate @smaraf 's issue with visualisation definitions not moving. Would appreciate help if anyone knows reproduction steps. |
@justinclift There is now a README specific to this script. Contributors are welcome to pull request changes to it. We don't use the wiki feature on any of our repositories but this could be a good idea in the future. Will add it to the slate of decisions to be made by the community over the next few months. |
@susodapop No worries. The wiki idea is mostly because it's a fairly well known/understood approach for letting Community members document things, and the Redash Community has the right kind of constructive attitude to make it work. Also, I've personally been taking notes as I've been using the migrate.py script to transfer customer's data from the hosted Redash servers to our Newdash infrastructure. Having a wiki to put the useful info in would be a lot easier (my perspective) than having to make things neat and create PR's. Much faster iteration time that way. |
Good points! After the Hosted Redash EOL we'll need to consider a wiki more fully. Would be happy to review your notes and make sure we've covered any relevant portions in our docs if you want to share either as an issue on this repo or you can email me. If the context helps: we have a huge makeover in the works for our documentation as well 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐥
No worries @susodapop. 😄 Probably the main things I've so far found a bit weird, is the having to manually create data sources in the destination, then a mapping for them in the meta.json, then ditto for the admin user. To me, those should all be automatically done by the script. It should pretty much assume the destination is a new Redash, with just the initial admin user created. Then take it from there. As a workaround, I've been manually pulling the info, then plugging it into the meta.json. eg:
So far, I haven't yet seen a way of extracting the complete data source info (including pw) via the api. So, it doesn't seem possible to create a proper backup of an install this way. That being said, it should still be possible to have the script pull over stub details for each source (along with queries, etc), and have the admin user fill them out after the migration script has completed. With the general caveats about making sure data sources don't actually try connecting to things over a network until there's a secure encryption layer in place (ssl, ssh, vpn, whatever). |
Good feedbacks all @justinclift! If you look at the latest commits to this script (from the past couple weeks) you'll see we're now creating stub data sources. The API purposefully doesn't reveal passwords. No way around that one. |
Yeah. Sounds like a safety measure, to stop exfiltration if something goes wrong (or along similar lines). That being said, it stops the possibility of having a true backup/restore tool. At least through the API in it's current state. Still, being able to grab most stuff is 90% of the way there, and that's good enough for our purposes. 😄 |
Correct. This will not change.
This is only true for hosted Redash accounts, which won't exist in a couple months. For the vast majority of Redash admins, the backup/restore process is painless: just dump the database to a file. After 30 November 2021 there's no reason to maintain the migration script other than to demonstrate what's possible with |
I just pushed the addition to the |
@susodapop Sorry for the delayed response here. Thank you for the improvements for migrating alerts and for releasing the migration toolkit. This has been a huge help for me. I re-ran migrations this morning and made a simple example to showcase the visualization configurations that did not get moved over to my destination. In the screenshot below, see the source on the left and destination on the right. In this example, I customized the column name and description. |
Usage
See DEVELOPING THIS SCRIPT in the readme.
Type of PR
Description
This effort adds a revised version of this gist that uses the
redash_toolbelt
client, supports recent versions of Redash and migrates all of the content (the gist was skipping alerts and favorites).Steps
2to3
client.py
pyproject.toml
Expanded scope
Related Tickets & Documents
#5