manta-node 0.6b6.dev850__py3-none-any.whl → 0.6b6.dev854__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ This file is auto-generated at build time by scripts/generate_version.py.
4
4
  Do not edit manually.
5
5
  """
6
6
 
7
- __version__ = "2026.11.13.086befb4"
8
- __build_date__ = "2026.11.13"
9
- __commit_id__ = "086befb4"
7
+ __version__ = "2026.11.17.ce93ad77"
8
+ __build_date__ = "2026.11.17"
9
+ __commit_id__ = "ce93ad77"
10
10
  __package_version__ = "0.6b6" # release-series base, moved by scripts/bump_version.py
@@ -138,11 +138,13 @@ class CommandHandler(Collector, MqttBase):
138
138
  Runtime broker role username (caller-sourced; not persisted).
139
139
  mqtt_password : Optional[str]
140
140
  Runtime broker role password (caller-sourced; not persisted).
141
+ Both may be None only with ``certificate_broker`` set.
141
142
  certificate_broker : Optional[CertificateBroker]
142
143
  The node's own broker certificate and its listener (#546). When set,
143
144
  the handler connects there with the certificate and no username or
144
- password, and falls back to the password listener when the broker
145
- does not accept the certificate or it is no longer in date.
145
+ password. When the broker does not accept the certificate or it is no
146
+ longer in date, the handler falls back to the password listener, or,
147
+ with no password given, stops the node with the reason (#555).
146
148
  """
147
149
 
