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

Decomission the upnp container and bring it into hm-config #164

Closed
vpetersson opened this issue Jan 19, 2022 · 27 comments
Closed

Decomission the upnp container and bring it into hm-config #164

vpetersson opened this issue Jan 19, 2022 · 27 comments
Assignees

Comments

@vpetersson
Copy link
Contributor

Background

We currently have a container running on the miners with the sole purpose of enabling uPNP. We can quickly just sunset this in favor of a single command in this repo.

It is however worth noting that this will be unnecessary once we move to light miners, but the timeline for this keeps slipping.

Acceptance Criteria

  • Remove the hm-upnp container from docker-compose.yml
  • Add the upnp package to the Dockerfile
  • Create a new task that runs every 12 hours that invokes the command
@shawaj
Copy link
Member

shawaj commented Jan 21, 2022

@vpetersson IMO this should be in hm-config not hm-diag.

Because UPnP requires host networking and so does config. Whereas diag doesn't

@shawaj
Copy link
Member

shawaj commented Jan 21, 2022

Also @vpetersson I don't think we need to run UPnP every 12 hours. We can just run it once at container start up

@vpetersson
Copy link
Contributor Author

Yeah, you're right. I was thinking this would solve the IP announcement with Helium, but those are two separate issues altogether. Just mixed them up in my head.

@MuratUrsavas
Copy link
Contributor

So, are we moving this task into hm-config?

@MuratUrsavas
Copy link
Contributor

What about this:

while(regionID is None):
    # While no region set
    try:
        with open("/var/pktfwd/region", 'r') as regionOut:
            regionFile = regionOut.read()

            if(len(regionFile) > 3):
                print("Frequency: " + str(regionFile))
                regionID = str(regionFile).rstrip('\n')
                break
        print("Invalid Contents")
        sleep(60)
        print("Try loop again")
    except FileNotFoundError:
        print("File Not Detected, Sleeping")
        sleep(60)

Should we really wait for it before enabling UPnP?

@shawaj
Copy link
Member

shawaj commented Jan 25, 2022

So, are we moving this task into hm-config?

Yes we should. We don't want host networking in diag container IMO

@shawaj shawaj transferred this issue from NebraLtd/hm-diag Jan 25, 2022
@shawaj
Copy link
Member

shawaj commented Jan 25, 2022

Moved it now @MuratUrsavas

@shawaj shawaj changed the title Decomission the upnp container and bring it into hm-diag Decomission the upnp container and bring it into hm-config Jan 25, 2022
@MuratUrsavas
Copy link
Contributor

Also, @vpetersson I'm running this task only once at the container startup like @shawaj said. Is that cool?

@vpetersson
Copy link
Contributor Author

Yeah that's fine. I confused the uPNP container with the IP logic that resides in the miner.

@MuratUrsavas
Copy link
Contributor

Right now I'm testing the changes and can see that hm-config container is listening port 44158 for uPnP. But HOST OS does not report the same (Checking from Balena Dashboard terminals). Is this the expected behavior?

@vpetersson
Copy link
Contributor Author

uPNP shouldn't require any open/listening ports. All it does is to send a packet to the router where it asks to do a port forwarding to port 44158 on the device sending it (/usr/bin/upnpc -e Nebra Helium -r 44158 TCP).

Port 44158 is the port of the miner and not hm-config.

@MuratUrsavas
Copy link
Contributor

This is interesting. The command you've mentioned is there right now and I'm seeing 44158 is listened in hm-config. Since gateway-config container is in Host network mode, it could be showing hm-miner's listening port? Could it be the case?

@vpetersson
Copy link
Contributor Author

Yes, because of host networking, so you're picking up the one from hm-miner. hm-config doesn't have any ports exposed explicitly.

@MuratUrsavas
Copy link
Contributor

Got it! Looks like this PR could make it into current sprint.

@MuratUrsavas
Copy link
Contributor

@vpetersson I have a question about FIRMWARE_VERSION parameter. I've changed it in docker-compose.yml from hm-config repo. Normally this parameter is broadcasted by helium-miner-software repo. Why do we need this also in here? Wouldn't that create a confusion, if the environment variable wouldn't get overridden?

If we should keep it, then what's the rule?

@shawaj
Copy link
Member

