bitsy-ai / printnanny-os

Image repository, change logs, and issue tracking for PrintNanny OS
GNU Affero General Public License v3.0
23 stars 2 forks source link

Edge NATS requests/subscriber do not correctly handle Raspberry Pis with mixed case hostnames #238

Closed leigh-johnson closed 1 year ago

leigh-johnson commented 1 year ago

Describe the bug

Naming your Raspberry Pi with a mixed-case hostname (e.g. raspberryPi) will result in 503 errors from the `printnanny-edge-nats.service.

This is because the NATS subscriber will attempt to subscribe on the hostname with exact casing:

Feb  2 19:56:35 raspberryPi printnanny-nats[22280]: [2023-02-03T01:56:35Z WARN  printnanny_nats::subscriber] Listening on nats://localhost:4223 where subject=pi.raspberryPi.>

But the front-end UI code publishes messages to window.location.hostname, which is always lowercase: https://github.com/bitsy-ai/printnanny-os-dash/blob/main/src/types/nats.ts#LL36C33-L36C33

To Reproduce

What are the steps to reproduce the issue?

  1. Create PrintNanny OS image with hostname: raspberryPi
  2. Open Mission Control dashboard
  3. Notice: 503 error is returned, which indicates NATS subscriber is unavailable
  4. Run systemctl status printnanny-edge-nats.service
  5. Notice: edge NATS subscriber is available, but is only subscribed to messages with subject pattern pi.raspberryPi.>
  6. Notice: ui publishes messages with subject pattern: pi.raspberrypi

Expected behavior

Hostname case should not impact PrintNanny OS services

Issue.txt

-----------------------
Build Info:  |
-----------------------
IMAGE_NAME = printnanny-release-image-raspberrypi4-64-20230202052633
DISTRO_PRETTY = PrintNanny Linux 0.6.2 (Feldspar)
VARIANT_NAME = PrintNanny OS Core
VARIANT_ID = core
DISTRO = printnanny
DISTRO_NAME = PrintNanny Linux
DISTRO_VERSION = 0.6.2
DISTRO_CODENAME = Feldspar
ID_LIKE = BitsyLinux
HOME_URL = https://printnanny.ai
BUG_REPORT_URL = https://github.com/bitsy-ai/printnanny-os/issues
YOCTO_VERSION = 4.1.2
YOCTO_CODENAME = Langdale
MACHINE = raspberrypi4-64
TUNE_PKGARCH = cortexa72
-----------------------
Layer Revisions:      |
-----------------------
meta              = langdale:f59aa3752dbc5552469207894bea9c01bd68fb6e
meta-poky         = langdale:f59aa3752dbc5552469207894bea9c01bd68fb6e
meta-yocto-bsp    = langdale:f59aa3752dbc5552469207894bea9c01bd68fb6e
meta-raspberrypi  = langdale-libcamera-fix:99f5a91d9d4b34ff8c214cf61cd12f375da1a76a
meta-oe           = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-python       = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-multimedia   = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-bitsy        = main:3483ea5157e7d612154d7cda67715c11056ddabf
meta-neural-network = mickledore:f19fa74c2f4c868eda1c48d709b66848f9cca5e8
meta-printnanny   = main:3483ea5157e7d612154d7cda67715c11056ddabf
meta-networking   = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-filesystems  = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-initramfs    = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-webserver    = langdale:f8cb46d803190bb02085c8a7d20957a71d32f311
meta-swupdate     = mickledore:c47a10be18412919f4c7041be05509ba97ac79f4
meta-microcontroller = mickledore:a848733698649628d0c3e34ae04ced0ee6ce3aee
leigh-johnson commented 1 year ago

LGTM :shipit:

Nov 08 06:00:42 camelPi systemd[1]: Started PrintNanny NATS worker.
Nov 08 06:00:42 camelPi printnanny-edge-nats[654]: [2022-11-08T14:00:42Z INFO  printnanny_nats::subscriber] Attempting to initialize NATS connection to nats://localhost:4223
Nov 08 06:00:42 camelPi printnanny-edge-nats[654]: [2022-11-08T14:00:42Z INFO  async_nats::options] event: connected
Nov 08 06:00:42 camelPi printnanny-edge-nats[654]: [2022-11-08T14:00:42Z WARN  printnanny_nats::subscriber] Subscribing to subect pi.camelpi.> with nats client Some(Client { info: Receiver { shared: Shared { v>
Nov 08 06:00:42 camelPi printnanny-edge-nats[654]: [2022-11-08T14:00:42Z WARN  printnanny_nats::subscriber] Listening on nats://localhost:4223 where subject=pi.camelpi.>