148
150
  def __init__(
@@ -183,9 +185,13 @@ class CommandHandler(Collector, MqttBase):
183
185
  self._certificate_connect_failures = 0
184
186
  self._connected_once = False
185
187
 
186
- # Required in certificate mode too: the password listener is the
187
- # fallback whenever the certificate is not accepted.
188
- if not mqtt_username or not mqtt_password:
188
+ # A certificate-only node has neither; a node with a password keeps the
189
+ # password listener as its fallback whenever the certificate fails.
190
+ has_password = bool(mqtt_username and mqtt_password)
191
+ self._certificate_only = (
192
+ certificate_broker is not None and not mqtt_username and not mqtt_password
193
+ )
194
+ if not has_password and not self._certificate_only:
189
195
  raise MantaNodeError(
190
196
  "MQTT broker username and password must both be provided"
191
197
  )
@@ -237,8 +243,8 @@ class CommandHandler(Collector, MqttBase):
237
243
  if inspect.isawaitable(result):
238
244
  await result
239
245
 
240
- # Before the password-path checks below, which stop the node: in
241
- # certificate mode no connect error may stop it.
246
+ # Before the password-path checks below: in certificate mode only the
247
+ # certificate rules decide whether a connect error stops the node.
242
248
  if self._certificate_broker is not None:
243
249
  self._on_certificate_connect_error(exc)
244
250
  return
@@ -263,8 +269,10 @@ class CommandHandler(Collector, MqttBase):
263
269
  def _on_certificate_connect_error(self, exc: Exception) -> None:
264
270
  """Fall back to the password listener when the certificate cannot work.
265
271
 
266
- Never stop the node over its certificate: the next start would find the
267
- same certificate in date and fail again, a crash loop under a supervisor.
272
+ A node with a password never stops over its certificate: the next start
273
+ would find the same certificate in date and fail again, a crash loop
274
+ under a supervisor. A certificate-only node stops instead, so a refused
275
+ certificate is reported rather than hidden.
268
276
  """
269
277
  broker = cast(CertificateBroker, self._certificate_broker)
270
278
  if not BrokerCertificateStore(broker.folder).has_usable_certificate(
@@ -301,6 +309,10 @@ class CommandHandler(Collector, MqttBase):
301
309
  )
302
310
 
303
311
  def _fall_back_to_password_listener(self, reason: str) -> None:
312
+ if self._certificate_only:
313
+ message = f"MQTT: {reason}; the node has no broker password and stops"
314
+ self.tracer.error(message)
315
+ raise MantaNodeError(message)
304
316
  self.tracer.warning(
305
317
  f"MQTT: {reason}; using the broker password at {self._password_address}"
306
318
  )
@@ -158,15 +158,28 @@ def _find_tls_error(error: BaseException) -> ssl.SSLError | None:
158
158
  return None
159
159
 
160
160
 
161
- def _mqtt_broker_credentials_from_env() -> tuple[str, str]:
162
- """Return the broker role credential pair from the runtime environment."""
161
+ class _NoNodeCertificate(Exception):
162
+ """Why the node has no usable broker certificate."""
163
+
164
+
165
+ def _mqtt_broker_credentials_from_env(
166
+ certificate_only_allowed: bool,
167
+ ) -> tuple[str, str] | None:
168
+ """Return the broker role credential pair from the runtime environment.
169
+
170
+ None means a certificate-only node: neither variable is set and
171
+ ``certificate_only_allowed`` (``security.node_certificate``) is on. A node
172
+ with only one of the two set is misconfigured, never certificate-only.
173
+ """
163
174
  username = os.getenv(MQTT_BROKER_USERNAME_ENV)
164
175
  password = os.getenv(MQTT_BROKER_PASSWORD_ENV)
165
- if not username or not password:
166
- raise NodeFatalError(
167
- "MQTT broker username and password must both be set before startup"
168
- )
169
- return username, password
176
+ if username and password:
177
+ return username, password
178
+ if certificate_only_allowed and not username and not password:
179
+ return None
180
+ raise NodeFatalError(
181
+ "MQTT broker username and password must both be set before startup"
182
+ )
170
183
 
171
184
 
172
185
  def reserve_available_port(
@@ -515,7 +528,18 @@ class Node:
515
528
  NodeFatalError
516
529
  If MQTT client unreacheable or gRPC error occurs
517
530
  """
518
- mqtt_username, mqtt_password = _mqtt_broker_credentials_from_env()
531
+ credentials = _mqtt_broker_credentials_from_env(
532
+ certificate_only_allowed=self.config.security.node_certificate
533
+ )
534
+ certificate_only = credentials is None
535
+ mqtt_username: str | None = None
536
+ mqtt_password: str | None = None
537
+ if credentials is not None:
538
+ mqtt_username, mqtt_password = credentials
539
+ else:
540
+ self.tracer.info(
541
+ "No broker password is set; the node connects with its certificate only"
542
+ )
519
543
  await self.check_manager_availability()
520
544
  try:
521
545
  version_info = get_full_version_info()
@@ -579,7 +603,7 @@ class Node:
579
603
  # After the node client holds the node token: the certificate call
580
604
  # names the node by that token.
581
605
  certificate_broker = await self._certificate_broker(
582
- registration, node_token
606
+ registration, node_token, certificate_only=certificate_only
583
607
  )
584
608
 
585
609
  # Ensure light service port is assigned
@@ -655,6 +679,14 @@ class Node:
655
679
  # Create asyncio tasks and start them
656
680
  self.command_loop = asyncio.create_task(self.command_handler.main())
657
681
  self.light_server_task = asyncio.create_task(self.server.wait_closed())
682
+ except NodeFatalError:
683
+ # The startup error is the reason the node gives; a failure while
684
+ # stopping must never replace it.
685
+ try:
686
+ await self.stop()
687
+ except Exception:
688
+ self.tracer.exception("Stopping the node after a failed start failed")
689
+ raise
658
690
  except ConnectionRefusedError:
659
691
  self.tracer.exception("Unable to start and connect to MQTT Message Broker")
660
692
  raise NodeFatalError(
@@ -693,33 +725,48 @@ class Node:
693
725
  raise NodeFatalError(f"[ERROR] {message}") from exc
694
726
 
695
727
  async def _certificate_broker(
696
- self, registration: Registration, node_token: str
728
+ self, registration: Registration, node_token: str, certificate_only: bool
697
729
  ) -> CertificateBroker | None:
698
730
  """The certificate listener with a usable node certificate, or None for
699
731
  the password path.
700
732
 
701
733
  With ``security.node_certificate`` on, a node that holds no usable
702
- certificate requests one over its node token (#546). Every failure
703
- returns None: the node then connects with the broker password, as with
704
- the flag off.
734
+ certificate requests one over its node token (#546). A node with a
735
+ broker password takes the password path on every failure, as with the
736
+ flag off. A ``certificate_only`` node has no password path, so every
737
+ failure stops it with the reason (#555).
738
+
739
+ Raises
740
+ ------
741
+ NodeFatalError
742
+ A ``certificate_only`` node has no usable certificate.
705
743
  """
706
744
  if not self.config.security.node_certificate:
707
745
  return None
746
+ try:
747
+ return await self._obtain_certificate_broker(registration, node_token)
748
+ except _NoNodeCertificate as reason:
749
+ if certificate_only:
750
+ message = (
751
+ f"{reason}; the node has no broker password and cannot connect"
752
+ )
753
+ self.tracer.error(message)
754
+ raise NodeFatalError(f"[ERROR] {message}") from None
755
+ self.tracer.warning(f"{reason}; using the broker password")
756
+ return None
757
+
758
+ async def _obtain_certificate_broker(
759
+ self, registration: Registration, node_token: str
760
+ ) -> CertificateBroker:
708
761
  if not (
709
762
  registration.mqtt_certificate_broker_host
710
763
  and registration.mqtt_certificate_broker_port
711
764
  ):
712
- self.tracer.info(
713
- "The manager offers no certificate listener; using the broker password"
714
- )
715
- return None
765
+ raise _NoNodeCertificate("The manager offers no certificate listener")
716
766
 
717
767
  node_id = node_id_from_token(node_token)
718
768
  if node_id is None:
719
- self.tracer.warning(
720
- "The node token carries no node id; using the broker password"
721
- )
722
- return None
769
+ raise _NoNodeCertificate("The node token carries no node id")
723
770
  store = BrokerCertificateStore(
724
771
  Path(self.config.security.node_certificate_folder).expanduser()
725
772
  )
@@ -747,10 +794,7 @@ class Node:
747
794
  issued.certificate_pem or "", issued.certificate_chain_pem or ""
748
795
  )
749
796
  except (MantaError, OSError, ValueError, TypeError) as error:
750
- self.tracer.warning(
751
- f"No node certificate ({error}); using the broker password"
752
- )
753
- return None
797
+ raise _NoNodeCertificate(f"No node certificate ({error})") from error
754
798
  self.tracer.info(f"Node certificate issued and stored in {store.folder}")
755
799
  return broker
756
800
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: manta_node
3
- Version: 0.6b6.dev850
3
+ Version: 0.6b6.dev854
4
4
  Summary: Node side software of the Manta platform. It is responsible for the communication with the Manta Core and the execution of the tasks.
5
5
  Author-email: Hugo Miralles <hugo.miralles@manta-tech.io>, Matthew Thompson <matthew.thompson@manta-tech.io>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -1,13 +1,13 @@
1
1
  manta_node/__init__.py,sha256=bgGWXH3yQVhNf0v1ZGUBAy5Y51fqb0Y-EaLnocbcino,153
2
2
  manta_node/__main__.py,sha256=SjrJyuMg_ZFKV6WOVe3MrtWM8Qmu065dkKZYl4n2YLw,1665
3
- manta_node/node_orchestrator.py,sha256=d6oPblvea4dJ8mwezRUtExg-XxkKWpbD9hml4O_uCeo,33056
3
+ manta_node/node_orchestrator.py,sha256=wWg7mGfocw_vHvqJb62gFkETjt9VPn0jtKxCGXhMJQY,34981
4
4
  manta_node/seam.py,sha256=nGLjNVlSrnRJPdrp7L8piyJai1bQveiqT5JDBWeFeGI,6501
5
5
  manta_node/task_manager.py,sha256=xRE-yKdUW0FFR8vtX1jDwl1AxTbqVD_JS7QVR62GA00,38002
6
6
  manta_node/tasks.py,sha256=o837Hi-KFVJg9LF5iOtE8oD6UuTOfrEPWR-JOdhRGeY,6983
7
7
  manta_node/update_path.py,sha256=6N_bN9z8MqnyWWfGTe1-aJFijf2tSy_IvO6VHvNSQVU,1667
8
8
  manta_node/utils.py,sha256=Hw4Iw2jYQYsfVLVJuBMt-_rMFBeml3nCDE2jiiXc8YM,1155
9
9
  manta_node/cli/__init__.py,sha256=arzO3mXDJ-E2yeeytbZfN7mCswwxdQ43_QjyeL2E5yE,134
10
- manta_node/cli/_version_generated.py,sha256=l_LAoTb-qg0rFstCDRbZ1bi2_MuQYo4yd0GlfolDQwM,332
10
+ manta_node/cli/_version_generated.py,sha256=3SH9TyOJarv27bw9B_385pakXVBhUoB3NnF4d951yOY,332
11
11
  manta_node/cli/config_manager.py,sha256=BCju9zqzraviL3KrzRnB-vZQUY__Q5kuEqb7EdB8YdI,4409
12
12
  manta_node/cli/main.py,sha256=dZa6zrypWBvpN8hd4qpxevvlyNFhxKINCg1537NJ36w,4318
13
13
  manta_node/cli/version.py,sha256=L4lNTz-Uw_ejumy1tXJcJhcjhb-5FRcRQ6ogZM5N1Xo,5136
@@ -42,7 +42,7 @@ manta_node/infrastructure/metrics/__init__.py,sha256=ODGAj9s63F5jba2c3dQRMfNK6I4
42
42
  manta_node/infrastructure/metrics/collector.py,sha256=9ESw__Pc2tV6ldG5yhos2IS7T5Td59KxTIwDRZc_G4w,3067
43
43
  manta_node/infrastructure/metrics/metrics_collector.py,sha256=osIYrNzU3g9WCAxVQ14isM9YEQ3eJ7F3QgKBbpgeMJs,13077
44
44
  manta_node/infrastructure/mqtt/__init__.py,sha256=riXo1sXgO4YV6DHCmWRqK61BAmuGLdHiVdQFunAJadA,140
45
- manta_node/infrastructure/mqtt/command_handler.py,sha256=CDrd6tHX8zs6z8cgdn3ymyRB-_0ebU1WQKZ4HhajWGo,42588
45
+ manta_node/infrastructure/mqtt/command_handler.py,sha256=AmnDPc8OyIJ4xdoZURq_MU-jJrnTlD5DVk0xZCfn_10,43308
46
46
  manta_node/infrastructure/network/__init__.py,sha256=On3XLgycFQoc-fBCa5hFuFDfEJjmFy7Wl2CK3D2LkdI,478
47
47
  manta_node/infrastructure/network/event_registry.py,sha256=iWEfUJRzDnWjOrDinpYqVyIUpGKJjp7RZkjMDPfpplM,1661
48
48
  manta_node/infrastructure/network/factory.py,sha256=-LvHbBp5nBpQ7fyQT1T0pvK3aczZqWc9QNDW37brBeU,3897
@@ -64,9 +64,9 @@ manta_node/supervisor/records.py,sha256=O1YjNN2bH1xzOJo_3l1G6FRvWo1CmdAfvSDJBj6s
64
64
  manta_node/supervisor/seam.py,sha256=4kczRku5Ctn4xRvXS-pyzaDFau7LnX5bYOn6IRNKRyE,9665
65
65
  manta_node/supervisor/sequence.py,sha256=eYu7rrk1ecc4Y2jQhhJ7CopPz3m0lOsFLJj5lT2PwBw,1685
66
66
  manta_node/supervisor/switch.py,sha256=PbWLNnRwQFhOBDAUSLcDwZsIW5jPHq_zNKIyS7Hd8C0,22342
67
- manta_node-0.6b6.dev850.dist-info/licenses/LICENSE,sha256=9mBgLhiB9goQPQjg9XQJ6FjgVxYw9Q8lyOZYkPGwF_c,34484
68
- manta_node-0.6b6.dev850.dist-info/METADATA,sha256=a9pjWNjneGUbd1InC_UirezNkTZbZiQN6asj5GCDysY,4937
69
- manta_node-0.6b6.dev850.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
70
- manta_node-0.6b6.dev850.dist-info/entry_points.txt,sha256=uCwggRApalLEsYs1YxwTBN0-e9oMJAkMoBp01HaSdoY,110
71
- manta_node-0.6b6.dev850.dist-info/top_level.txt,sha256=nbT5J5WETuXM9UPoQckl29uUOq8wMYdRb9QDx5kAFeo,11
72
- manta_node-0.6b6.dev850.dist-info/RECORD,,
67
+ manta_node-0.6b6.dev854.dist-info/licenses/LICENSE,sha256=9mBgLhiB9goQPQjg9XQJ6FjgVxYw9Q8lyOZYkPGwF_c,34484
68
+ manta_node-0.6b6.dev854.dist-info/METADATA,sha256=49j4690F4Tnr3xWPAg5271FSU9w6VqP5062Sb0EM2gs,4937
69
+ manta_node-0.6b6.dev854.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
70
+ manta_node-0.6b6.dev854.dist-info/entry_points.txt,sha256=uCwggRApalLEsYs1YxwTBN0-e9oMJAkMoBp01HaSdoY,110
71
+ manta_node-0.6b6.dev854.dist-info/top_level.txt,sha256=nbT5J5WETuXM9UPoQckl29uUOq8wMYdRb9QDx5kAFeo,11
72
+ manta_node-0.6b6.dev854.dist-info/RECORD,,