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

Calling 'update.sh' from a different directory doesn't work. #2581

Closed
winder opened this issue Jul 19, 2021 · 1 comment · Fixed by #3983
Closed

Calling 'update.sh' from a different directory doesn't work. #2581

winder opened this issue Jul 19, 2021 · 1 comment · Fixed by #3983

Comments

@winder
Copy link
Contributor

winder commented Jul 19, 2021

Problem

If you put update.sh in the path and then execute an initial install, the command fails.

To test this, I created a small Dockerfile and executed docker build .

 FROM golang:1.14.7    
    
 # Basic dependencies.        
 ENV HOME /opt    
 ENV DEBIAN_FRONTEND noninteractive    
 RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3          
 RUN mkdir -p /opt/algorand/bin
 RUN mkdir -p /opt/algorand/data   
 ADD https://github.com/algorand/go-algorand/raw/1e1474216421da27008726c44ebe0a5ba2fb6a08/cmd/updater/update.sh 
/opt/algorand/bin/update.sh
 RUN chmod 755 /opt/algorand/bin/update.sh
-ENV PATH="/opt/algorand/bin:${PATH}"
-update.sh -i -c nightly -p /opt/algorand/bin -d /opt/algorand/data -n
+WORKDIR /opt/algorand/bin
+RUN ./update.sh -i -c nightly -p /opt/algorand/bin -d /opt/algorand/data -n
 RUN find /opt/algorand

With the first version I get this output:

docker build .
Sending build context to Docker daemon  7.076MB
Step 1/11 : FROM golang:1.14.7
 ---> 0fc73a78e79d
Step 2/11 : ENV HOME /opt
 ---> Using cache
 ---> caf11c205201
Step 3/11 : ENV DEBIAN_FRONTEND noninteractive
 ---> Using cache
 ---> ee9bd264a88a
Step 4/11 : RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3
 ---> Using cache
 ---> ee4ea8381580
Step 5/11 : RUN mkdir -p /opt/algorand/bin
 ---> Using cache
 ---> 0f07994fc76a
Step 6/11 : RUN mkdir -p /opt/algorand/data
 ---> Using cache
 ---> 6b72e0b1dc2c
Step 7/11 : ADD https://github.com/algorand/go-algorand/raw/1e1474216421da27008726c44ebe0a5ba2fb6a08/cmd/updater/update.sh /opt/algorand/bin/update.sh
Downloading  19.67kB
 ---> ad6bc3b53f03
Step 8/11 : RUN chmod 755 /opt/algorand/bin/update.sh
 ---> Running in 46566bb8c58f
Removing intermediate container 46566bb8c58f
 ---> 9b27a75c7a1b
Step 9/11 : ENV PATH="/opt/algorand/bin:${PATH}"
 ---> Running in 4e6db1235d8d
Removing intermediate container 4e6db1235d8d
 ---> e59adad2dcfb
Step 10/11 : RUN update.sh -i -c nightly -p /opt/algorand/bin -d /opt/algorand/data -n
 ---> Running in a0c6e057039c
Current Version = 0
downloaded file /opt/algorand/bin/install_master_linux-amd64.tar.gz is missing.
Removing intermediate container a0c6e057039c
 ---> 2cbea7ab8b1f
Step 11/11 : RUN find /opt/algorand
 ---> Running in 7eb216afde09
/opt/algorand
/opt/algorand/bin
/opt/algorand/bin/update.sh
/opt/algorand/data
Removing intermediate container 7eb216afde09
 ---> 7cf83d1e5c36
Successfully built 7cf83d1e5c36

With the second it completes as expected:

docker build .
Sending build context to Docker daemon  7.076MB
Step 1/11 : FROM golang:1.14.7
 ---> 0fc73a78e79d
Step 2/11 : ENV HOME /opt
 ---> Using cache
 ---> caf11c205201
Step 3/11 : ENV DEBIAN_FRONTEND noninteractive
 ---> Using cache
 ---> ee9bd264a88a
Step 4/11 : RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3
 ---> Using cache
 ---> ee4ea8381580
Step 5/11 : RUN mkdir -p /opt/algorand/{bin,data}
 ---> Running in c3dc48fdcb7a
Removing intermediate container c3dc48fdcb7a
 ---> 3314a759e9f6
Step 6/11 : ADD https://github.com/algorand/go-algorand/raw/1e1474216421da27008726c44ebe0a5ba2fb6a08/cmd/updater/update.sh /opt/algorand/bin/update.sh
Downloading  19.67kB
 ---> 25302b9935dc
Step 7/11 : RUN chmod 755 /opt/algorand/bin/update.sh
 ---> Running in 0ca3a3f7acfd
Removing intermediate container 0ca3a3f7acfd
 ---> 8074b53cfc00
Step 8/11 : WORKDIR /opt/algorand/bin
 ---> Running in d4dd4f884cea
Removing intermediate container d4dd4f884cea
 ---> 65ad076787c0
Step 9/11 : RUN ./update.sh -i -c nightly -p /opt/algorand/bin -d /opt/algorand/data -n
 ---> Running in c84b2cd2a2ea
