new OPL scripts: dump/restore OPL tables, load global statistics without other local table work#985
Conversation
such a file, as loading from a dump-file is much faster than running OPL-update. Modify the docker-entrypoint.sh to do such a dump after running OPL-update, to attempt to restore the OPL tables from a dump-file before trying to run OPL-update, and also to save/restore the JSON files generated by OPL-update. Also add a script to import that OPL global statistics without running the full update-OPL-statistics script which also works on local data.
heiderich
left a comment
There was a problem hiding this comment.
I gave the dump and restore files a test in their version in #980. I think this is a great idea!
The file load-OPL-global-statistics seems to do part of what update-OPL-statistics is doing. This means code duplication, which is usually not a good idea. There are different ways around this:
- Remove that part from
update-OPL-statisticsand call both files whenupdate-OPL-statisticswas called before. This would probably require updating the documentation. - Remove that part from
update-OPL-statisticsand callload-OPL-global-statisticsfromupdate-OPL-statisticsinstead. - Move the code that does the actual work into a third file that is used by both of them.
global statistics data from the OPL after running update-OPL-statistics. Remove the reloading of the global statistics data from update-OPL-statistics but print a warning that it no longer does that. Also fix the warning in lib/WeBWorK/Utils/LibraryStats.pm to inform users to use load-OPL-global-statistics instead of update-OPL-statistics when the global statistics data is missing.
Addressed by commit f63ed9f
The documentation at |
|
Since I do not intend to address the inline comment about the passwords at present, I marked the tread above as resolved, but the issue should be obvious - so here is a summary: @heiderich wrote:
I responded:
A contribution improving the manner in which the database settings are handled and which secures the password would be very welcome. |
|
Testing (requires comfort working in the mysql database directly):
|
|
I opened #987 to document the security issue. Even though I think that this practice is a a bad idea, I do not want to stay in the way of this PR. |
|
Commit f63ed9f resolves my concerns about code duplication. Thanks @taniwallach. |
|
Thanks David. This looks like it might be the best quick fix: Set MYSQL_PWD in the environment (export MYSQL_PWD=muhpassword) and execute your command without the -p. See MySQL Program Environment Variables. In spite of the manual's dire warnings, this is rather safe. Unless you start weird warez in the same shell later. So we run: MYSQL_PWD=$(cat foo.php etc) mysql -u foouser -h barhost – David Tonhofer Mar 1 '18 at 18:02 Note that there is the MYSQL_PWD environment variable which is read by mysql if you don't specify -p. And under Linux this is a secure method because the environment of a user cannot be read by other unprivilleged users - in contrast to the argument vector. – maxschlepzig Jul 14 at 14:55 |
@mgage Did you possibly mean to post this comment in #987? If so, could you post it again there? It would be easier to keep track of the discussion if we keep topics little separated when possible. (This was one of the reasons I opened that issue.) |
with the use of the MYSQL_PWD environment variable. See: openwebwork#987
implemented in commit 00d4f30 |
|
I just tested the current version of PR #980 and the current version of these scripts. See: #980 (comment) @heiderich - after the recent changes - are you ready to approve? @mgage @pstaabp @jwj61 @glarose @nmoller @sean-fitzpatrick @Alex-Jordan - Do any of you plan to test this (before it gets merged)? |
|
No, I won't have a chance to test it. I am just glad people are able to build on what I wrote many years ago. |
|
One more minor comment: Some of the Perl scripts in I am in favor of having the endings in the filenames, as it indicates already what to expect. So I wonder whether we should add those endings to the newly added filenames. |
… them/refer to them
caa03af to
70f2e2e
Compare
I renamed the "new" scripts and some of the old ones modified by this PR. |
|
Yet another minor comment: In view of #876 I wonder whether we should possibly avoid "OPL" in the name of the (new) scripts and rather use something generic like "library"? I agree that renaming |
|
For now, we want to solve these "problems" for the OPL, and until the support for multiple libraries is completed and tested, it is too soon to predict exactly how to modify these scripts to support other libraries. For now, I think this is good enough. When additional library support is added, we would want to create generic scripts which could run for a given library based on a parameter sent as a command line argument, and the OPL specific scripts could then be wrappers which call the generic scripts with the parameter set to "OPL". |
New scripts to dump the OPL tables to a dump-file and to restore from such a file, as loading from a dump-file is much faster than running
OPL-update.Also add a script to import that OPL global statistics without running the full
update-OPL-statisticsscript which also works on local data.