fix-windows-init #74
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "fix-windows-init"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Problem
On Windows machines with slow boot times, the agent's network interface
detection could time out (hard limit of 300 seconds) before the network
stack had finished configuring. When that happened the module raised an
exception, was removed from the active module list, and never retried —
leaving the machine unregistered until the service was manually restarted.
The workaround was to configure the Windows service with a delayed start.
The same race condition can also occur on Linux (if systemd starts the
service before DHCP assigns an address) and on macOS (the LaunchDaemon
plist has no network dependency).
Solution
onActivation()now returns immediately after reading config andcreating the REST client, then launches a daemon thread (
setup_thread)that retries network detection indefinitely until an interface with
a routable IP is found, then registers with ogcore.
pythoncom.CoInitialize()is called at thread start sothat the WMI-based
getNetworkInfo()works correctly outside the mainthread (fixes
CO_E_NOTINITIALIZED/-2147221008).if self.interfaceguards inonDeactivation(),onLogin()andonLogout()to preventAttributeErrorif those events fire beforethe interface is detected.
How to test
Disable-NetAdapter -Name "Ethernet" -Confirm:$false).with ogcore once the interface appears.