docker image rm uses wrong format?
Closed this issue · 7 comments
When the miner is more than 500 blocks behind, removal of the image does not work.
This is what the script tries to do:
docker image rm miner-amd64_2020.10.12.1_GA
Error response from daemon: invalid reference format: repository name must be lowercase
The command should probably be
docker image rm quay.io/team-helium/miner:miner-arm64_2020.10.12.1_GA
Untagged: quay.io/team-helium/miner:miner-arm64_2020.10.12.1_GA
Untagged: quay.io/team-helium/miner@sha256:0546a3dfa164943cfc5624fe467d0ae5c8446721be29adefef92b8a474702881
Deleted: sha256:528a9811811a3f9e5260285f5547b172a16ef0255d0e568c883aa235a4ca8306
Deleted: sha256:e6f2f7ea131c9b55aabcd74990f690f23054486cacc9ab8c8ce9572dffaccd93
Deleted: sha256:7f177e2014a00adca6235e9608a44d5426862a6bd8128a3102ba337a59c1e17e
Deleted: sha256:88ac2f8395988ec4a6199a917cb9795cfb0e27e00ba3d79b5911415028a523a5
Deleted: sha256:500340c4b43178cc5fe2218a059bf1cfbec51db3af48eae19c8753f3160423f1
Deleted: sha256:678a0785e7d29c77c56c1bb0af4b279374e731903506838956f7bc808665a6dd
But since I don't understand why we're removing the image, I'm not 100% sure how this should be fixed.
Also, the following code:
if [[ $height_diff -gt 50 ]]; then docker stop "$MINER" && docker start "$MINER" ; fi
#If the miner is more than 500 blocks behind, stop the image, remove the container, remove the image. It will be redownloaded later in the script.
if [[ $height_diff -gt 500 ]]; then docker stop "$MINER" && docker rm "$MINER" && docker image rm "$miner_latest" ; fi
will first stop the miner, due to height_diff being greater than 50. Then the second if clause (>500) will try to stop the miner again - which will fail with Error response from daemon: No such container:
causing the docker rm and docker image rm to not be run.
Maybe it should be changed to
if [[ $height_diff -gt 50 ]]; then docker stop "$MINER" && docker start "$MINER" ; fi
#If the miner is more than 500 blocks behind, stop the image, remove the container, remove the image. It will be redownloaded later in the script.
if [[ $height_diff -gt 500 ]]; then docker image rm "$miner_latest" ; fi
There might be a race condition here though - if it takes time to stop and remove the container? I think docker stop and docker rm can return before the command has finished completely?
We were removing the older images because we didn't want to fill up the disk space. I could have sworn this was working previously so im not sure what changed in regards to the name formatting. I'll take a look at that though.
On the first height difference, it stops the miner waits for that command to complete, then starts the miner. So the next if statement should be able to stop the miner, should it not?
When you use the && operand it should wait completely for the previous command to complete and if it completes sucessfully, then it will perform the next command. I guess its possible it tries to stop then start the miner and while that is starting up it may try to stop it again in the next if statement.
We were removing the older images because we didn't want to fill up the disk space. I could have sworn this was working previously so im not sure what changed in regards to the name formatting. I'll take a look at that though.
Yes, we do remove old images to clear disk space in https://github.com/Wheaties466/helium_miner_scripts/blob/master/miner_latest.sh#L93
The cleanup code prefixes with quay.io/team-helium/miner
so it works.
But this code is at https://github.com/Wheaties466/helium_miner_scripts/blob/master/miner_latest.sh#L69 and it doesn't use quay.io/team-helium/miner
. Maybe the solution is to just add the prefix, but since I don't understand what this part of the code does (I don't understand how removing the image would resolve sync problems but it could be just because I don't know exactly how the miner works) I don't want to add the prefix without anyone else checking.
On the first height difference, it stops the miner waits for that command to complete, then starts the miner. So the next if statement should be able to stop the miner, should it not?
When you use the && operand it should wait completely for the previous command to complete and if it completes sucessfully, then it will perform the next command. I guess its possible it tries to stop then start the miner and while that is starting up it may try to stop it again in the next if statement.
Yes, you are correct. My bad. Just ignore everything starting with "Also" in my original comment.
I think I'm going to add an
&& echo "stopping and starting the miner because it may be stuck syncing the blockchain"
to give some more debugging info for the logs.
EDIT: I added that statement in. So now you shouldn't get that message in the future.
I believe this is now fixed so im going to close.
There has been no change to the related code, so I don't see how this could have been fixed.
https://github.com/Wheaties466/helium_miner_scripts/blob/master/miner_latest.sh#L66 still does docker image rm "$miner_latest"
which does not contain the quay.io/team-helium/miner
prefix.
Ah thats right sorry about that. I thought that had been included in a PR. I'll add it now.