From 3b6362d9975c76f1532871c005ced2a083f790e5 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 29 Feb 2024 10:45:15 +0000
Subject: [PATCH] Rollout fixes v0.28.1

- Wait for FPGA to be booted before returning from power_hardware_on
- Use valid placeholders for unused MAC & destination IPs
---
 README.md                                           |  1 +
 infra/jobs/station/logging.levant.nomad             |  9 +++------
 tangostationcontrol/VERSION                         |  2 +-
 .../devices/base_device_classes/power_hierarchy.py  |  2 +-
 .../tangostationcontrol/devices/sdp/beamlet.py      | 13 ++++++++++---
 .../tangostationcontrol/devices/sdp/firmware.py     |  7 +++++++
 .../test/devices/sdp/test_beamlet_device.py         |  4 ++--
 7 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index b3c2deb1c..4ce91b47b 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,7 @@ Next change the version in the following places:
 
 # Release Notes
 
+* 0.28.2 Bugfixes / rollout fixes
 * 0.28.1 Bugfixes / rollout fixes
 * 0.28.0 Make `StationManager` device asynchronous
 * 0.27.2 Add new attributes in OPCUA devices
diff --git a/infra/jobs/station/logging.levant.nomad b/infra/jobs/station/logging.levant.nomad
index 8221d4770..998c57f41 100644
--- a/infra/jobs/station/logging.levant.nomad
+++ b/infra/jobs/station/logging.levant.nomad
@@ -55,7 +55,7 @@ job "log-scraping" {
         task "vector" {
             driver = "docker"
             config {
-                image = "timberio/vector:0.32.1.custom.989ad14-distroless-static"
+                image = "timberio/vector:0.37.0.custom.2ca601b-distroless-static"
                 ports = ["api"]
             }
             # docker socket volume mount
@@ -71,8 +71,8 @@ job "log-scraping" {
             }
             # resource limits are a good idea because you don't want your log collection to consume all resources available
             resources {
-                cpu    = 50 # 500 MHz
-                memory = 100 # 256MB
+                cpu    = 50
+                memory = 256
             }
             # template with Vector's configuration
             template {
@@ -119,9 +119,6 @@ healthchecks.require_healthy = true
     .nomad.task      = .label."com.hashicorp.nomad.task_name"
     .nomad.group     = .label."com.hashicorp.nomad.task_group_name"
     .nomad.namespace = .label."com.hashicorp.nomad.namespace"
-    .nomad.node      = .label."com.hashicorp.nomad.node_name"
-    .nomad.job_id    = .label."com.hashicorp.nomad.job_id"
-    .nomad.node_id   = .label."com.hashicorp.nomad.node_id"
 
     # delete labels that vary too much or are duplicates
     del(.label)
diff --git a/tangostationcontrol/VERSION b/tangostationcontrol/VERSION
index 48f7a71df..a37255a85 100644
--- a/tangostationcontrol/VERSION
+++ b/tangostationcontrol/VERSION
@@ -1 +1 @@
-0.28.1
+0.28.2
diff --git a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/power_hierarchy.py b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/power_hierarchy.py
index 8de3c9f59..5dd30f9cf 100644
--- a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/power_hierarchy.py
+++ b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/power_hierarchy.py
@@ -32,7 +32,7 @@ class PowerHierarchyDevice(AbstractHierarchyDevice):
 
     HIBERNATE_TIMEOUT = 60.0
     STANDBY_TIMEOUT = 300.0
-    ON_TIMEOUT = 300.0
+    ON_TIMEOUT = 600.0
 
     def init(
         self,
diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py b/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py
index 5f2fb24a6..4e8c5d781 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py
@@ -34,6 +34,7 @@ from tangostationcontrol.common.constants import (
 )
 
 # Additional import
+from tangostationcontrol.common.device_decorators import debugit
 from tangostationcontrol.common.lofar_logging import log_exceptions
 from tangostationcontrol.common.proxy import create_device_proxy
 from tangostationcontrol.common.sdp import phases_to_weights
@@ -650,12 +651,17 @@ class Beamlet(OPCUADevice):
             "FPGA_beamlet_output_nof_destinations_RW_default_shorthand"
         ]
 
-        default_settings = []
+        default_settings = [
+            ("FPGA_beamlet_output_nof_destinations_RW", [nof_destinations] * N_pn),
+        ]
 
         # Set MAC, IP, port
         for setting, value_if_undefined in [
-            ("FPGA_beamlet_output_multiple_hdr_eth_destination_mac_RW", ""),
-            ("FPGA_beamlet_output_multiple_hdr_ip_destination_address_RW", ""),
+            (
+                "FPGA_beamlet_output_multiple_hdr_eth_destination_mac_RW",
+                "00:00:00:00:00:00",
+            ),
+            ("FPGA_beamlet_output_multiple_hdr_ip_destination_address_RW", "0.0.0.0"),
             ("FPGA_beamlet_output_multiple_hdr_udp_destination_port_RW", 0),
         ]:
             # obtain shorthand description (first values per fpga)
@@ -680,6 +686,7 @@ class Beamlet(OPCUADevice):
         # report effective number of output destinations
         return self.read_attribute("FPGA_beamlet_output_nof_destinations_act_R")
 
+    @debugit()
     def write_FPGA_beamlet_output_nof_destinations_RW(self, value):
         old_FPGA_processing_enable = self.sdp_proxy.FPGA_processing_enable_RW
         try:
diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py b/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
index f024dab26..8fa13ef5c 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/firmware.py
@@ -359,6 +359,13 @@ class SDPFirmware(OPCUADevice):
             self.Firmware_Boot_timeout,
         )
 
+        # Wait for the new image to be booted
+        self.wait_attribute(
+            "TR_fpga_communication_error_R",
+            lambda attr: (~attr | ~wait_for).all(),
+            self.Firmware_Boot_timeout,
+        )
+
     def _power_hardware_on(self):
         """Boot the SDP Firmware user image"""
 
diff --git a/tangostationcontrol/test/devices/sdp/test_beamlet_device.py b/tangostationcontrol/test/devices/sdp/test_beamlet_device.py
index f8b1c74ed..062113ed1 100644
--- a/tangostationcontrol/test/devices/sdp/test_beamlet_device.py
+++ b/tangostationcontrol/test/devices/sdp/test_beamlet_device.py
@@ -135,11 +135,11 @@ class TestBeamletDevice(base.TestCase):
 
         self.assertListEqual(
             defaults["FPGA_beamlet_output_multiple_hdr_eth_destination_mac_RW"],
-            [MACs + [""] * (N_bdo_destinations_mm - 4)] * N_pn,
+            [MACs + ["00:00:00:00:00:00"] * (N_bdo_destinations_mm - 4)] * N_pn,
         )
         self.assertListEqual(
             defaults["FPGA_beamlet_output_multiple_hdr_ip_destination_address_RW"],
-            [IPs + [""] * (N_bdo_destinations_mm - 4)] * N_pn,
+            [IPs + ["0.0.0.0"] * (N_bdo_destinations_mm - 4)] * N_pn,
         )
         self.assertListEqual(
             defaults["FPGA_beamlet_output_multiple_hdr_udp_destination_port_RW"],
-- 
GitLab