netboot 0.2.2__tar.gz → 0.2.3__tar.gz

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.
Files changed (67) hide show
  1. {netboot-0.2.2 → netboot-0.2.3}/CHANGELOG.md +13 -1
  2. {netboot-0.2.2 → netboot-0.2.3}/PKG-INFO +1 -1
  3. {netboot-0.2.2 → netboot-0.2.3}/pyproject.toml +1 -1
  4. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/AGENTS.md +6 -6
  5. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/engine.py +29 -30
  6. {netboot-0.2.2 → netboot-0.2.3}/tests/test_engine_robustness.py +27 -16
  7. {netboot-0.2.2 → netboot-0.2.3}/.gitignore +0 -0
  8. {netboot-0.2.2 → netboot-0.2.3}/AGENTS.md +0 -0
  9. {netboot-0.2.2 → netboot-0.2.3}/LICENSE +0 -0
  10. {netboot-0.2.2 → netboot-0.2.3}/README.md +0 -0
  11. {netboot-0.2.2 → netboot-0.2.3}/benchmarks/README.md +0 -0
  12. {netboot-0.2.2 → netboot-0.2.3}/benchmarks/bench_netboot.py +0 -0
  13. {netboot-0.2.2 → netboot-0.2.3}/benchmarks/results/netboot.json +0 -0
  14. {netboot-0.2.2 → netboot-0.2.3}/docs/api.md +0 -0
  15. {netboot-0.2.2 → netboot-0.2.3}/docs/changelog.md +0 -0
  16. {netboot-0.2.2 → netboot-0.2.3}/docs/cli.md +0 -0
  17. {netboot-0.2.2 → netboot-0.2.3}/docs/configuration.md +0 -0
  18. {netboot-0.2.2 → netboot-0.2.3}/docs/extending.md +0 -0
  19. {netboot-0.2.2 → netboot-0.2.3}/docs/index.md +0 -0
  20. {netboot-0.2.2 → netboot-0.2.3}/examples/README.md +0 -0
  21. {netboot-0.2.2 → netboot-0.2.3}/examples/config/pixie.yaml +0 -0
  22. {netboot-0.2.2 → netboot-0.2.3}/examples/plugins/recording.py +0 -0
  23. {netboot-0.2.2 → netboot-0.2.3}/examples/templates/debian/boot.cfg +0 -0
  24. {netboot-0.2.2 → netboot-0.2.3}/examples/templates/debian/install.ks.j2 +0 -0
  25. {netboot-0.2.2 → netboot-0.2.3}/mkdocs.yml +0 -0
  26. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/__init__.py +0 -0
  27. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/__main__.py +0 -0
  28. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/_version.py +0 -0
  29. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/cmds/__init__.py +0 -0
  30. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/cmds/complete.py +0 -0
  31. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/cmds/initiate.py +0 -0
  32. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/content/__init__.py +0 -0
  33. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/__init__.py +0 -0
  34. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/dhcpd.py +0 -0
  35. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/dnsmasq.py +0 -0
  36. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/kea.py +0 -0
  37. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/options.py +0 -0
  38. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/dhcp/windhcp.py +0 -0
  39. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/logging.py +0 -0
  40. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/main.py +0 -0
  41. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/py.typed +0 -0
  42. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/templates/__init__.py +0 -0
  43. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/templates/common.py +0 -0
  44. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/templates/jinja.py +0 -0
  45. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/templates/shell.py +0 -0
  46. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/utils/__init__.py +0 -0
  47. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/utils/config.py +0 -0
  48. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/utils/dicts.py +0 -0
  49. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/utils/misc.py +0 -0
  50. {netboot-0.2.2 → netboot-0.2.3}/src/netboot/utils/net.py +0 -0
  51. {netboot-0.2.2 → netboot-0.2.3}/tests/conftest.py +0 -0
  52. {netboot-0.2.2 → netboot-0.2.3}/tests/test_api_contracts.py +0 -0
  53. {netboot-0.2.2 → netboot-0.2.3}/tests/test_cli.py +0 -0
  54. {netboot-0.2.2 → netboot-0.2.3}/tests/test_cli_discovery.py +0 -0
  55. {netboot-0.2.2 → netboot-0.2.3}/tests/test_config_discovery.py +0 -0
  56. {netboot-0.2.2 → netboot-0.2.3}/tests/test_content.py +0 -0
  57. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp.py +0 -0
  58. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp_dhcpd.py +0 -0
  59. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp_dnsmasq.py +0 -0
  60. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp_kea.py +0 -0
  61. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp_options.py +0 -0
  62. {netboot-0.2.2 → netboot-0.2.3}/tests/test_dhcp_windhcp.py +0 -0
  63. {netboot-0.2.2 → netboot-0.2.3}/tests/test_hooks.py +0 -0
  64. {netboot-0.2.2 → netboot-0.2.3}/tests/test_lookup.py +0 -0
  65. {netboot-0.2.2 → netboot-0.2.3}/tests/test_render.py +0 -0
  66. {netboot-0.2.2 → netboot-0.2.3}/tests/test_target.py +0 -0
  67. {netboot-0.2.2 → netboot-0.2.3}/tests/test_utils.py +0 -0
@@ -6,6 +6,17 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.3] - 2026-09-23
10
+
11
+ ### Fixed
12
+ - One DHCP server being offline no longer fails `pixie initiate` or
13
+ `pixie complete`. Arming is meant to be best effort, but since 0.2.0 it
14
+ stopped at the first failing server and rolled the others back. `initiate`
15
+ now tries every server in the zone, logs each failure as a warning, and fails
16
+ only when no server could be armed. `complete` logs a failing server as a
17
+ warning and still exits 0, so read the log if you need to know every server
18
+ was disarmed.
19
+
9
20
  ## [0.2.2] - 2026-09-21
10
21
 
11
22
  netboot moves to netimps 0.3.1 and yaconfiglib 0.13. If a plugin, hook or
@@ -543,7 +554,8 @@ First packaged release: the `netboot` library with the `pixie` command line.
543
554
  config value construction no longer swallows non-`TypeError` errors; repo
544
555
  `joinpath` keeps `.local` a path so chained joins work.
545
556
 
546
- [Unreleased]: https://github.com/jose-pr/netboot/compare/v0.2.2...HEAD
557
+ [Unreleased]: https://github.com/jose-pr/netboot/compare/v0.2.3...HEAD
558
+ [0.2.3]: https://github.com/jose-pr/netboot/compare/v0.2.2...v0.2.3
547
559
  [0.2.2]: https://github.com/jose-pr/netboot/compare/v0.2.1...v0.2.2
548
560
  [0.2.1]: https://github.com/jose-pr/netboot/compare/v0.2.0...v0.2.1
549
561
  [0.2.0]: https://github.com/jose-pr/netboot/compare/v0.1.3...v0.2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: netboot
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: PXE provisioning management: render netboot artifacts and drive DHCP for targets
5
5
  Project-URL: Homepage, https://github.com/jose-pr/netboot/
6
6
  Project-URL: Issues, https://github.com/jose-pr/netboot/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "netboot"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  authors = [{ name = "Jose A." }]
9
9
  description = "PXE provisioning management: render netboot artifacts and drive DHCP for targets"
10
10
  readme = "README.md"
@@ -150,12 +150,12 @@ is the same object. `netboot.netutils` remains an alias for
150
150
  process's working directory; an absolute path or a URI is used as given.
151
151
  - **`.pxe_init(netboot) -> Self`** / **`.pxe_complete(netboot) -> Self`** —
152
152
  arm/disarm every `dhcpzone.dhcpservers` for this context; called by
153
- `Pixie.initialize`/`.complete`, not usually invoked directly. `pxe_init`
154
- is **all or nothing**: if a backend raises, the ones already armed are
155
- rolled back before the error propagates, so a target is never left armed
156
- on some servers and not others. `pxe_complete` is the opposite — every
157
- backend is tried even if one fails, and the first error is raised
158
- afterwards, because stopping early would leave the rest armed.
153
+ `Pixie.initialize`/`.complete`, not usually invoked directly. Both try
154
+ every backend. `pxe_init` logs a backend that raises as a **warning** and
155
+ carries on; it raises (the first error) only when **no** backend could be
156
+ armed, and nothing is rolled back, so a target may end up armed on some
157
+ servers and not others. `pxe_complete` never raises for a backend: each
158
+ failure is logged as a warning and the rest are still disarmed.
159
159
 