shawaj commented Jan 26, 2022

It's just for building and testing locally I think

@vpetersson
Copy link
Contributor Author

@MuratUrsavas yeah so this is a bit confusing and I think we should overhaul this. At this point, we only care about exposing the Helium Miner Software git has to hm-diag (i.e. FIRMWARE_VERSION). This will allow us to manually traverse back and find what exact hash of each corresponding sub-component (since the docker tag is the same as the git hash).

In the future, we will be introducing the semantic versioning for Helium Miner Software (NebraLtd/helium-miner-software#351), which will make this a bit more human readable.

@MuratUrsavas
Copy link
Contributor

@shawaj if that's the case then maybe we should consider removing it from all sub-repo's. IMHO it's a source of conflict. Maybe we could create MICRO_SERVICE_VERSION parameter or a similar one for that purpose later.

@shawaj
Copy link
Member

shawaj commented Jan 26, 2022

@MuratUrsavas it needs to be FIRMWARE_VERSION because the codebase looks for that specific environment variable.

The actual content of that variable is irrelevant. It could just be TEST.0.1 or whatever

We don't ever use the local repo docker compose for anything other than testing.

@shawaj
Copy link
Member

shawaj commented Jan 26, 2022

@MuratUrsavas yeah so this is a bit confusing and I think we should overhaul this. At this point, we only care about exposing the Helium Miner Software git has to hm-diag (i.e. FIRMWARE_VERSION). This will allow us to manually traverse back and find what exact hash of each corresponding sub-component (since the docker tag is the same as the git hash).

In the future, we will be introducing the semantic versioning for Helium Miner Software (NebraLtd/helium-miner-software#351), which will make this a bit more human readable.

@vpetersson this is not correct. Firmware version is the miner version. That is needed in both config and diag and possibly some of the other containers. But we put the firmware version into every container so that the containers have an environment variable update every time we push an update so the containers are all restarted.

@MuratUrsavas
Copy link
Contributor

@vpetersson this is not correct. Firmware version is the miner version. That is needed in both config and diag and possibly some of the other containers. But we put the firmware version into every container so that the containers have an environment variable update every time we push an update so the containers are all restarted.

But the same environment variable also comes from helium-miner-software and the current one is overridden (AFAIK) by it. So we'll always have a FIRMWARE_VERSION parameter coming from main repo, unless the sub container is solely working just by itself.

MuratUrsavas pushed a commit to NebraLtd/helium-miner-software that referenced this issue Jan 26, 2022
@vpetersson
Copy link
Contributor Author

@shawaj good point about pushing this to all containers. That's true.

That said, we want to move away from using the Helium Miner Version as our version tracker in favor of a Nebra flavored Semantic Version. This is the first step towards this.

(This Issue is the wrong issue to discuss this in fwiw.)

@shawaj
Copy link
Member

shawaj commented Jan 26, 2022

The docker-compose.yml in this repo is never used when building for the actual fleet (testnet or mainnet). It's only ever used for local building and/or just as a reference on how the container needs to be run.

Maybe good to rename it to docker-compose-example.yml or something

@MuratUrsavas
Copy link
Contributor

OK, this short discussion opened the way for me and I'm creating PR's right now.

@vpetersson
Copy link
Contributor Author

The docker-compose.yml in this repo is never used when building for the actual fleet (testnet or mainnet). It's only ever used for local building and/or just as a reference on how the container needs to be run.

Maybe good to rename it to docker-compose-example.yml or something

Ah I see what you mean. Yeah this docker-compose.yml file should be renamed to something like docker-compose_dev.yml or similar.

@MuratUrsavas
Copy link
Contributor

Done and merged to master.

@marvinmarnold marvinmarnold reopened this Jan 27, 2022
vpetersson added a commit to NebraLtd/helium-miner-software that referenced this issue Jan 27, 2022
* feat: Removed hm-upnp container. Its task is now carried by hm-config
(NebraLtd/hm-config#164)

* Bumped the hm-config version

* Update Raspberry Pi docker compose output

* Update ROCK Pi docker compose output

Co-authored-by: Murat Ursavas <[email protected]>
Co-authored-by: Murat Ursavaş <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@MuratUrsavas
Copy link
Contributor

Merged into production, closing the issue.

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

4 participants