Current Version = 0
updater
updater binary was downloaded
Latest Version = 8590459817
New version found
Checking for files matching: 'channel/nightly/node_nightly_linux-amd64_' in bucket algorand-releases
Update Downloaded to /tmp/tmp.yNNgaw0wdb/8590459817.tar.gz
Expanding update...
Validating update...
Starting the new update script to complete the installation...
... Resuming installation from the latest update script
Current Version = 0
Backing up current binary files...
Backing up current data files from /opt/algorand/data...
Installing new binary files...
Installing new data files into /opt/algorand/data...
Copying genesis files locally
Checking for new ledger in /opt/algorand/data
Cannot read genesis file /opt/algorand/data/genesis.json: open /opt/algorand/data/genesis.json: no such file or directory
Updating genesis files for default network
New genesis ID, resetting wallets
New Ledger - restoring genesis accounts in /opt/algorand/data
New Ledger - importing rootkeys for genesis accounts
Imported 0 keys
Applying migration fixups...
Deleting existing log files in /opt/algorand/data
Install complete - restart node manually
Removing intermediate container c84b2cd2a2ea
 ---> f5cf73e8a7db
Step 10/11 : RUN find /opt/algorand
 ---> Running in 5f044510c1ef
/opt/algorand
/opt/algorand/{bin,data}
/opt/algorand/bin
/opt/algorand/bin/update.sh
/opt/algorand/bin/[email protected]
/opt/algorand/bin/catchupsrv
/opt/algorand/bin/COPYING
/opt/algorand/bin/algokey
/opt/algorand/bin/carpenter
/opt/algorand/bin/msgpacktool
/opt/algorand/bin/goal
/opt/algorand/bin/find-nodes.sh
/opt/algorand/bin/backup
/opt/algorand/bin/backup/bin-v0.tar.gz
/opt/algorand/bin/algocfg
/opt/algorand/bin/ddconfig.sh
/opt/algorand/bin/genesisfiles
/opt/algorand/bin/genesisfiles/testnet
/opt/algorand/bin/genesisfiles/testnet/genesis.json
/opt/algorand/bin/genesisfiles/devnet
/opt/algorand/bin/genesisfiles/devnet/genesis.json
/opt/algorand/bin/genesisfiles/betanet
/opt/algorand/bin/genesisfiles/betanet/genesis.json
/opt/algorand/bin/genesisfiles/mainnet
/opt/algorand/bin/genesisfiles/mainnet/genesis.json
/opt/algorand/bin/genesisfiles/genesis.json
/opt/algorand/bin/tealdbg
/opt/algorand/bin/sudoers.template
/opt/algorand/bin/tealcut
/opt/algorand/bin/algoh
/opt/algorand/bin/kmd
/opt/algorand/bin/node_exporter
/opt/algorand/bin/systemd-setup.sh
/opt/algorand/bin/updater
/opt/algorand/bin/algod
/opt/algorand/bin/diagcfg
/opt/algorand/data
/opt/algorand/data/devnet-v1.0
/opt/algorand/data/kmd-v0.5
/opt/algorand/data/kmd-v0.5/kmd.pid
/opt/algorand/data/kmd-v0.5/kmd_config.json.example
/opt/algorand/data/kmd-v0.5/kmd-out.log
/opt/algorand/data/kmd-v0.5/kmd.lock
/opt/algorand/data/kmd-v0.5/sqlite_wallets
/opt/algorand/data/kmd-v0.5/kmd.log
/opt/algorand/data/kmd-v0.5/kmd.token
/opt/algorand/data/kmd-v0.5/kmd.net
/opt/algorand/data/kmd-v0.5/kmd-err.log
/opt/algorand/data/backup
/opt/algorand/data/backup/data-v0.tar.gz
/opt/algorand/data/wallet-genesis.id
/opt/algorand/data/genesis.json
/opt/algorand/data/config.json.example
/opt/algorand/data/goal.cache
Removing intermediate container 5f044510c1ef
 ---> 508063c9bade
Step 11/11 : ENV PATH="/opt/algorand/bin:${PATH}"
 ---> Running in 25f612c0dcad
Removing intermediate container 25f612c0dcad
 ---> c9635ddce1fd
Successfully built c9635ddce1fd

Solution

Download UPDATER_URL to the bin directory instead of the current working directory.

Acceptance criteria

Reproduce the failure to use update.sh with the instructions detailed above.
Create a follow up ticket with potential solutions to resolve outcome of reproducing the issue.

Dependencies

Urgency

Medium-High, could this be the "updater.sh" doesn't always work issue?

@algolucky
Copy link
Contributor

algolucky commented May 12, 2022

Noticed this while looking around, but I was given an error which leads me to:

echo "downloaded file ${SCRIPTPATH}/${UPDATER_FILENAME} is missing."

It's expecting that the updater script is in the same directory as update.sh . The curl command (

CURL_OUT=$(curl -LJO --silent ${UPDATER_URL})
) is executing in the current context, leading to the updater being installed in PWD, where the check expects it to be right next to update.sh.

Could try updating the curl command or the check, a cleaner solution might be to create a temporary directory that can be used for all artifacts, and reference that directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants