-
Notifications
You must be signed in to change notification settings - Fork 339
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
Implement Network Settings for Ubuntu Core - closes #3155 #3168
Implement Network Settings for Ubuntu Core - closes #3155 #3168
Conversation
ac18d67
to
514ff5b
Compare
I think I've been working on this long enough that I should probably get someone to start reviewing it! Sorry this is such a huge patch but it made sense to do it all in one go. @tim-hellhake I would value your input on this if you have time to review, if not let me know and I will try to find someone. Note that the build is currently failing in CI because the dbus npm package needs libdbus to build (libdbus-1-dev apt package on Debian-based distros). I'm not exactly sure where to add that in the GitHub Action. Maybe https://github.com/WebThingsIO/gateway/blob/master/.github/workflows/build.yml#L33 ? But I feel like apt packages may be installed somewhere else as well. If you want to give this a test drive then it should work on Ubuntu Deskop if you build from source locally as normal (need to Generating a snap package from this branch to test on Ubuntu Desktop is a bit more involved but if you want to try it:
The snap currently runs on port 8080 by default. The same snap should run on Ubuntu Core on the same architecture. |
README.md
Outdated
<!-- | ||
- On Fedora, Debian, Raspberry Pi OS, or Ubuntu, you can install the relevant .rpm or .deb package from the [releases page](https://github.com/WebThingsIO/gateway/releases). | ||
- On Arch Linux, you can install the [webthings-gateway AUR package](https://aur.archlinux.org/packages/webthings-gateway/). The PKGBUILD for this package can also be seen [here](https://github.com/WebThingsIO/gateway-aur). | ||
- Otherwise, you can build it from source yourself (see below). | ||
--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would delete this part completely
c9ea074
to
2c5068b
Compare
@tim-hellhake Thanks for the review! I addressed your comment and managed to get it to build in CI by adding the DBus dependency to the GitHub Action via apt. However, for some reason the integration tests appear to all pass but then the task times out after 6 hours! Any ideas what might be going on there? |
It does appear to be something in this PR which is causing the tests to time out, but I'm a bit stuck figuring out what it is. The actual tests seem to pass but then jest times out and eventually gets killed. The only idea I've had so far is that Dbus.getBus() is keeping something open that is preventing Jest from finishing. Maybe rather than opening that when the class is instantiated there should be some kind of init() method on Platform which is called when needed... but I'm really just guessing. |
Edit: I got the integration tests passing locally on master on Ubuntu Desktop after running |
Ugh, getting the node-dbus npm package (added as a dependency in this PR) to build on MacOS may be challenging. At the moment it won't build because node-dbus needs libdbus in order to compile the package using node-gyp. I tried installing dbus with
I tried installing glib with I'm currently stuck at that point, so haven't been able to reproduce the integration test failures on Mac OS, but also it currently means if we landed this PR as-is the gateway would no longer build on Mac OS. |
OK, it's not super pretty but I've managed to get jest to close properly by disconnecting the system bus after all the tests have run. That's what I think was keeping the Node process running. I'm going to take another look at getting this to build on Mac OS before merging. |
I've managed to get DBus to build on Mac OS, by installing python3 and dbus via brew, and then adding the bundled versionless binary symlinks to my path in order to symlink
After doing this However, the gateway currently fails to start with
This is all a bit silly because DBus isn't actually needed when running on Mac OS, so I was tempted to just add it as an optional dependency and not install node-dbus on Mac OS, but then we need to add fallbacks in the code and I'm not sure what other problems that might cause. I'll try to take another look tomorrow, but any ideas welcome. |
I'm just guessing but after researching this a bit further I think the issue here might be that I'm trying to build it on a MacBook Pro with Apple silicon (i.e. arm64 architecture), and there isn't a native version of Node.js 10 for arm64. The missing symbols may be due to node-gyp compiling native dependencies for the x64 architecture and then trying to run them on the arm64 architecture. I tried working around this by running Terminal using Rosetta (to emulate i386), but it didn't work. This maybe another thing that gets fixed when we finish upgrading to Node.js 20 in #3142 (since there are arm64 builds of newer versions of Node.js). I'm not sure whether to wait for that upgrade (which could still take a while) before landing this PR, or just go ahead and land this PR in the interests of moving forward, and accept that builds on newer MacBooks will be broken for a while. @tim-hellhake Do you have any thoughts? |
Some good news is that having finally got WebThings Gateway to run on Node.js 20, I've discovered that it is upgraded the architecture mismatch problem is no longer an issue. However, even when DBus compiles for the right architecture and I start the DBus service with I think rather than trying to get DBus to run on macOS where it's not actually needed, we need to just stop the gateway trying to use DBus when running on macOS. The reason it currently does this is that the NetworkManager class opens a (single) connection to the system bus when it is instantiated, and the way that platform implementations are currently loaded means that they are all instantiated on start. I need to try and do some re-factoring so that the gateway only tries to connect to DBus if it's actually running on Ubuntu or Ubuntu Core... |
fe96b18
to
19f4653
Compare
OK I've managed to fix the macOS builds by refactoring the platform code to only try to open a connection to the DBus system bus on demand when NetworkManager is actually using it (which I should really have done in the first place), so now it will run properly on macOS. Phewf. I've added some notes to the README to explain how to get it to build on macOS since libdbus is still needed as a build time dependency. @tim-hellhake Rather than kick off another review cycle I'm going to squash this and land it so I can move on to getting the Node.js 20 upgrade landed, but feel free to let me know if there's anything you think I should have done differently and I can address that in a follow-up. |
19f4653
to
ed85f42
Compare
Closes #3155
This PR implements a back end for network settings which works inside a snap running on Ubuntu or Ubuntu Core. It configures network settings using NetworkManager via its DBus API.
Previously all the Platform methods were synchronous but this introduces optional asynchronous versions of those methods.
The snap will require the
network-manager
andsystem-observe
snap interfaces, which must be connected in order for it to work.