FreeNAS/freenas 13649a3src/middlewared/middlewared/plugins/alert alert.py runtime.py

Restructure alert plugin to the lean typesafe layout

## Problem
The alert plugin passed mypy but didn't follow the typesafe convention the other converted plugins use: the eponymous `alert` service lived in `alert.py` as an 1100-line `Service` with all logic, models, and helpers inline, `__init__.py` was empty, and the two sibling services each combined their service class and service part in one off-convention file.

## Solution
- Move `AlertService` into a lean `__init__.py` that exposes only the endpoint stubs; each delegates to plain functions in `lifecycle.py` / `runtime.py` / `oneshot.py` / `queries.py` that take `(context, state)`.
- Lift all mutable runtime state into a dedicated `AlertState` object (`state.py`) built once in `__init__`. Concurrency is intentionally unchanged — it still relies on the asyncio event loop plus the existing `process_alerts` job lock, with no new lock introduced.
- Pull the standalone pieces into `state.py`, `alert_classes.py`, and `serialize.py`, and split the siblings into `alertservice.py` / `alertservice_crud.py` and `alertclasses.py` / `alertclasses_config.py` to match the `*_crud.py` / `*_config.py` convention.
- Move the inline `AlertOneshotDelete` models into the API package, and update `main.py` imports plus the setup-ordering key (`alert.alert` -> `alert`, since `setup()` now lives in the package `__init__`).
DeltaFile
+0-1,108src/middlewared/middlewared/plugins/alert/alert.py
+454-0src/middlewared/middlewared/plugins/alert/runtime.py
+0-226src/middlewared/middlewared/plugins/alert/service.py
+217-0src/middlewared/middlewared/plugins/alert/__init__.py
+212-0src/middlewared/middlewared/plugins/alert/queries.py
+145-0src/middlewared/middlewared/plugins/alert/alertservice.py
+1,028-1,33410 files not shown
+1,642-1,41616 files

FreeNAS/freenas d524944src/middlewared/middlewared/api/v27_0_0 reporting.py

v27 pydantic changes
DeltaFile
+10-5src/middlewared/middlewared/api/v27_0_0/reporting.py
+10-51 files

FreeNAS/freenas b9fba81src/middlewared/middlewared/api/v26_0_0 reporting.py, src/middlewared/middlewared/plugins/reporting graphs.py

Remove stale ARC graph names from reporting API

## Problem
`reporting.get_data` accepted three graph names — `arcrate`, `arcactualrate`, `arcresult` — whose backing plugin classes were deleted during the ZFS netdata plugin rewrite. The Pydantic `Literal` and the in-memory `__graphs` dict drifted out of sync, so passing any of them crashed `netdata_get_data` with an uncaught `KeyError`.

## Solution
Removed the dead names from `GraphIdentifier.name`'s `Literal` and docstring in both `v26_0_0/reporting.py` and `v27_0_0/reporting.py`. Added a `ReportingNetdataGetDataArgs.from_previous` on each so legacy WS clients walking the adapter chain get the dead entries silently filtered instead of a hard rejection at the final v27 boundary. Hardened the dispatch site in `plugins/reporting/graphs.py` to raise `CallError(ENOENT)` for any unknown name — mirroring what `netdata_graph` already does — so future schema/implementation drift surfaces as a clean RPC error rather than an unhandled exception.
DeltaFile
+68-0src/middlewared/middlewared/pytest/unit/api/handler/version/test_reporting_graph_filter.py
+10-5src/middlewared/middlewared/api/v26_0_0/reporting.py
+4-1src/middlewared/middlewared/plugins/reporting/graphs.py
+82-63 files

FreeNAS/freenas fb76afesrc/middlewared/middlewared/plugins support.py

return an error when the debug is too large
DeltaFile
+14-1src/middlewared/middlewared/plugins/support.py
+14-11 files

FreeNAS/freenas 7d7d11csrc/middlewared/middlewared/plugins/device_ vrrp_events.py, src/middlewared/middlewared/plugins/failover_ event.py

Process BACKUP in vrrp rapid-succession branch

When VrrpEventThread saw a second rapid event after waiting
rapid_event_settle_time, it dropped the latest queued event and
logged a warning. On boot-time keepalived flaps where the
MASTER->BACKUP gap floors below max_wait, that drop swallowed
the only BACKUP signal middleware was going to see, so
vrrp_backup never ran.

