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

Update scripts #161

Open
mahansky opened this issue Oct 10, 2018 · 10 comments
Open

Update scripts #161

mahansky opened this issue Oct 10, 2018 · 10 comments

Comments

@mahansky
Copy link
Contributor

mahansky commented Oct 10, 2018

Problems

git

Windows

If the %GOPATH% variable contains spaces, following command will fail (quotes should fix it)
https://github.com/skycoin/skywire/blob/669cf0742522268df8724a210456b580ef298dca/static/script/win/update-skywire.bat#L9

md5 hash

On unix platforms, md5 hash of node executable is calculated

  • it's not used anywhere after that
  • is probably not correct since the update can happen in another files than node executable

https://github.com/skycoin/skywire/blob/master/static/script/unix/start

Idea

Don't discard the output from update scripts, return it from the API endpoint instead, so it can be displayed on the frontend to help with debugging

@gz-c
Copy link
Member

gz-c commented Oct 11, 2018

"git commands (like git pull) requires authentication on official skywire images, so it's not possible to update skywire software using its api" what do you mean requires authentication?

@mahansky
Copy link
Contributor Author

For example, the script to check if there is a new update available, it asks for github username/password instead of directly printing out true/false

root@Orangepi:/usr/local/skywire/go/src/github.com/skycoin/skywire/static/script/unix# ./check
Username for 'https://github.com':

@gz-c
Copy link
Member

gz-c commented Oct 11, 2018

that could be a misconfiguration of .git/config

@mahansky
Copy link
Contributor Author

root user doesn't have git config in his home dir, this is the content of project's git config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/samoslab/skywire.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

@BigOokie
Copy link
Contributor

Adding some information taken from testing the upgrade with @mahansky last night on an Official Skyminer (using official images). Each pair of commands and their output are combined in script blocks below.

git status

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
git rev-parse HEAD

28940f7f65285665f448dbf686230b9a7763f1c2
[ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \
sed 's/\// /g') | cut -f1) ] && echo "false" || echo "true"

Username for 'https://github.com': 
Password for 'https://github.com': 
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/samoslab/skywire.git/'
-bash: [: 28940f7f65285665f448dbf686230b9a7763f1c2: unary operator expected
true

Note: the github repo referenced above.

Can also confirm I was also seeing an issue with the %GOPATH% (as mentioned above) when attempting to trigger the upgrade via the browser. This is what was shown when inspecting with Chrome dev tools:

fork/exec /src/github.com/skycoin/skywire/static/script/unix/check: no such file or directory

Can confirm that when I SSH into the Manager Node, its %GOPATH% is set correctly however. So this env appears not to be available to the app maybe?

@gz-c
Copy link
Member

gz-c commented Oct 12, 2018

https://github.com/samoslab/skywire.git/ this is the wrong git url, it should be https://github.com/skycoin/skywire.git/

@gz-c
Copy link
Member

gz-c commented Oct 12, 2018

git remote set-url origin https://github.com/skycoin/skywire.git

@asxtree
Copy link
Collaborator

asxtree commented Oct 12, 2018

######ONLY FOR OFFICIAL IMAGES######

The steps to upgrade should be like this, the old commands from May should not be used because a new key will be created

cd /usr/local/skywire/go/src/github.com/skycoin/skywire/
git remote -v #Not mandatory, used only to see the current repo url
git remote set-url origin https://github.com/skycoin/skywire.git
git pull --progress

After the pull an incognito tab should be used or clear the browser cache (Chrome).
Tested on the manager image, on orange pi prime.

Other skywire installations should just use the update button from the web interface of the node or git pull

@gz-c
Copy link
Member

gz-c commented Oct 13, 2018

shift-ctrl-r / shift-cmd-r will reload a page with cache flush on chrome

@jdpwebb
Copy link
Contributor

jdpwebb commented Oct 19, 2018

I have had the update process working on the official images for a couple months now. The issue is not with skywire or the update scripts but with the official images. The steps needed to get the update button from the frontend working on the official images are:

  1. Change the git remote repository to this repository as noted above by @asxtree and in the README (https://github.com/skycoin/skywire#ip-presetted-system-images).
  2. Ensure that the necessary environment variables are available. Specifically, ensure the GOPATH is set for the process running the skywire node, and that the PATH variable includes the path to the golang binary. I suspect this will require exporting the relevant variables in rebuild.sh. I have updated my nodes to use systemd so I can easily stop and restart my nodes so my setup is slightly different. This issue is referenced in $GOPATH and other variables not defined in Manager GUI terminal session #76.
  3. Note that SSL verification in images #81 and Date/time incorrect on official images #77 are also relevant. You will either need to use export GIT_SSL_NO_VERIFY=1 as it exists in /etc/rc.local or update the official image's system time so that you can pull without seeing any certification errors.

md5 hash

On unix platforms, md5 hash of node executable is calculated

  • it's not used anywhere after that
  • is probably not correct since the update can happen in another files than node executable

https://github.com/skycoin/skywire/blob/master/static/script/unix/start

Idea

Don't discard the output from update scripts, return it from the API endpoint instead, so it can be displayed on the frontend to help with debugging

Regarding the above, the md5 hash is used to check if the update was successful and return this information to the front end (in this line), but I agree with @mahansky that this is not the best method of checking if the update was successful for several reasons:

  • As @mahansky notes, if other files are updated without any changes to the executable, for example if only a UI file is updated, the update process will appear to fail even though it was successful because the md5 hash of the old executable and the "new" executable will be the same.
  • If the update process is successful, but the user chooses to wait to restart the node, and then later tries to do the update again (because they have forgotten that they already did so), they will be informed that the update failed. Instead they should be told they need to restart the node to complete the update process.
  • It's hard to return information to the user about which part of the update process failed.

There are other issues with the update process, but fixing the above will solve many of them.

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

No branches or pull requests

5 participants