Closed kizniche closed 7 years ago
I've updated the script to distinguish the latest major version (i.e. 4 in v4.X.X) in the list of releases. This can be useful to prevent unrestricted upgrading to the latest version. For instance, if a user has v4.0.26 installed, and versions 4.0.27, and 5.0.0 have been released since that install, then the user would only be able to upgrade the the latest v4 release. This prevents upgrading to a major version that may not have backward-compatibility with v4 dependencies, databases, etc.
After adding test releases and running, here is the output:
kiz@tango:mycodo/scripts$ ./test_new_upgrade_method.py
List of all Mycodo Releases:
v5.0.0
v4.0.27
v4.0.26
Latest Version: v5.0.0
Tar URL: https://api.github.com/repos/kizniche/Mycodo/tarball/v5.0.0
Latest v4 Version: v4.0.27
Tar URL: https://api.github.com/repos/kizniche/Mycodo/tarball/v4.0.27
I've been experimenting with a new upgrade script. It replaces the Mycodo install with the latest release, moves camera folders and databases, then upgrades the database and restarts the web UI and daemon. Unique about it is a two-part system. It will create a script that will execute after the first half of the script has finished executing. This new script will be separate from the Mycodo install and allows all the files in the Mycodo install directory to be safely moved, without having to worry about what happens to an executing script when it tries to move itself.
I've tested it, and it works, but I'm not sure if I covered enough bases to ensure an error doesn't break the system. I added a reversion method that will restore the old version if there's an error in the part of the crucial moving process. I've also tested this to work.
Because this new method doesn't rely on cloning the git repository, commit hashes will need to be phased out of the system (particularly on the update page that exclusively relies on commit hashes at the moment).
I forgot to reference this issue again, but the most recent commit 4f8d56a introduces the new upgrade system to the mycodo_dev branch. It allows upgrading only to releases with the tag "v4.X.X" where Y and Z denote the minor and patch version numbers, respectively. I've tested it to work, but I'll continue to test to try and find issues.
Edit: I've created a temporary release, v4.1.0 (which is actually just a copy of release v4.0.26), to test the new upgrade system before release to the public.
I created a new repo to test the new upgrade system, and after about 20 upgrade tests, I believe it's at a point that works. I already deleted the repo, but all the fixes have been pushed to the mycodo_dev branch.
It essentially works like this:
Also, there is a recovery function built into the upgrade script that will rollback any changes if there are any errors encountered in the process of the upgrade during any critical parts (the moving of the install directories). Any errors that prevent the upgrade are logged and will be indicated on the upgrade page that an error occurred during the upgrade and will prevent the user from attempting the upgrade again (will remove the upgrade button) until the user physically deletes the ~/Mycodo/.upgrade file that indicates an error occurred. This page will also instruct the user where to find the upgrade log to find what error caused the issue.
I think this method is better than the current one for a couple reasons:
I'm leaning toward merging the mycodo_dev branch with the new upgrade system. I'm fairly confident it will work. However, if not, reinstalling Mycodo wouldn't be too difficult. I'm just wondering if anyone has any objections or issues I may not have considered.
Currently, upgrades are performed through the web UI under Admin/Upgrade, and will perform a git reset to bring the local repository to the master HEAD:
This necessitates the use of git branches to avoid committing to master and exposing users to the ability to upgrade. Additionally, there may come a time that the developers would like to push a commit to master but not want the master available to be upgraded to.
One solution I thought of is to use releases as a way to upgrade the system. When a new release that has a version number above the currently-installed version, an upgrade can be performed. I wrote a script, test_update_version_info.py, that will collect all current Mycodo releases named "vX.X.X", where the Xs are the version's major, minor, and patch numbers. The script will filter all other names out, then sort the versions to find the highest. Then, the tar archive URL is presented for the latest release version matching the "vX.X.X" format.
I was thinking the prefix to the version number can be used to denote different types of releases, in case there were a future option in Mycodo to be able to jump to an experimental upgrade track that allowed users to upgrade to pre-stable releases.