Fire the hook for BACKUP (skipping if vrrp_backup already ran
this process lifetime, tracked via a new LAST_EVENT_TYPE
attribute on FailoverEventsService); keep the drop+warn for
MASTER, since acting on an unsettled MASTER would kick off
fenced + zpool import.
DeltaFile
+31-1src/middlewared/middlewared/plugins/device_/vrrp_events.py
+16-0src/middlewared/middlewared/plugins/failover_/event.py
+47-12 files

FreeNAS/freenas 9c8597asrc/middlewared/middlewared/plugins support.py

log messages
DeltaFile
+25-1src/middlewared/middlewared/plugins/support.py
+25-11 files

FreeNAS/freenas fbdb724src/middlewared/middlewared/utils/nvmet spdk.py

Wait for bdev to actually disappear after delete

spdk_bdev_unregister's cb_fn (which sends the RPC reply) fires before
spdk_bdev_close(desc) in spdk_bdev_unregister_by_name, so bdev_aio_delete
can return while the underlying close(fd) on the zvol is still pending.
DeltaFile
+37-3src/middlewared/middlewared/utils/nvmet/spdk.py
+37-31 files

FreeNAS/freenas ce3ccccsrc/middlewared/middlewared/pytest/unit/utils test_cpu_temperatures.py test_cpu_info_impl.py, src/middlewared/middlewared/utils sensors.py cpu.py

Merge branch 'master' of https://github.com/truenas/middleware into NAS-135885
DeltaFile
+733-206src/middlewared/middlewared/pytest/unit/utils/test_cpu_temperatures.py
+0-481src/middlewared/middlewared/utils/sensors.py
+347-0src/middlewared/middlewared/utils/cpu/hwmon.py
+329-0src/middlewared/middlewared/pytest/unit/utils/test_cpu_info_impl.py
+0-232src/middlewared/middlewared/utils/cpu.py
+231-0src/middlewared/middlewared/utils/cpu/temperatures.py
+1,640-91916 files not shown
+2,310-1,04322 files

FreeNAS/freenas 2c6478dsrc/middlewared/middlewared/pytest/unit datastore_harness.py test_get_or_insert.py, src/middlewared/middlewared/pytest/unit/plugins conftest.py test_crud_query_extend_order_by.py

improper use of conftest.py
DeltaFile
+51-0src/middlewared/middlewared/pytest/unit/datastore_harness.py
+0-51src/middlewared/middlewared/pytest/unit/plugins/conftest.py
+1-1src/middlewared/middlewared/pytest/unit/plugins/test_crud_query_extend_order_by.py
+1-1src/middlewared/middlewared/pytest/unit/plugins/test_datastore.py
+1-1src/middlewared/middlewared/pytest/unit/plugins/test_interface_link_address.py
+1-1src/middlewared/middlewared/pytest/unit/test_get_or_insert.py
+55-556 files

FreeNAS/freenas 0e54674src/middlewared/middlewared/pytest/unit test_get_or_insert.py, src/middlewared/middlewared/pytest/unit/plugins test_interface_link_address.py

correct imports
DeltaFile
+1-1src/middlewared/middlewared/pytest/unit/plugins/test_interface_link_address.py
+1-1src/middlewared/middlewared/pytest/unit/test_get_or_insert.py
+2-22 files

FreeNAS/freenas f4f07e4src/middlewared/middlewared/plugins/truenas_connect finalize_registration.py

