Fix receiver port object parsing; Console 3.1.27

This commit is contained in:
Andrei Smaliak 2026-10-25 10:12:06 +01:00
parent 4cab7580a0
commit a1750061d9
9 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,10 @@
# Edge Console 3.1.27
- Fix the 3.1.26 enrollment validator to consume the actual receiver response:
each named port is an object containing local, remote and available fields.
Persist remote; do not require availability before starting the tunnel.
- Retain support for scalar port assignments and reject missing, invalid and
duplicate remote ports before changing configuration.
- Add regression coverage using the observed EVA response, including offline
endpoints and invalid nested port values. All 127 Console tests pass.
- On g-box-8e6af561, enrollment successfully applied ports 34589/34590/34591.

View File

@ -14,7 +14,7 @@
"version": "1.0.1" "version": "1.0.1"
}, },
"stage_ui": { "stage_ui": {
"version": "3.1.26" "version": "3.1.27"
}, },
"stage_avahi": { "stage_avahi": {
"version": "1.0.0" "version": "1.0.0"

View File

@ -60,7 +60,7 @@ APP_DIR = "/opt/iomatex-console"
PUBLIC_DIR = os.path.join(APP_DIR, "public") PUBLIC_DIR = os.path.join(APP_DIR, "public")
PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d") PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d")
CONFIG_PATH = "/etc/iomatex/console.json" CONFIG_PATH = "/etc/iomatex/console.json"
UI_VERSION = "V 3.1.26" UI_VERSION = "V 3.1.27"
STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health" STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health"
ZONEINFO_ROOT = "/usr/share/zoneinfo" ZONEINFO_ROOT = "/usr/share/zoneinfo"

View File

@ -567,6 +567,11 @@ def _validate_reverse_tunnel_ports(ports):
result = {} result = {}
for name in ("cockpit", "z2m", "webui"): for name in ("cockpit", "z2m", "webui"):
value = ports.get(name) value = ports.get(name)
# Receiver contract returns endpoint metadata; availability can be false
# until enrollment starts the tunnel. Only the assigned remote port is
# configuration; never confuse it with the local service port.
if isinstance(value, dict):
value = value.get("remote")
if isinstance(value, bool) or not re.fullmatch(r"[0-9]{1,5}", str(value or "")): if isinstance(value, bool) or not re.fullmatch(r"[0-9]{1,5}", str(value or "")):
raise RuntimeError("Environment returned an invalid reverse tunnel port: " + name) raise RuntimeError("Environment returned an invalid reverse tunnel port: " + name)
value = int(value) value = int(value)

View File

@ -118,7 +118,7 @@ class ReverseTunnelConfigurationTest(unittest.TestCase):
response = Mock() response = Mock()
response.read.return_value = json.dumps({"reverse_tunnel": { response.read.return_value = json.dumps({"reverse_tunnel": {
"ssh_host": "gateway.example.com", "ssh_port": 2222, "ssh_host": "gateway.example.com", "ssh_port": 2222,
"ssh_user": "iomatex-tunnel", "ports": {"cockpit": 34589, "z2m": 34590, "webui": 34591}, "ssh_user": "iomatex-tunnel", "ports": {"cockpit": {"local": 9090, "remote": 34589, "available": False}, "z2m": {"local": 8081, "remote": 34590, "available": False}, "webui": {"local": 8099, "remote": 34591, "available": False}},
}}).encode() }}).encode()
context = Mock() context = Mock()
context.__enter__ = Mock(return_value=response) context.__enter__ = Mock(return_value=response)

View File

@ -29,6 +29,16 @@ class RegistrationTunnelSwitchTest(unittest.TestCase):
output = subprocess.check_output([str(root / ("iomatex-rt-" + name + ".sh"))], env=env, text=True) output = subprocess.check_output([str(root / ("iomatex-rt-" + name + ".sh"))], env=env, text=True)
self.assertIn("127.0.0.1:%s:127.0.0.1:%s" % (remote, local), output) self.assertIn("127.0.0.1:%s:127.0.0.1:%s" % (remote, local), output)
def test_receiver_endpoint_objects_use_remote_ports_even_when_offline(self):
ports = {"cockpit": {"local": 9090, "remote": 34589, "available": False},
"webui": {"local": 8099, "remote": 34591, "available": False},
"z2m": {"local": 8081, "remote": 34590, "available": False}}
self.assertEqual({"cockpit": 34589, "z2m": 34590, "webui": 34591},
registration._validate_reverse_tunnel_ports(ports))
for invalid in ({"local": 9090}, {"remote": True}, {"remote": 65536}):
with self.subTest(value=invalid), self.assertRaises(RuntimeError):
registration._validate_reverse_tunnel_ports(dict(ports, cockpit=invalid))
def test_invalid_server_ports_are_rejected(self): def test_invalid_server_ports_are_rejected(self):
valid = {"cockpit": 34589, "z2m": 34590, "webui": 34591} valid = {"cockpit": 34589, "z2m": 34590, "webui": 34591}
for bad in (None, True, 0, 65536, "12; reboot", 34590): for bad in (None, True, 0, 65536, "12; reboot", 34590):

View File

@ -49,7 +49,7 @@
{ mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" }, { mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" },
{ mode: "custom", label: "Custom", host: "" } { mode: "custom", label: "Custom", host: "" }
]; ];
const UI_VERSION = "V 3.1.26"; const UI_VERSION = "V 3.1.27";
const ITSCREEN_LOG_INITIAL_LINES = 50; const ITSCREEN_LOG_INITIAL_LINES = 50;
const ITSCREEN_LOG_BUFFER_LIMIT = 300; const ITSCREEN_LOG_BUFFER_LIMIT = 300;
const ITSCREEN_LOG_BATCH_MS = 250; const ITSCREEN_LOG_BATCH_MS = 250;

View File

@ -23,7 +23,7 @@
} catch (error) {} } catch (error) {}
})(); })();
</script> </script>
<link rel="stylesheet" href="/console.css?v=3.1.26&amp;rev=edge-runtime-profile-1"> <link rel="stylesheet" href="/console.css?v=3.1.27&amp;rev=edge-runtime-profile-1">
</head> </head>
<body> <body>
<main class="shell"> <main class="shell">
@ -109,7 +109,7 @@
</main> </main>
<div id="menuBackdrop" class="menuBackdrop" hidden></div> <div id="menuBackdrop" class="menuBackdrop" hidden></div>
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div> <div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
<script src="/console.i18n.js?v=3.1.26&amp;rev=edge-runtime-profile-1"></script> <script src="/console.i18n.js?v=3.1.27&amp;rev=edge-runtime-profile-1"></script>
<script src="/console.js?v=3.1.26&amp;rev=edge-runtime-profile-1"></script> <script src="/console.js?v=3.1.27&amp;rev=edge-runtime-profile-1"></script>
</body> </body>
</html> </html>

View File

@ -1,3 +1,3 @@
{ {
"version": "3.1.26" "version": "3.1.27"
} }