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

/dev/i2c-7 messes up non rockpi units #253

Closed
shawaj opened this issue Nov 20, 2021 · 16 comments
Closed

/dev/i2c-7 messes up non rockpi units #253

shawaj opened this issue Nov 20, 2021 · 16 comments

Comments

@shawaj
Copy link
Member

shawaj commented Nov 20, 2021

if you add:

      - /dev/i2c-7:/dev/i2c-7

to a device (such as raspberry pi) that doesn't have this devices on the host-os then it fails to start those containers (diag and miner in this case).

Need to see if we can find a workaround for that

@shawaj
Copy link
Member Author

shawaj commented Nov 21, 2021

Possibly privileged: true is the best solution.

Not ideal though so will also reach out to balena

shawaj added a commit that referenced this issue Nov 21, 2021
As per #253 adding /dev/i2c-7 works to enable the i2c on RockPi but stops the diagnostics and miner containers from starting on Raspberry Pi based devices as they have no i2c-7

This moves to privileged: true which should give access to all available buses
@shawaj
Copy link
Member Author

shawaj commented Nov 21, 2021

This has fixed things so it works on both RockPi and RasPi.

The only question is whether there's any detrimental effects of using privileged: true in general

@kashifpk
Copy link
Contributor

privileged containers can be exploited to have full access to the host's devices (Ref: https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/) but in our case should not be an issue as we're using these boards for the single purpose of running the helium miner software. And that too is only possible with some constraints. So if a user that has our boxes wants to exploit this he is just messing with his own hardware. For a remote attacker he would first need someway to get a footprint into the container (via balena or some fault in our code). As we have balena public device urls disabled mostly that shouldn't be an issue.

My 2c - Not that risky considering where we're using it.

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

@kashifpk that was my thoughts also.

I guess the alternative is to maintain another repo for the RockPi version of the software but that seems unnecessary given this being the only required difference.

I wonder if it's possible to achieve this with any cap-add directive? Or whether we can make privileged: true more secure using cap-drop?

Also relates to #259 and maybe something like balena contracts or one of the other linked things could be helpful such as using multiple compose files for example https://docs.docker.com/compose/reference/

@vpetersson
Copy link
Contributor

I think it is inevitable that we will have to add multiple docker-compose files. Perhaps a better solution is to simply modify the build script to automatically configure /dev/i2c accordingly. That will unfortunately require us to run on different fleets, but perhaps it is the path of least resistance.

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

@vpetersson I think we will have to run on different fleets anyway because of the VARIANT being different on different hardware. We haven't solved that yet and not convinced we can...

@vpetersson
Copy link
Contributor

Yeah we were just discussing this in the stand-up. Then we can just auto-generate the docker-compose.yml file on run time (similar to Balena's Dockerfile.template) and just render it according to the target.

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

Perhaps for Testnet we use privileged: true and for other units we use different i2c bus.

Having said that...I don't see any particular reason not to use privileged: true on production devices.

Either way, the tooling isn't terribly difficult whichever path we choose

@vpetersson
Copy link
Contributor

I want to keep the delta between testnet and mainnet minimal. privileged: true is a big one that can cause a lot of different behaviors and bugs to go undiscovered.

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

@vpetersson then we have to maintain multiple different testnets as well i.e. RockPi testnet and RasPi testnet

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

I wonder if there's a way to remap i2c-7 on RockPi to i2c-1 (and vice versa) but probably more hassle than it's worth and not a good idea / something balena will support as will mean differences between operation on native and balenaOS

@vpetersson
Copy link
Contributor

@vpetersson then we have to maintain multiple different testnets as well i.e. RockPi testnet and RasPi testnet

Yeah good point. I think we should do that.

I wonder if there's a way to remap i2c-7 on RockPi to i2c-1 (and vice versa) but probably more hassle than it's worth and not a good idea / something balena will support as will mean differences between operation on native and balenaOS

Possible, but i think it's more likely they will allow the container to start w/out the device existing tho.

@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

I suppose one benefit to having different testnets is that we can more easily isolate hardware specific issues

@vpetersson
Copy link
Contributor

Yeah exactly.

shawaj added a commit that referenced this issue Nov 22, 2021
fever privileged containers based on discussion in #253
shawaj added a commit that referenced this issue Nov 22, 2021
- revert privileged containers based on discussion in #253
- add rockpi builds to testnet and production actions using build matrix
- with rockpi versions, change the i2c bus to i2c-7 in docker-compose
- remove hard coded balena cli version and change to env variable
@shawaj
Copy link
Member Author

shawaj commented Nov 22, 2021

@vpetersson created a PR in #264 to sort this

@marvinmarnold
Copy link
Contributor

Blocked by completion of: #272

vpetersson pushed a commit that referenced this issue Dec 2, 2021
* fix: revert privileged containers and add rockpi builds

- revert privileged containers based on discussion in #253
- add rockpi builds to testnet and production actions using build matrix
- with rockpi versions, change the i2c bus to i2c-7 in docker-compose
- remove hard coded balena cli version and change to env variable

* feat: bump hm-diag for RockPi support

bump hm-diag to pull in NebraLtd/hm-diag#238

* fix: bump pktfwd and correct if statements

- bump pktfwd to bring in sx1302 fixes
- correct if statements in previous commits

* add space

* fix(diagnostics): expose serial-number

By adding /proc to container for
/proc/device-tree/serial-number

* Added env var DIAGNOSTICS_VERSION to hold hm-diag git hash and updated hm-diag git hash to point to a commit that contains operational /version endpoint

* Bumped FIRMWARE_VERSION to 2021.11.26.1

* feat: better detect BT devices and LTE devices

* feat: bump gateway-config version

* fix: match DIAGNOSTICS_VERSION with latest version

* fix: update FIRMWARE_VERSION

* feat: remove session bus in diagnostics

* Update push-to-prod.yml

* Update push-to-testnet.yml

* fix: add fail fast false to production

add fail fast false

* fix: add fail fast false to testnet

add fail fast false

* fix: temporarily move diagnostics to privileged

This is a temporary fix to resolve the issue described in #281 so that @NebraLtd/tech-support can continue testing other recent changes

* fix: bump diagnostics to fix rockpi provisioning

relates to NebraLtd/hm-diag#260

* Update miner to latest GA 2021.11.30.1

Co-authored-by: Aaron Shaw <[email protected]>
Co-authored-by: Marvin Arnold <[email protected]>
Co-authored-by: Kashif Iftikhar <[email protected]>
Co-authored-by: Kashif Iftikhar <[email protected]>
Co-authored-by: Zhang <[email protected]>
Co-authored-by: mr-bump <[email protected]>
Co-authored-by: Marvin Arnold <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants