-
Notifications
You must be signed in to change notification settings - Fork 179
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
fix(update-server): Avoid bricking when given a bad name #10219
Conversation
Codecov Report
@@ Coverage Diff @@
## edge #10219 +/- ##
=======================================
Coverage 74.72% 74.72%
=======================================
Files 2111 2111
Lines 55691 55702 +11
Branches 5635 5635
=======================================
+ Hits 41616 41626 +10
- Misses 12915 12916 +1
Partials 1160 1160
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
This looks good to me behavior wise and is well commented, nice.
if the pretty hostname could not be written. | ||
""" | ||
try: | ||
# We can't run `hostnamectl --pretty <name>` to write this for us |
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.
jfyi - this is to do with the way these files are stored, as I recall. The inode we get when we open("/etc/machine-info")
in this program is stored in /var/
and bind-mounted onto /etc/machine-info
. That bind happens after systemd somehow caches what you get when you open /etc/machine-info
at boot time before the bind-mount, which is read-only. This is why we use this style here, and I think I went with using the file directly for consistency in other places also.
We definitely could test this more by slightly restructuring or mocking to use various weird /etc/machine-info
files captured from robots.
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.
Ahh thanks, that’s super helpful. Maybe there’s a way to get it working by adjusting when systemd-hostnamed
starts, so it caches the correct thing. I’ll play around with it.
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 tried a couple approaches to working around this today, but I didn't get anywhere.
- I tried doing
systemctl restart systemd-hostnamed
before doinghostnamectl --pretty
in hopes that it would pick up our file in/var
instead of the underlying file in/etc
, but that didn't change anything. - I tried editing
/usr/lib/systemd/system/systemd-hostnamed.service
to expand itsReadWritePaths
from/etc
to/etc /etc/machine-info /var/machine-info
, but that didn't change anything.
I'm not sure this has to do with caching. I think it might have to do with the way systemd-hostnamed
tries to overwrite the file. I suspect it tries to atomically place a new file at the /etc/machine-info
path instead of modifying the file that's already there, and I guess that doesn't work with bind mounts? Here's a Stack Exchange question I just asked about part of it. 🤷
Resolve conflicts in: * update-server/tests/common/test_name_management.py * update-server/otupdate/openembedded/__init__.py
Overview
This PR fixes bugs related to the update server's rename functionality.
Changelog
Refactors
Primarily:
Fix #9960
At a high level, the shape of this bug was like this:
See #9960 (comment) for more details.
The solution in this PR is twofold:
Fix #10198
Quick fix. When a request isn't valid JSON, we now handle it gracefully by returning an HTTP 400 error with a descriptive message.
Review requests
robot-server
. I'm sure we could make it set up for testability, but refactors have their own risks.Testing
A couple parts of this unfortunately must be tested on a real robot, since they interact with several system processes.
Before beginning testing, I strongly recommend making sure you have SSH access set up on your OT-2, in case you have to recover from a brick.
Testing that robot renaming still works, in general
Send a name to the robot.
Examples of names that should work:
otie
Hello World
👉😎👉
Make sure the new name shows up in the Opentrons App. On macOS, you can also make sure it's correctly advertising itself over mDNS + DNS-SD by monitoring
dns-sd -B
. You should see the exact name that you sent.Testing that this solved #9960
1234567890123456789012345678901234567890123456789012345678901234567890
(70 digits, 70 bytes)名名名名名名名名名名名名名名名名名名名名名名名名名名名名名名
(30 kanji, 90 bytes when encoded as UTF-8)systemctl restart opentrons-update-server
.systemctl status opentrons-update-server
orjournalctl --boot
.)dns-sd -B
.Risk assessment
High. This code is difficult to meaningfully cover by tests because it depends heavily on interaction with external system stuff. The highest-risk code is the stuff in
__main__.py
and__init.py__
. If that goes wrong somehow, it will prevent the update server from starting up, and leave a robot bricked except by heavy intervention.