From d6185e01837fd87e91d1253ed5560b0befc1b261 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 25 Feb 2024 13:13:36 -0500 Subject: [PATCH 1/2] #433 use os.clock instead of util.time_s for coordinator connection timeout to supervisor --- coordinator/coordinator.lua | 10 +++++----- coordinator/startup.lua | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/coordinator/coordinator.lua b/coordinator/coordinator.lua index 5ed4a99..0054436 100644 --- a/coordinator/coordinator.lua +++ b/coordinator/coordinator.lua @@ -302,7 +302,7 @@ function coordinator.comms(version, nic, sv_watchdog) if not self.sv_linked then if self.est_tick_waiting == nil then - self.est_start = util.time_s() + self.est_start = os.clock() self.est_last = self.est_start self.est_tick_waiting, self.est_task_done = @@ -310,10 +310,10 @@ function coordinator.comms(version, nic, sv_watchdog) _send_establish() else - self.est_tick_waiting(math.max(0, LINK_TIMEOUT - (util.time_s() - self.est_start))) + self.est_tick_waiting(math.max(0, LINK_TIMEOUT - (os.clock() - self.est_start))) end - if abort or (util.time_s() - self.est_start) >= LINK_TIMEOUT then + if abort or (os.clock() - self.est_start) >= LINK_TIMEOUT then self.est_task_done(false) if abort then @@ -336,9 +336,9 @@ function coordinator.comms(version, nic, sv_watchdog) elseif self.sv_config_err then coordinator.log_comms("supervisor unit count does not match coordinator unit count, check configs") ok = false - elseif (util.time_s() - self.est_last) > 1.0 then + elseif (os.clock() - self.est_last) > 1.0 then _send_establish() - self.est_last = util.time_s() + self.est_last = os.clock() end elseif self.est_tick_waiting ~= nil then self.est_task_done(true) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index e974f18..844be1c 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.2.5" +local COORDINATOR_VERSION = "v1.2.6" local println = util.println local println_ts = util.println_ts From f9917b786c4a07e2368be01d7b6bf2b20423b559 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 25 Feb 2024 18:02:13 -0500 Subject: [PATCH 2/2] #432 wait 20s on computer power on before assuming monitor configuration problem --- coordinator/startup.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 844be1c..268bec3 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,9 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.2.6" +local COORDINATOR_VERSION = "v1.2.7" + +local CHUNK_LOAD_DELAY_S = 20.0 local println = util.println local println_ts = util.println_ts @@ -41,6 +43,25 @@ local log_crypto = coordinator.log_crypto ppm.mount_all() local loaded, monitors = coordinator.load_config() + +-- if the computer just started, its chunk may have just loaded (...or the user rebooted) +-- if monitor config failed, maybe an adjacent chunk containing all or part of a monitor has not loaded yet, so keep trying +while loaded == 2 and os.clock() < CHUNK_LOAD_DELAY_S do + term.clear() + term.setCursorPos(1, 1) + println("There was a monitor configuration problem at boot.\n") + println("Startup will keep trying every 2s in case of chunk load delays.\n") + println(util.sprintf("The configurator will be started in %ds if all attempts fail.\n", math.max(0, CHUNK_LOAD_DELAY_S - os.clock()))) + println("(exit early with ctrl-t)") + +---@diagnostic disable-next-line: undefined-field + os.sleep(2) + + -- remount and re-attempt + ppm.mount_all() + loaded, monitors = coordinator.load_config() +end + if loaded ~= 0 then -- try to reconfigure (user action) local success, error = configure.configure(loaded, monitors)