Conversation
| """Collect IO counters in bytes. Call inside oneshot().""" | ||
| try: | ||
| io = proc.io_counters() | ||
| io = proc.io_counters() # type: ignore[attr-defined] # not available on macOS |
There was a problem hiding this comment.
my mypy wouldn't pass without this.
Greptile SummaryThis PR fixes a macOS-specific bug where users were prompted to "apply system changes?" on every execution of Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant D as dimos run
participant C as MulticastConfiguratorMacOS.check()
participant NS as netstat -nr
participant F as MulticastConfiguratorMacOS.fix()
participant RD as route delete -net 224.0.0.0/4
participant RA as route add -net 224.0.0.0/4 -interface lo0
D->>C: check()
C->>NS: netstat -nr
NS-->>C: routing table (224.0.0.0/4 on en0 or missing)
C-->>D: False (no lo0 route found)
D->>F: fix()
F->>RD: sudo route delete -net 224.0.0.0/4 (check=False)
note over RD: Removes stale en0 route if present.<br/>Silently ignored if no route exists.
RD-->>F: returncode (ignored)
F->>RA: sudo route add -net 224.0.0.0/4 -interface lo0 (check=True)
RA-->>F: returncode=0 (success)
note over D,RA: Next execution
D->>C: check()
C->>NS: netstat -nr
NS-->>C: 224.0.0.0/4 on lo0 found
C-->>D: True (no prompt, no fix needed)
Last reviewed commit: be17a5f |
| # Delete any existing 224.0.0.0/4 route (e.g. on en0) before adding on lo0, | ||
| # otherwise `route add` fails with "route already in use" | ||
| sudo_run( | ||
| "route", | ||
| "delete", | ||
| "-net", | ||
| self.MULTICAST_PREFIX, | ||
| check=False, | ||
| text=True, | ||
| capture_output=True, | ||
| ) |
There was a problem hiding this comment.
Route delete placed in the wrong class
The route delete is inside BufferConfiguratorMacOS.fix(), but the corresponding route add -net 224.0.0.0/4 -interface lo0 lives in MulticastConfiguratorMacOS.fix(). These two classes check and fix entirely independent conditions, so they are not guaranteed to both run in the same session.
A concrete failure scenario:
- The buffer sysctl values need updating →
BufferConfiguratorMacOS.check()returnsFalse→BufferConfiguratorMacOS.fix()runs and deletes the224.0.0.0/4route. - The multicast route is already correct on
lo0→MulticastConfiguratorMacOS.check()returnsTrue→MulticastConfiguratorMacOS.fix()is never called. - Result: the valid multicast route has been silently removed, breaking LCM until the next reboot.
The fix should live in MulticastConfiguratorMacOS.fix(), right before the route add, so that the delete and re-add are always atomic:
# in MulticastConfiguratorMacOS.fix()
def fix(self) -> None:
# Delete any existing 224.0.0.0/4 route (e.g. on en0) before adding on lo0,
# otherwise `route add` fails with "route already in use"
sudo_run(
"route",
"delete",
"-net",
"224.0.0.0/4",
check=False,
text=True,
capture_output=True,
)
sudo_run(*self.add_route_cmd, check=True, text=True, capture_output=True)The route delete was in BufferConfiguratorMacOS.fix(), but the corresponding route add lives in MulticastConfiguratorMacOS.fix(). If only buffer settings needed updating, the valid multicast route would be silently deleted without being re-added.
|
@greptile |
Problem
I would get the "apply system changes?" every time on MacOS (not just every reboot but every execution)
Solution
Run a command to correctly set the multicast value on systems that already have a value set
Breaking Changes
Should be none, tested on summer's mac and mine.
How to Test
(should only get asked questions once per reboot)
Contributor License Agreement