160
160
  ## DHCP (`netboot.dhcp`)
161
161
 
@@ -7,6 +7,7 @@ whole implementation.
7
7
 
8
8
  import datetime
9
9
  import enum as _enum
10
+ import logging
10
11
  import typing as _ty
11
12
  from argparse import Namespace
12
13
  from copy import deepcopy
@@ -199,51 +200,49 @@ class PixieContext(Namespace):
199
200
  return self.repos.get(resource.src)
200
201
 
201
202
  def pxe_init(self, config: "Pixie"):
202
- """Arm every DHCP backend for this target, all or nothing.
203
+ """Arm every DHCP backend for this target, succeeding if any one does.
203
204
 
204
- A target armed on two of three backends is worse than one armed on
205
- none: it may boot into an installer from one server while another
206
- hands out its normal lease. So a failure rolls the already-armed
207
- backends back before re-raising.
205
+ Every backend is tried. A backend that fails is logged as a warning and
206
+ skipped, so one server being offline does not block the others; the
207
+ first error is raised only when no backend could be armed.
208
208
  """
209
- armed = []
209
+ first_error = None
210
+ armed = 0
210
211
  for dhcpserver in self.dhcpzone.dhcpservers:
211
212
  try:
212
213
  dhcpserver.add_target(self)
213
- except Exception:
214
- for done in reversed(armed):
215
- try:
216
- done.remove_target(self)
217
- except Exception: # keep unwinding; report the first cause
218
- LOGGER.exception(
219
- "rollback failed for %s on %s",
220
- self.target._id,
221
- getattr(done, "uri", done),
222
- )
223
- raise
224
- armed.append(dhcpserver)
214
+ except Exception as exc:
215
+ LOGGER.warning(
216
+ "could not arm %s on %s: %s",
217
+ self.target._id,
218
+ getattr(dhcpserver, "uri", dhcpserver),
219
+ exc,
220
+ exc_info=LOGGER.isEnabledFor(logging.DEBUG),
221
+ )
222
+ first_error = first_error or exc
223
+ else:
224
+ armed += 1
225
+ if first_error is not None and not armed:
226
+ raise first_error
225
227
  return self
226
228
 
227
229
  def pxe_complete(self, config: "Pixie"):
228
- """Disarm every DHCP backend, continuing past a failure.
230
+ """Disarm every DHCP backend; a failure is a warning, never an error.
229
231
 
230
- Cleanup is the opposite case from arming: stopping at the first error
231
- would leave the remaining backends armed, so every backend is tried and
232
- the first error is raised once they have all had their turn.
232
+ Every backend is tried, and one that fails is logged and skipped, so
233
+ the rest are still disarmed.
233
234
  """
234
- first_error = None
235
235
  for dhcpserver in self.dhcpzone.dhcpservers:
236
236
  try:
237
237
  dhcpserver.remove_target(self)
238
238
  except Exception as exc:
239
- LOGGER.exception(
240
- "could not disarm %s on %s",
239
+ LOGGER.warning(
240
+ "could not disarm %s on %s: %s",
241
241
  self.target._id,
242
242
  getattr(dhcpserver, "uri", dhcpserver),
243
+ exc,
244
+ exc_info=LOGGER.isEnabledFor(logging.DEBUG),
243
245
  )
244
- first_error = first_error or exc
245
- if first_error is not None:
246
- raise first_error
247
246
  return self
248
247
 
249
248
  def _template_names(self, suffix: Union[list[str], str], **options) -> list[str]:
@@ -706,7 +705,7 @@ class Pixie:
706
705
  def initialize(self, target: "PixieTarget"):
707
706
  """Arm DHCP for `target` and return its context.
708
707
 
709
- All or nothing: a backend that fails rolls back the ones already armed.
708
+ A backend that fails is a warning; it raises only if none could be armed.
710
709
  """
711
710
  target = self.hook(PixieEvent.StartPixieInitialize, target)
712
711
  ctx = self.make_context(target)
@@ -716,7 +715,7 @@ class Pixie:
716
715
  def complete(self, target: "PixieTarget"):
717
716
  """Disarm DHCP for `target` and return its context.
718
717
 
719
- Every backend is tried even if one fails; the first error is raised after.
718
+ Every backend is tried; one that fails is logged as a warning.
720
719
  """
721
720
  target = self.hook(PixieEvent.StartPixieComplete, target)
722
721
  ctx = self.make_context(target, require_image=False)
@@ -1,7 +1,7 @@
1
1
  """Engine behaviour under partly-broken input and partly-failing backends.
2
2
 
3
3
  Each case here is a crash or a silent wrong answer the 2026-09-17 review
4
- reproduced: a half-armed target, a retired image blocking cleanup, a global
4
+ reproduced: an offline DHCP server, a retired image blocking cleanup, a global
5
5
  that replaced the render context, a zone chosen by declaration order.
6
6
  """
7
7
 
@@ -61,28 +61,39 @@ class rollback(_Recorder): # scheme `rollback://`
61
61
  pass
62
62
 
63
63
 
64
- def test_a_failing_backend_rolls_back_the_ones_already_armed():
64
+ def test_arming_survives_a_failing_backend_with_a_warning(caplog):
65
65
  engine = _engine()
66
66
  zone = engine.dhcpzones["lan"]
67
- zone.dhcpservers[1].fail_on = "add"
68
- with pytest.raises(RuntimeError):
67
+ zone.dhcpservers[0].fail_on = "add"
68
+ with caplog.at_level(logging.WARNING, logger="netboot"):
69
69
  engine.initialize(engine.lookup_target("host1"))
70
- # b failed, so a must not be left armed.
71
- assert _Recorder.calls == [
72
- ("arm", "rollback://a"),
73
- ("arm", "rollback://b"),
74
- ("disarm", "rollback://a"),
75
- ]
70
+ # a is offline; b is still armed and nothing is rolled back.
71
+ assert _Recorder.calls == [("arm", "rollback://a"), ("arm", "rollback://b")]
72
+ assert "could not arm host1 on rollback://a" in caplog.text
76
73
 
77
74
 
78
- def test_disarm_continues_past_a_failure_then_raises():
75
+ def test_arming_raises_when_every_backend_fails():
79
76
  engine = _engine()
80
- zone = engine.dhcpzones["lan"]
81
- zone.dhcpservers[0].fail_on = "remove"
82
- with pytest.raises(RuntimeError):
77
+ for server in engine.dhcpzones["lan"].dhcpservers:
78
+ server.fail_on = "add"
79
+ with pytest.raises(RuntimeError, match="rollback://a refused to arm"):
80
+ engine.initialize(engine.lookup_target("host1"))
81
+ assert _Recorder.calls == [("arm", "rollback://a"), ("arm", "rollback://b")]
82
+
83
+
84
+ def test_disarm_failures_are_warnings(caplog):
85
+ engine = _engine()
86
+ for server in engine.dhcpzones["lan"].dhcpservers:
87
+ server.fail_on = "remove"
88
+ with caplog.at_level(logging.WARNING, logger="netboot"):
83
89
  engine.complete(engine.lookup_target("host1"))
84
- # The second backend is still disarmed despite the first failing.
85
- assert ("disarm", "rollback://b") in _Recorder.calls
90
+ # Every backend is tried, and none of the failures is raised.
91
+ assert _Recorder.calls == [
92
+ ("disarm", "rollback://a"),
93
+ ("disarm", "rollback://b"),
94
+ ]
95
+ assert "could not disarm host1 on rollback://a" in caplog.text
96
+ assert "could not disarm host1 on rollback://b" in caplog.text
86
97
 
87
98
 
88
99
  def test_complete_works_when_the_image_is_no_longer_configured(caplog):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes