HeliumDIY / helium_workarounds

Container base for Helium workarounds to run in
7 stars 11 forks source link

docker build and run #5

Open serbyxp opened 2 years ago

serbyxp commented 2 years ago

hi, I'm not very failure with any sort of connecting 2 docker containers together,

I have downloaded the repo and ran docker build helium_workaround -t wa docker run wa I get a :

Traceback (most recent call last): file "fix_not_found_peer.py, line 67, in for line in follow(log_file): File "fix_not_found_peer.py, line 17, in follow File = open(filename, 'r') FileNotFoundError: [Errno 2] no such file or directory /log/console.log'

I sure in the docker run wa I need to add some sort of bind or mount command to the helium miner docker folder...

assuming the docker helium miner container is the standard repo with a var/data folder bind to / home/pi/hotspot_data would I need to add a ---mount type=bind,source=/home/pi/hotspot_data,target=/var/data <<< or /var/data/log

rafaribe commented 2 years ago

You don't even have to build the container yourself if you don't want to. There's already pre-containers built on GitHub Container Registry and DockerHub.

Here's the relevant part of my docker-compose that I use:

helium_workarounds:
    image: ghcr.io/heliumdiy/helium_workarounds:latest
    container_name: helium_workarounds
    volumes:
      - /home/pi/miner_data/log:/log
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - LOG_ONLY_FAILED=True
    networks:
      - helium
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"

The entrypoint of the container expects the file to be supplied either by ENV var or as the first argument. Here are the relevant lines to solve your problem: https://github.com/HeliumDIY/helium_workarounds/blob/main/Dockerfile#L13 https://github.com/HeliumDIY/helium_workarounds/blob/main/src/fix_not_found_peer.py#L56 https://github.com/HeliumDIY/helium_workarounds/blob/main/src/fix_not_found_peer.py#L58

OmegxEU commented 2 years ago

Hi,

I will like to try using this but I don't know what steps do I need to take (I'm totally new to this). Is there any step by step instruction?

serbyxp commented 2 years ago

I got it to work, Both ways , with running ansible command on fresh boot. But you have to make some changes to the file the “all” need to change it to “localhost “ https://github.com/HeliumDIY/helium_ansible/blob/main/rpi.yml#L3 I didn’t figure out how to get the hotspot.yml https://github.com/HeliumDIY/helium_ansible/blob/main/hosts.yml#L5 file to work I think you need to add it to the device tree. But if you want to get it to work you can just go in the template folder and the docker compose file. https://github.com/HeliumDIY/helium_ansible/blob/main/roles/miner/templates/docker-compose.yml#L154-%23L172 But you got to take all the {} and replace it with the actual path of the container image . Heh the ansible thing got me confused since I never used it before but … on a raspi4 you can just do sudo apt install ansible . Then use “sudo ansible-playbook ./rpi.yml “

https://github.com/HeliumDIY/helium_ansible/blob/main/group_vars/all.yaml#L1 Like that’s where I added the content of the hotspot.yml ( all the erroneous things after compile ) like the host name or Hotspot name etc that’s from this file https://github.com/HeliumDIY/helium_ansible/blob/main/host_vars/hotspot.yml Also note here for the eec key portion if your using that repo you need to add the True statement in the all.yml file somewhere in there To make this part of the code work

https://github.com/HeliumDIY/helium_ansible/blob/main/roles/miner/templates/miner/sys.config#L10

maybe the guys who wrote it will clarify that issue for us about the hotspot.yml file not auto being added … I think it’s something in the host.yml that needs to be linked to it 🤷‍♀️.

like if you want fresh provision then use ansible if you just want to add the workaround then you can just do like a “docker-compose up “ in terminal where the docker-compose file is saved …and just make sure that the folder where your miner_data is located corresponds with the docker compose file … you can just cut and paste the workaround part. But theirs some other issues like the file paths when using just docker compose vs ansible … or you can just # comment all the stuff you don’t want loaded if you want to leave it there … like the file path :config.sys is going to give you an error and all the {}{} %if else if ,is going to give you errors it works fine using ansible but not straight up docker… I didn’t make this so I mean it took me like 2 days to figure out really simple things… like “ansible-playbook ./rpi.yml “ being the main comand only command you need. It’ll compile everything and at the end it will throw you errors but just read them they tell you what’s wrong. And you can fix those and re run untill you get it all right. Like the i2c-1 and i2c-0 https://github.com/HeliumDIY/helium_ansible/blob/main/roles/miner/templates/docker-compose.yml#L61 you can just delete the one and the if else statement and just leave the one that’s for your miner , if not you got to change the names like “pices” or “cotx” just name it . In the host variables and what not theirs all the stuff that you can change “false” to “true” if you want ansible to install it or not … then the host name etc … just go through all the tasks and what not and make the appropriate changes for your setup.

If the people that wrote this want to try something different, I think I got an idea for a workaround that might be a little more focused towards the peer books, bs just a refresh ( I’m not a coder but I know enough to have an idea) Instead of the peer refresh , it would entail some sort of peer book workaround like have all the peers that are being refreshed be put into a seperate database or “book” and try to resend the message instead of just refreshing it, that or I think we need to use some sort of “onion network” to let our connections through to the countries that have government / isp firewalls etc. Not sure if that’s even possible or what. But just an idea .

rafaribe commented 2 years ago

@serbyxp Glad you got it working, but you don't have to install ansible on the pi, you should install it on your host system and then supply the ssh credentials to connect through ssh with ansible via the ansible_host and so on.

Every variable on the all.yml should and can be overriden by the hosts.yml for your particular case. The idea for the hosts.yml file is that you can supply a fleet of hotspots with different manufacturers, needing different settings and you can just run ansible once and it can manage all of them.

The peerbook question won't be a thing for much longer, when the Team Helium releases the gateway-rs (light hotspots) the Rust implementation will perform gRPC calls directly on the hotspots instead of relying on Erlang's libp2p, therefore eliminating this problem.

serbyxp commented 2 years ago

Yeah I noticed since first time I even heard of ansible and started looking into it because I do a lot of raspberry pi projects not concerning helium specific like OpenPnP stuff and CNC CAM stuff. Esp32 little hobby projects. It was something I was doing the hard way before. Really good software that I got interested in. For provisioning things on the fly.

I personally already got gateway-rs alpha ( I think it’s the only one out still ) compiled on raspberry pi 1 b 32 bit with the SX1302 hal ready to go, ( takes forever to compile on slower systems) if your gonna do it do something like a a cross compile or have a main image that you can use that ansible to quick provision.

I had a broken concentrator card on my origonal nebra miner hardware that broke so the new 1302 hal USB version pinout is Basiclly the same, and it can be ran as SPI. Main difference that I wasn’t able to change because of balenaOS provisioning used by nebra( resets config.txt on reboot) , is what I noticed in the data sheet which is specific to different concentrator manufactures, some are “active high” some are “active low” which is in reference to the reset pins I/O. I noticed in one of the files I think it was the packet forwarder tasks or maybe the hotspot.yml there is a part in the code with a “ spi # usb “ I tried switching that around to “usb # spi”. But I think I couldn’t get that part to work in the container image for your packet forwarder repo, same as all the other manufacture packet forwarders ( helium og, nebra etc..) don’t have the USB implementation or portion in the actual base code that compiled the lora_pkt_fwd , I could be wrong, since I could never get that hotspot.yml file to load for me heh. But the lora-net SX1302 hal has that in it, so the /dev/ttyACM0 path and the mcu .bin file can be updated or loaded whatever it does… it’s not an issue, but if you get bored you might want to add that for versatility later on down the road.. especially for the gateway-rs light hotspots, you’ll be able to use something even smaller then a raspi 1 b ( esp32…) could handle your grpc and the mcu (stm32) in the usb packet forwarders can handle the UDP passing through the port 1680 to esp32 or just a simple usb-Ethernet from a custom image for the stm32 mcu.bin… I’m working on that personally but I’m stuck like chuck until they fix this peer issue, like none of my witnesses get dialed all failed, not found or connection refused. I get some witnesses currently but they are either RAK or helium OG. I have a buddy that has a fleet of helium OG like 20, that were all great earners on the top floors of 30+ story buildings, and they flat lined also and are not in deny list, all on different IP ( isp) addresses same issue. We have 1 validator that claims to be in Miami fl, I can’t even dial or ping it with /p2p/adder it’s broken as f… it effects everything including the API updates to the sync state all that. I ran on my laptop the AMD version of the miner image and the API updated right away like in less then 1 hour. I have no idea if it’s a settings issue in the image or maybe on the provisioning using ansible on ARM, pi… I went in manually to networking settings and disabled all the ipv6 addresses in Raspi to ipv4 only 🤔 and I started beaconing … lol I don’t know if that had anything to do with it, or if it was just coincidence that I got “lucky” and someone I could actually dial sent me the request?? But I think the ipv4 / 6 settings affect the libp2p also. Which I don’t think is set up In your playbook. But it didn’t change the main issue but I did read that somewhere about ipv4 / 6 and p2p… maybe it’s an issue someone would have to confirm that. I also changed the settings for ipv6/4 in isp provided router/modem to use the ipv4 only but I could not change the main ipv6 ip of the ISP, even though I get a ipv4 IP which is what p2p displays. ( I never had an issue with my isp or p2p for the month before the December update ) worked fine just plugging it in and forwarding the port 44158)

The only time I get the error of connection refused is I am in USA ( Miami fl ) I get it on turkey and on China challengers, I think that’s just government or maybe my Comcast isp firewall, which is understandable, but the other not found errors are people that supposedly are in USA, Canada isp networks which I shouldn’t have an issue connecting to, as far as government firewalls etc… I don’t mean to say USA is better then any other country or anything like that, I just understand they ( different governments ) allow Different firewalls access controls that can effect this also. I don’t want to make this a rant, but issue wise maybe the ipv4 / 6 settings can be an issue that is a simple setting you might be able to confirm or add to your playbook , I did it manually ( I kept the GUI on the pi since I’m not good at terminal commands navigating so much… I’m point and click kinda guy heh ) just food for thought to tweak your play book if it’s even a thing, or concern of yours. I don’t know so much about “TOR” networks but maybe the openvpn or the other program you have in there that I’m not familiar with, or something can make tunnels ? Or hops to or through the government / isp firewalls ? I don’t know , might be more work and time vs just waiting it out… Untill light-hotspot is official..

But very good work with this is so clean and understandable to use once you read get proficient with ansible “framework” documentation / commands . If you guys have a discord or forum hangout spot to shoot ideas instead of this issues board, I’ll hop in there every now and then bounce some ideas around , or help trouble shoot any issues. Let me know.

n8091977 commented 2 years ago

I am struggling to get this running, once I have the docker image on my pi how do I setup the env files and make it run?

My logs are in /home/pi/hnt/miner/log

root@remote-miner-6:/home/pi/hnt/miner/log# docker pull ghcr.io/heliumdiy/helium_workarounds:latest latest: Pulling from heliumdiy/helium_workarounds 9b3977197b4f: Already exists df1b46ab5c09: Pull complete a61966fcb4dc: Pull complete 067ecd560f60: Pull complete 2a838f7dac6e: Pull complete 35d5c083237b: Pull complete a5726d5be1f9: Pull complete 4a93546cf0ab: Pull complete 69b1147e74e8: Pull complete Digest: sha256:9cfa84f4822de0418b51ce318ba4803f3da39a3957ba293eb4505b0fcfe9f9c8 Status: Downloaded newer image for ghcr.io/heliumdiy/helium_workarounds:latest root@remote-miner-6:/home/pi/hnt/miner/log# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 70c14ed64268 quay.io/team-helium/miner:miner-arm64_2022.01.29.0_GA "/opt/miner/bin/mine…" 18 hours ago Up 18 hours miner 099a33cf462d gateway_mfr:arm64 "/opt/gateway_mfr/bi…" 6 months ago Up 5 days provision root@remote-miner-6:/home/pi/hnt/miner/log# docker start helium_workarounds Error response from daemon: No such container: helium_workarounds

serbyxp commented 2 years ago

I mentioned it in a post. That I closed here… it takes hours for it to update the ledger.db folder / files. I use an ssd … so it took me 3 hours for all those to populate… someone on helium official issues mentioned 5-10 hours to update on an SD card . If your having issues with the files loading into the folder I mentioned in the closed issue of trying to chmod 777 the ledger folder , I can not confirm that is the issue, but if you look at the ledger.db folder it should be populating the files in there slowly… but if it’s not populating files. Then try the chmod 777 or something similar to that folder

