When running the Akita agent in a Docker container built for a different architecture than the host (e.g. built for amd64 but running on arm64), the agent fails to read any network interfaces with error messages of the form SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: Function not implemented
.
This PR extends the agent to detect these errors and print a nicer error message for the user that indicates the underlying problem. It also adds the target architecture to the akita --version
output, e.g. akita version 0.21.18 (09c7847085262f10ea9e2cd4bae280383970e5c1-dirty, arm64)
.
When running in Docker, the CLI output will look like this:
> docker run -e AKITA_API_KEY_ID -e AKITA_API_KEY_SECRET akitasoftware/cli:latest apidump --project akibox
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
[INFO] Akita Agent 0.21.18-rc4
[WARNING] Skipping interface eth0 for collecting packets because of error: failed to read packets from interface eth0: eth0: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: Function not implemented
[WARNING] Skipping interface lo for collecting packets because of error: failed to read packets from interface lo: lo: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: Function not implemented
[WARNING] The agent received "Function not implemented" when trying to read from your network interfaces. This often indicates that the Akita agent was built for a different architecture than your host architecture. This Akita agent binary was built for arm64.
[ERROR] No network interfaces could be used: Unable to read network interfaces. If your host architecture is not arm64, try using `docker pull --platform $YOUR_ARCHITECTURE akitasoftware/cli:latest` to pull an Akita agent built for your architecture.
When not in Docker, the last error message will instead read:
[ERROR] No network interfaces could be used: Unable to read network interfaces. If your host architecture is not arm64, try downloading an Akita agent built for your architecture from https://github.com/akitasoftware/akita-cli/releases.
Testing
I tested this by building a CLI docker image on arm64 and running it on an amd64 macOS laptop.