Procházet zdrojové kódy

fix(firmware): update the stored target after an owut upgrade (#1825) (#1833)

Nacho před 1 měsícem
rodič
revize
2d566a29c4
2 změnil soubory, kde provedl 8 přidání a 0 odebrání
  1. 1 0
      CHANGELOG.md
  2. 7 0
      server-go/internal/httpapi/firmware_owut.go

+ 1 - 0
CHANGELOG.md

@@ -39,6 +39,7 @@ y este proyecto se adhiere a [Versionado Semántico](https://semver.org/lang/es/
 
 ### Fixed
 
+- An owut upgrade that finishes updates the stored firmware target (#1825). The target row only got the new version from the agent callback, so a unit upgraded through the owut flow kept showing the previous version on every surface that reads the stored column while the board already reported the new one. The confirmation after the reboot now writes the version the board reports.
 - A locally administered MAC with no address and no lease is no longer remembered (#1818). The NMRP address a Netgear unit announces while it reboots to flash firmware never asks for an IP, so nothing but the memory of the previous cycle kept it in the client list with a lease that did not exist. The entry is still persisted as soon as it has an address, a DHCP lease or a previous record, so virtual machines and phones with MAC randomisation are untouched.
 - Locally administered MACs are recognised by the server itself (#1818). The flag only came from the agent discovery scan, a snapshot taken at one moment, so a MAC that lives in the switch FDB for a few seconds (the NMRP address a Netgear unit announces while it reboots to flash firmware) was never marked and entered the client list as an unknown device. The bit is now read from the address, so those entries are identifiable even when discovery never saw them.
 - Rotating the agent token now reaches the configuration the agent actually reads (#1816). The packaged init prefers the UCI config and only falls back to the environment file when the UCI token is empty, while the rotation rewrote the environment file alone. A router that still carried a token from an older install kept pushing with it and got a 401 on every cycle, forever, while SSH polling made it look healthy. The hot rotation now writes server, slug and token through `uci` when the config file is present, before restarting the service.

+ 7 - 0
server-go/internal/httpapi/firmware_owut.go

@@ -429,6 +429,13 @@ func (s *server) awaitReboot(id int64, routerID, target, origin, from string) {
 		time.Sleep(owutRebootPoll)
 		if v := s.detectedFirmwareVersion(routerID); (target != "" && v == target) || (target == "" && v != "" && v != from) {
 			_ = s.firmware.SetStatus(id, "done", "", "")
+			// #1825: el flujo owut no pasa por el callback del agente, así
+			// que el target guardado se quedaba con la versión anterior. Se
+			// actualiza aquí, con la que acaba de confirmar el board.
+			if t, _ := s.firmware.GetTarget(routerID); t != nil && v != "" {
+				t.CurrentVersion = v
+				_ = s.firmware.SetTarget(*t)
+			}
 			s.emitFirmwareResult(routerID, from, target, origin, true, "")
 			return
 		}