if you read above other comments , you can see how I set it up, and got it to run is diffrent then the way the author intended it to be ran, so when it comes to the permissions on the folders, that might be a reason that I had to change the folder permissions , that might not be the case for those running it the way it was intended. I have issues when starting and stopping the container as well due to the permissions set in the tasks, since I run this using portainer. It conflicts with certain settings for me, so you might need to look into the permissions etc, when running it differently then written by the original authors.

look at the folder if it’s growing , then just let it be don’t restart it or it will mess it up, in your console log it will look like it’s “hung” on a script called upgrading to gateway_v2

it’s like 450-500 mbs of files that it has to populate so an sd card with a write speed of 22 or so is going to take longer then say an ssd 150 ( on a pi ) but it’s a long wait if you keep turning it on off it won’t ever finish just look at the folder ledger.db make sure it’s adding files , if not try the chmod thing, it doesn’t add the files in any particular order how ever it pulls it from peers I guess …

also, I mean besides the point of the long loading time… for gateway_v2 it didn’t fix any of the peer not found or failed to connect issues . So don’t expect much to change in regards to that. I think it’s a firewall issue across ISP / government firewalls. But I can’t confirm that, so it’s just speculation. I have been beaconing a lot more tho. So I mean 🤷‍♀️. What gives with that issue, if you know anything about ToR / VPNs or any of that sort of stuff, that might be the only way to try and get more of those receipts in. I don’t know about that stuff to much or where to really start with that. But I have noticed the refreshing for peers, instead of it just sending to one peer, it is sending to a lot of different peers now the same receipt , which is “new” I think… also the witnesses I do get. Are never on the first attempt, it’s always on the retry or second attempt. If that means anything to anyone… heh I’m just over it, untill I figure out how to make tunnels or Whtever it is that ToR does by hopping around firewalls etc…

Also another thing but I only have 1 hotspot, so I can’t tell you if it works or not. Or what / how those files get populated into ledger.db but I sent someone I trust my ledger.db folder like a zip file… if the ledger.db files aren’t specific to your Miner or hotspot… if you have more then 1 you might be able to just copy that folder to the rest of your “fleet”.. again I can’t confirm that since I got 1 hotspot.

@n8091977 if your running this on a manufacturers miner, you need to note, that a lot of the manufacturers firmware when restarted flushes the drive to a default setup, so you might not be able to save or make any changes to that firmware or OS, their may be some files you can change and or save but that’s specific to your setup, then note that the workaround file has a file path that’s looking for logs in a specific place to tail them, and or to execute the docker cli api commands, in the /home/pi/miner_data which I think you changed it to the correct path which seems to be /home/pi/hnt… in. Your case. But in the script or python workaround it’s also got a file location for the docker cli … etc, so I mean why it’s saying the container is not found… that might be an issue of the firmware deleting any extra files / folders on every restart. But… double check those things, is the only thing I can think of, sorry I didn’t see you’ve already been on the newer image for over 18 hours so I’m sure your up to date with your update for gateway_v2 so if your having the issue that your manufacturer resets the image every time it loads that’s going to be a hassle to figure out / you might need to download it every time you want to use it 🤷‍♀️ Or maybe try using “sudo” when downloading / running the workaround image… that might save it properly… one of those permission things… that might work around, that or don’t restart the thing . Nebra uses balenaOS which they have a “supervisor” software that everytime it restarts it does like a check on what’s different then their “fleets” settings and reverts / deletes things

as far as enviroment and that type of stuff this is what I got showing in my portainer 7D6D0E1F-4036-4EC3-9BE5-A6C16717D51A

benisdev-py commented 2 years ago

Hey the docker compose yml:

....."volumes:

beauce I have a pices p100 Miner and they save it to :"/home/pi/hnt/miner/log" so its a diffrent path, I ust changed the path in the docker-compose.yml to my path but I dont know if the container works so how can I check if the " helium_workarounds " Container is working fine?

My logs of the helium_workarounds Container:

Logging only failed to dial events Tailing file: /log/console.log Logging only failed to dial events Tailing file: /log/console.log

hope that is rigth.