-
-
Notifications
You must be signed in to change notification settings - Fork 112
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 sample_data script #994
Conversation
It can be executed by ofn-admin or ofn-deploy user. But it can't be automated until we pass in the db credentials (user,pass,dbname). MAybe we set these as env vars, and/or with user .pgpass file
todo: refactor onto multiple lines [skip ci]
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 see where you are going with this. All the sudo commands work for ofn-admin but not for ofn-deploy. That user can execute only one single command as root at the moment:
# Grant ofn-deploy sudo access for deploy script
ofn-deploy ALL=(ALL) NOPASSWD: /home/ofn-deploy/deploy
/etc/sudoers.d/ofn-deploy
Thanks, so I take it you have no concerns about heading in this direction. 👍 Hmm, actually there's another piece of the puzzle I hadn't realised before: the ability to trigger the script is tied to the specific deployment SSH key. So I guess we would need to create a separate SSH key for this new script. I see why you had reservations about heading down this path :) |
Also, currently, this is just replacing the current data with the sample data. And then there are requests to expand the sample data, or apply only some of the sample data. Each of these may be different commands. If we don't want to end up with lots of repetition then we would need to open our SSH setup. I think that it would be easier to allow Github to execute SSH commands as the openfoodnetwork user. It would make all this much easier. But maybe it would be better to have a more generic way of creating snapshots and use them. In that case, testers could create whatever test data they want and then store it for repeating tests. That data doesn't have to be managed in code then either. I reckon it may be easier to implement a simple admin UI for this than managing all kinds of sample data in code. Then we don't need any SSH or Github Actions for this. Example how this could work:
Estimate: 3 days. And I don't think that we would have less work messing around with Github Actions, ofn-install, managing SSH keys and creating new sample data factories. What do you think? |
Wow, thanks for thinking through this. You're right that we need to design a solution before jumping in to it. I thought this PR just needed another hour or two maybe, but then maybe I didn't think it all through.
Optional extension:
Again, it's worth talking to testers to see what the most pressing needs are. Filipe seems offline today, maybe we could bring it up next delivery circle, or after delivery circle (he's usually online then). |
Thanks so much for the time invested and sharing your insights ✨
This is an interesting solution indeed. Two thoughts:
Yes, lets discuss it on the next delivery circle, thanks again 👍 |
Yes, it would. |
This is true. So we could keep a backup restore script for the console. Maybe if we move this new UI into its own engine then it wouldn't depend on the OFN database and may be more robust. It depends if the bad database prevents Rails from loading altogether. |
Closed in favour of triggering as an option within the existing deploy script. |
It can be executed by ofn-admin or ofn-deploy user.