NAS-140333 / 26.0.0-RC.1 / Treat terminal TNC finalize errors as failure (by sonicaj) (#19041)

This commit wires the registration finalization loop through the shared
classifier from truenas_connect_utils, so a 400 with a non-retryable
error code now sets REGISTRATION_FINALIZATION_FAILED and exits instead
of polling fruitlessly until the 45-minute claim token expires. Network
errors, 5xx, 408, 429 and the pending-registration "not found" case
still retry with the existing backoff. Adds unit tests for the
classifier.

Original PR: https://github.com/truenas/middleware/pull/19036

Co-authored-by: Waqar Ahmed <waqarahmedjoyia at live.com>
DeltaFile
+31-31src/middlewared/middlewared/plugins/truenas_connect/finalize_registration.py
+31-311 files

FreeNAS/freenas 5fdcd44src/middlewared/middlewared/pytest/unit/plugins test_datastore.py

noqa imports unneeded (everything initialized in conftest.py now)
DeltaFile
+0-4src/middlewared/middlewared/pytest/unit/plugins/test_datastore.py
+0-41 files

FreeNAS/freenas 7c85538src/middlewared/middlewared/pytest/unit/plugins conftest.py test_datastore.py

move `datastore_test` to conftest.py
DeltaFile
+51-0src/middlewared/middlewared/pytest/unit/plugins/conftest.py
+1-44src/middlewared/middlewared/pytest/unit/plugins/test_datastore.py
+3-31src/middlewared/middlewared/pytest/unit/plugins/test_crud_query_extend_order_by.py
+55-753 files

FreeNAS/freenas 398843asrc/middlewared/middlewared/plugins/truenas_connect finalize_registration.py

Treat terminal TNC finalize errors as failure

This commit wires the registration finalization loop through the shared classifier from truenas_connect_utils, so a 400 with a non-retryable error code now sets REGISTRATION_FINALIZATION_FAILED and exits instead of polling fruitlessly until the 45-minute claim token expires. Network errors, 5xx, 408, 429 and the pending-registration "not found" case still retry with the existing backoff. Adds unit tests for the classifier.
DeltaFile
+31-31src/middlewared/middlewared/plugins/truenas_connect/finalize_registration.py
+31-311 files

FreeNAS/freenas 8200210

Empty commit to create PR on github.

You should reset it
DeltaFile
+0-00 files

FreeNAS/freenas 719c64dsrc/middlewared/middlewared/plugins/truenas_connect finalize_registration.py

NAS-140333 / 27.0.0-BETA.1 / Treat terminal TNC finalize errors as failure (#19036)

This commit wires the registration finalization loop through the shared
classifier from truenas_connect_utils, so a 400 with a non-retryable
error code now sets REGISTRATION_FINALIZATION_FAILED and exits instead
of polling fruitlessly until the 45-minute claim token expires. Network
errors, 5xx, 408, 429 and the pending-registration "not found" case
still retry with the existing backoff. Adds unit tests for the
classifier.
DeltaFile
+34-33src/middlewared/middlewared/plugins/truenas_connect/finalize_registration.py
+34-331 files

FreeNAS/freenas b97ab4bsrc/middlewared/middlewared/plugins/truenas_connect finalize_registration.py

Treat terminal TNC finalize errors as failure

This commit wires the registration finalization loop through the shared classifier from truenas_connect_utils, so a 400 with a non-retryable error code now sets REGISTRATION_FINALIZATION_FAILED and exits instead of polling fruitlessly until the 45-minute claim token expires. Network errors, 5xx, 408, 429 and the pending-registration "not found" case still retry with the existing backoff. Adds unit tests for the classifier.
DeltaFile
+34-33src/middlewared/middlewared/plugins/truenas_connect/finalize_registration.py
+34-331 files

FreeNAS/freenas 459760esrc/middlewared/middlewared/pytest/unit/utils test_cpu_temperatures.py test_cpu_info_impl.py, src/middlewared/middlewared/utils sensors.py cpu.py

NAS-140739 / 27.0.0-BETA.1 / Rewrite CPU temperature reading via sysfs hwmon (#18922)

## Problem

The legacy CPU temperature pipeline (`utils/cpu.py` +
`utils/sensors.py`) consumed `libsensors` via a 481-line ctypes wrapper
and attributed temperatures to logical CPUs using ordinal arithmetic and
string-sort heuristics rather than kernel topology. Several real defects
followed.

** 1.5× over-reported aggregate on AMD APUs (Ryzen 7 5825U class).** The
orchestrator wrote each broadcast temperature to `cpuN` and then
mirrored it to its HT sibling via `ht_map`. On AMD APUs the kernel
enumerates SMT siblings *consecutively* (cpu0/cpu1, cpu2/cpu3, …), so
`ht_map = {cpu0: cpu1, cpu2: cpu3, …}`. The mirror loop then wrote each
even-indexed primary twice (once as primary, once as mirror) and each
odd-indexed primary once (mirror lookup misses), producing `total = 12T
/ len = 8 = 1.5T` for any uniform input T, plus only 8 of 16 dashboard
bars (cpu8..cpu15 were never populated).

    [129 lines not shown]
DeltaFile
+733-206src/middlewared/middlewared/pytest/unit/utils/test_cpu_temperatures.py
+0-481src/middlewared/middlewared/utils/sensors.py
+347-0src/middlewared/middlewared/utils/cpu/hwmon.py
+329-0src/middlewared/middlewared/pytest/unit/utils/test_cpu_info_impl.py
+0-232src/middlewared/middlewared/utils/cpu.py
+231-0src/middlewared/middlewared/utils/cpu/temperatures.py
+1,640-9198 files not shown
+2,258-98314 files

FreeNAS/freenas 6e40f4asrc/middlewared/middlewared/utils/cpu info.py

address review 2
DeltaFile
+11-6src/middlewared/middlewared/utils/cpu/info.py
+11-61 files

FreeNAS/freenas abce731src/middlewared/middlewared/utils/cpu hwmon.py info.py

address review 1
DeltaFile
+8-8src/middlewared/middlewared/utils/cpu/hwmon.py
+7-7src/middlewared/middlewared/utils/cpu/info.py
+15-152 files

FreeNAS/freenas dcfabe3src/middlewared/middlewared/api/v26_0_0 zpool_query.py, src/middlewared/middlewared/plugins/zpool crud.py

NAS-141113 / 26.0.0-RC.1 / Expose all_sed property on zpool.query (by sonicaj) (#19040)

This PR adds changes to surface the all_sed flag on zpool.query entries
so callers can identify pools made up entirely of Self-Encrypting Drives
without going through pool.query.

Original PR: https://github.com/truenas/middleware/pull/19035

---------

Co-authored-by: Waqar Ahmed <waqarahmedjoyia at live.com>
Co-authored-by: caleb <yocalebo at gmail.com>
DeltaFile
+5-1src/middlewared/middlewared/plugins/zpool/crud.py
+3-0src/middlewared/middlewared/api/v26_0_0/zpool_query.py
+8-12 files

FreeNAS/freenas d610897src/middlewared/middlewared/api/v26_0_0 zpool_query.py, src/middlewared/middlewared/api/v27_0_0 zpool_query.py

NAS-141113 / 27.0.0-BETA.1 / Expose all_sed property on zpool.query (#19035)

This PR adds changes to surface the all_sed flag on zpool.query entries
so callers can identify pools made up entirely of Self-Encrypting Drives
without going through pool.query.

---------

Co-authored-by: caleb <yocalebo at gmail.com>
DeltaFile
+5-1src/middlewared/middlewared/plugins/zpool/crud.py
+3-0src/middlewared/middlewared/api/v26_0_0/zpool_query.py
+3-0src/middlewared/middlewared/api/v27_0_0/zpool_query.py
+11-13 files

FreeNAS/freenas 69adc21src/middlewared/middlewared/api/v26_0_0 zpool_query.py, src/middlewared/middlewared/api/v27_0_0 zpool_query.py

NAS-141114 / 27.0.0-BETA.1 / `zpool.query`: remove `stripe` topology key, fold single-disk vdevs into `data` (by creatorcary) (#19039)

## Summary

Removes the `stripe` key from the `zpool.query` topology output and
folds single-disk (childless) top-level vdevs into the existing `data`
key, so all storage vdevs are reported in one place.

## Background

`query_impl._format_topology()` was splitting top-level storage vdevs
into two buckets:

- `data`   — vdevs that have children (mirror, raidz, etc.)
- `stripe` — single-disk vdevs with no children

This split was a middleware-only invention. ZFS itself has no separate
"stripe" vdev type — a lone disk is simply a top-level data vdev. The
distinction added nothing the caller couldn't derive from

    [16 lines not shown]
DeltaFile
+3-8src/middlewared/middlewared/plugins/zpool/query_impl.py
+3-4tests/api2/test_zpool_query.py
+1-6src/middlewared/middlewared/plugins/boot.py
+0-4src/middlewared/middlewared/plugins/pool_/topology.py
+0-2src/middlewared/middlewared/api/v27_0_0/zpool_query.py
+0-2src/middlewared/middlewared/api/v26_0_0/zpool_query.py
+7-266 files

FreeNAS/freenas d924730src/middlewared/middlewared/api/v26_0_0 zpool_query.py, src/middlewared/middlewared/plugins boot.py

NAS-141114 / 26.0.0-RC.1 / `zpool.query`: remove `stripe` topology key, fold single-disk vdevs into `data` (#18993)

## Summary

Removes the `stripe` key from the `zpool.query` topology output and
folds single-disk (childless) top-level vdevs into the existing `data`
key, so all storage vdevs are reported in one place.

## Background

`query_impl._format_topology()` was splitting top-level storage vdevs
into two buckets:

- `data`   — vdevs that have children (mirror, raidz, etc.)
- `stripe` — single-disk vdevs with no children

This split was a middleware-only invention. ZFS itself has no separate
"stripe" vdev type — a lone disk is simply a top-level data vdev. The
distinction added nothing the caller couldn't derive from

    [9 lines not shown]
DeltaFile
+3-8src/middlewared/middlewared/plugins/zpool/query_impl.py
+1-6src/middlewared/middlewared/plugins/boot.py
+3-4tests/api2/test_zpool_query.py
+0-4src/middlewared/middlewared/plugins/pool_/topology.py
+0-2src/middlewared/middlewared/api/v26_0_0/zpool_query.py
+7-245 files

FreeNAS/freenas e7a7600src/middlewared/middlewared/api/base/server/ws_handler rpc.py, src/middlewared/middlewared/plugins/init_shutdown_script crud.py

NAS-141198 / 26.0.0-RC.1 / Minor fixes backport for 26 (#19038)
DeltaFile
+9-2src/middlewared/middlewared/api/base/server/ws_handler/rpc.py
+1-1src/middlewared/middlewared/plugins/init_shutdown_script/crud.py
+10-32 files

FreeNAS/freenas 241346dsrc/middlewared/middlewared/api/base model.py, src/middlewared/middlewared/api/v27_0_0 filesystem.py

`filesystem.py` file mypy
DeltaFile
+196-156src/middlewared/middlewared/plugins/filesystem.py
+25-13src/middlewared/middlewared/api/v27_0_0/filesystem.py
+14-9src/middlewared/middlewared/plugins/account.py
+11-11src/middlewared/middlewared/plugins/vm/vm_device_convert.py
+10-5src/middlewared/middlewared/api/base/model.py
+7-7src/middlewared/middlewared/plugins/filesystem_/acl.py
+263-20117 files not shown
+317-24123 files

FreeNAS/freenas 78e13d4src/middlewared/middlewared/common environ.py, src/middlewared/middlewared/common/attachment __init__.py certificate.py

`common` mypy checks
DeltaFile
+36-27src/middlewared/middlewared/common/listen/__init__.py
+34-29src/middlewared/middlewared/common/attachment/__init__.py
+21-21src/middlewared/middlewared/common/event_source/manager.py
+15-12src/middlewared/middlewared/common/attachment/certificate.py
+2-2src/middlewared/middlewared/plugins/container/attachments.py
+2-2src/middlewared/middlewared/common/environ.py
+110-938 files not shown
+118-10114 files

FreeNAS/freenas de9bdafsrc/middlewared/middlewared/common environ.py, src/middlewared/middlewared/common/attachment __init__.py certificate.py

`common` mypy checks
DeltaFile
+36-27src/middlewared/middlewared/common/listen/__init__.py
+34-29src/middlewared/middlewared/common/attachment/__init__.py
+21-21src/middlewared/middlewared/common/event_source/manager.py
+15-12src/middlewared/middlewared/common/attachment/certificate.py
+2-2src/middlewared/middlewared/common/environ.py
+2-2src/middlewared/middlewared/plugins/container/attachments.py
+110-938 files not shown
+118-10114 files

FreeNAS/freenas 5f349e9.github/workflows mypy.yml, src/middlewared/middlewared/api/base decorator.py model.py

`middlewared.api` typing hints
DeltaFile
+56-49src/middlewared/middlewared/api/base/decorator.py
+56-36src/middlewared/middlewared/api/base/model.py
+10-13src/middlewared/middlewared/api/base/jsonschema.py
+6-5src/middlewared/middlewared/api/base/excluded.py
+3-3src/middlewared/middlewared/api/base/handler/accept.py
+1-4.github/workflows/mypy.yml
+132-1101 files not shown
+134-1127 files

FreeNAS/freenas 6f9072b.github/workflows mypy.yml, src/middlewared/middlewared/api/base/validators base.py cron.py

`middlewared.api.base.validators` mypy
DeltaFile
+7-4src/middlewared/middlewared/api/base/validators/base.py
+4-4src/middlewared/middlewared/api/base/validators/cron.py
+2-2src/middlewared/middlewared/api/base/validators/options.py
+3-1src/middlewared/middlewared/api/base/validators/filters.py
+1-1src/middlewared/middlewared/utils/filter_list.py
+2-0.github/workflows/mypy.yml
+19-126 files