I’ve followed the instructions for using container contracts as defined in: Container contracts - Balena Documentation
However there are unmet requirements with the following contract.yml:
type: “sw.container”
slug: “enforce-raspberrypicm4-ioboard”
name: “Enforce running on Raspbery Pi CM4 IO Board”
requires:
- type: “hw.device-type”
version: “==raspberrypicm4-ioboard”
- type: “sw.supervisor”
version: “>=11.1.0”
Specifically, the hw.device-type is always unmet and does not update my containers to the new release. The documentation is a bit sketchy so where ‘version’ is specified for hw.device-type I’ve tried all variations that seems reasonable: “raspberrypicm4-ioboard”, “=raspberrypicm4-ioboard”, “==raspberrypicm4-ioboard” and none of those ‘versions’ are ever satisfied.
The Fleet/Device absolutely use raspberrypicm4-ioboard. This is reflected in the BALENA_DEVICE_TYPE environment variable and is used in the Dockerfile via %BALENA_MACHINE_NAME% so the issue is not because the device-type is unsatisfied.
Thanks
Kirk Ocke
1 Like
Hi Kirk,
I’ve spent some time looking into this - starting from zero knowledge, since I’d never actually used container contracts myself.
First, I agree the documentation could do with improving. I had to go and look at code to find how the device type requirement should be defined. And I can confirm it should be "raspberrypicm4-ioboard"
without any =
signs.
Could you just test this once more?
If this still doesn’t work, then I will try and set up a test. I don’t have a CM4 to try, so my plan would be:
- create a generic AARCH64 fleet
- add a Pi4 and a Jetson Nano to the fleet
- deploy code with a contract restricting a service to hw.device-type
raspberrypi4-64
- push an update
I expect the Pi4 to update all services, but the nano to not update the service with the contract.
Does that sound like a representative test?
Phil
Hi Phil,
I just tested again using the following contract.yml:
type: "sw.container"
slug: "enforce-raspberrypicm4-ioboard"
name: "Enforce supervisor and hardware requirements"
requires:
- type: "sw.supervisor"
version: ">=11.1.0"
- type: "hw.device-type"
version: "raspberrypicm4-ioboard"
When pushing to a fleet with raspberrypicm4-ioboard hardware I get:
Could not move to new release: Some releases were rejected due to having unmet requirements …
This is the same behavior as previously described.
I believe the test you’ve outlined is representative of what I’m experiencing.
Thanks
Kirk
OK Kirk - thanks for testing it again. I’ll try and run my experiment, but you’ll have to bear with me as it might take me a few days.
Phil
Thanks and if it takes a few days no worries here
–Kirk
Kirk,
Sorry it took me so long to get back to you.
I have run my test, and found what I think is the issue. Up front: the documentation is not very clear here, and might be incorrect in places - so I have asked internally how we should go about updating or rewriting it.
What I found with my tests, is that your contract shouldn’t have a version
field for the device type requirement, it should be a name
field. This is the contract I used:
type: "sw.container"
slug: "enforce-raspberrypi4-64"
name: "Enforce hardware requirements"
requires:
- type: "hw.device-type"
name: "raspberrypi4-64"
This contract saw my optional container run on a Pi4 but not downloaded at all on a PiZero2 in the same fleet.
Please could you give that a try, and let me know if that fixes the issue for you?
Phil
Hi Phil,
I’ve tested using ‘name’ instead of ‘version’ and it works.
Thanks so much
Kirk
1 Like