Skip to content

Commit 62fd037

Browse files
authored
[inventory] Add zpool health to inventory (#9911)
Does exactly what it says on the tin. Output from the API on simulated omicron: ``` $ curl -H "api-version: 24.0.0" http://[::1]:58414/inventory | jq .zpools <..> [ { "id": "84c820d7-8af9-4c79-89cf-ae07c70b0c28", "total_size": 17179869184, "health": "online" }, { "id": "6deda61c-2bfe-452c-a018-a35ab566ae07", "total_size": 17179869184, "health": "online" }, { "id": "46c5185c-6b09-4e8f-8da2-a65cd24b443d", "total_size": 17179869184, "health": "online" } ] ``` On an a4x2 machine I forced a fault on a zpool and this is a snippet from the inventory collection ```console root@oxz_switch:~# omdb db inventory collections show latest <...> zpools 1625cac3-72a8-496a-ba89-799f6f6cd274: total size: 19968 MiB health: online 26012db4-bba8-47ed-9e57-cb4b96562c19: total size: 19968 MiB health: online 2dd8b022-c560-42f8-acfb-154f0e8062aa: total size: 19968 MiB health: online 619af41c-70ae-401a-9bd1-190b17cf15c8: total size: 19968 MiB health: online ff983224-ef9a-47e5-9d3e-57e64909a6eb: total size: 19968 MiB health: unavailable ``` Supersedes: #9615 Closes: #9719
1 parent 0d9b2d7 commit 62fd037

41 files changed

Lines changed: 10794 additions & 61 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,9 +1598,9 @@ sled 2eb69596-f081-4e2d-9425-9994926e0832 (role = Gimlet, serial serial1)
15981598
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-6d012675-6f54-4b6a-8658-ab0076237569" } in 1
15991599
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-9a065406-12a0-4b29-926e-d66bb785d17b" } in 2
16001600
zpools
1601-
64ea76fb-6673-4810-8e53-c2458b75eb01: total size: 100 GiB
1602-
6d012675-6f54-4b6a-8658-ab0076237569: total size: 100 GiB
1603-
9a065406-12a0-4b29-926e-d66bb785d17b: total size: 100 GiB
1601+
64ea76fb-6673-4810-8e53-c2458b75eb01: total size: 100 GiB health: online
1602+
6d012675-6f54-4b6a-8658-ab0076237569: total size: 100 GiB health: online
1603+
9a065406-12a0-4b29-926e-d66bb785d17b: total size: 100 GiB health: online
16041604
datasets:
16051605
oxp_9a065406-12a0-4b29-926e-d66bb785d17b/crypt/debug - id: 1338efa2-c05b-4231-9180-db10555139ff, compression: gzip-9
16061606
available: 1 GiB, used: 0 B
@@ -1746,9 +1746,9 @@ sled 32d8d836-4d8a-4e54-8fa9-f31d79c42646 (role = Gimlet, serial serial2)
17461746
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-687e054b-a9b5-4404-8b3f-0ea119c44a6a" } in 1
17471747
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-a4e8a5cc-cd1c-4a08-bcf1-31785f7cda28" } in 2
17481748
zpools
1749-
2db3c119-38fa-41c0-8dbe-89689b84d655: total size: 100 GiB
1750-
687e054b-a9b5-4404-8b3f-0ea119c44a6a: total size: 100 GiB
1751-
a4e8a5cc-cd1c-4a08-bcf1-31785f7cda28: total size: 100 GiB
1749+
2db3c119-38fa-41c0-8dbe-89689b84d655: total size: 100 GiB health: online
1750+
687e054b-a9b5-4404-8b3f-0ea119c44a6a: total size: 100 GiB health: online
1751+
a4e8a5cc-cd1c-4a08-bcf1-31785f7cda28: total size: 100 GiB health: online
17521752
datasets:
17531753
oxp_a4e8a5cc-cd1c-4a08-bcf1-31785f7cda28/crypt/zone/oxz_crucible_e668d83e-a28c-42dc-b574-467e57403cc1 - id: 0304cb4a-6013-4ecd-a9ba-c0fb45874cfc, compression: off
17541754
available: 1 GiB, used: 0 B
@@ -1894,9 +1894,9 @@ sled 89d02b1b-478c-401a-8e28-7a26f74fa41b (role = Gimlet, serial serial0)
18941894
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-ab94a812-86ce-428c-bbbb-6ce1ab0b071b" } in 1
18951895
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-f96f5901-2907-4f21-bfeb-772f8a3c4e44" } in 2
18961896
zpools
1897-
0477165a-a72e-4814-b8d6-74aa02cb2040: total size: 100 GiB
1898-
ab94a812-86ce-428c-bbbb-6ce1ab0b071b: total size: 100 GiB
1899-
f96f5901-2907-4f21-bfeb-772f8a3c4e44: total size: 100 GiB
1897+
0477165a-a72e-4814-b8d6-74aa02cb2040: total size: 100 GiB health: online
1898+
ab94a812-86ce-428c-bbbb-6ce1ab0b071b: total size: 100 GiB health: online
1899+
f96f5901-2907-4f21-bfeb-772f8a3c4e44: total size: 100 GiB health: online
19001900
datasets:
19011901
oxp_f96f5901-2907-4f21-bfeb-772f8a3c4e44/crucible - id: 03708424-a92a-4f02-8ad6-ccbc6f64c5a4, compression: off
19021902
available: 1 GiB, used: 0 B

dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (role = Gimlet, serial serial1)
208208
physical disks:
209209
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-72c59873-31ff-4e36-8d76-ff834009349a" } in 0
210210
zpools
211-
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB
211+
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB health: online
212212
datasets:
213213
oxp_72c59873-31ff-4e36-8d76-ff834009349a/crypt/zone/oxz_clickhouse_353b3b65-20f7-48c3-88f7-495bd5d31545 - id: 09b9cc9b-3426-470b-a7bc-538f82dede03, compression: off
214214
available: 1 GiB, used: 0 B
@@ -337,7 +337,7 @@ sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (role = Gimlet, serial serial0)
337337
physical disks:
338338
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-c6d33b64-fb96-4129-bab1-7878a06a5f9b" } in 0
339339
zpools
340-
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB
340+
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB health: online
341341
datasets:
342342
oxp_c6d33b64-fb96-4129-bab1-7878a06a5f9b/crypt/zone/oxz_external_dns_803bfb63-c246-41db-b0da-d3b87ddfc63d - id: 1bca7f71-5e42-4749-91ec-fa40793a3a9a, compression: off
343343
available: 1 GiB, used: 0 B
@@ -469,7 +469,7 @@ sled d81c6a84-79b8-4958-ae41-ea46c9b19763 (role = Gimlet, serial serial2)
469469
physical disks:
470470
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-4930954e-9ac7-4453-b63f-5ab97c389a99" } in 0
471471
zpools
472-
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB
472+
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB health: online
473473
datasets:
474474
oxp_4930954e-9ac7-4453-b63f-5ab97c389a99/crypt/zone/oxz_crucible_pantry_75b220ba-a0f4-4872-8202-dc7c87f062d0 - id: 090bd88d-0a43-4040-a832-b13ae721f74f, compression: off
475475
available: 1 GiB, used: 0 B

dev-tools/reconfigurator-cli/tests/output/cmds-nexus-generation-autobump-stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,9 @@ sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (role = Gimlet, serial serial1)
569569
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-72c59873-31ff-4e36-8d76-ff834009349a" } in 1
570570
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-b5fd5bc1-099e-4e77-8028-a9793c11f43b" } in 2
571571
zpools
572-
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB
573-
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB
574-
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB
572+
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB health: online
573+
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB health: online
574+
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB health: online
575575
datasets:
576576
oxp_72c59873-31ff-4e36-8d76-ff834009349a/crypt/zone/oxz_crucible_e2fdefe7-95b2-4fd2-ae37-56929a06d58c - id: 0582030b-aab6-4d0e-b1d2-64562ee712cd, compression: off
577577
available: 1 GiB, used: 0 B
@@ -766,9 +766,9 @@ sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (role = Gimlet, serial serial0)
766766
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-c6d33b64-fb96-4129-bab1-7878a06a5f9b" } in 1
767767
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-e4d937e1-6ddc-4eca-bb08-c1f73791e608" } in 2
768768
zpools
769-
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB
770-
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB
771-
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB
769+
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB health: online
770+
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB health: online
771+
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB health: online
772772
datasets:
773773
oxp_073979dd-3248-44a5-9fa1-cc72a140d682/crypt/external_dns - id: 02c56a30-7d97-406d-bd34-1eb437fd517d, compression: off
774774
available: 1 GiB, used: 0 B
@@ -954,9 +954,9 @@ sled d81c6a84-79b8-4958-ae41-ea46c9b19763 (role = Gimlet, serial serial2)
954954
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-30c16fe4-4229-49d0-ab01-3138f2c7dff2" } in 1
955955
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-4930954e-9ac7-4453-b63f-5ab97c389a99" } in 2
956956
zpools
957-
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB
958-
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB
959-
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB
957+
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB health: online
958+
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB health: online
959+
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB health: online
960960
datasets:
961961
oxp_4930954e-9ac7-4453-b63f-5ab97c389a99/crypt/local_storage - id: 090bd88d-0a43-4040-a832-b13ae721f74f, compression: off
962962
available: 1 GiB, used: 0 B

dev-tools/reconfigurator-cli/tests/output/cmds-target-release-stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (role = Gimlet, serial serial1)
556556
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-72c59873-31ff-4e36-8d76-ff834009349a" } in 1
557557
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-b5fd5bc1-099e-4e77-8028-a9793c11f43b" } in 2
558558
zpools
559-
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB
560-
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB
561-
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB
559+
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB health: online
560+
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB health: online
561+
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB health: online
562562
datasets:
563563
oxp_72c59873-31ff-4e36-8d76-ff834009349a/crypt/zone/oxz_crucible_e2fdefe7-95b2-4fd2-ae37-56929a06d58c - id: 0582030b-aab6-4d0e-b1d2-64562ee712cd, compression: off
564564
available: 1 GiB, used: 0 B
@@ -753,9 +753,9 @@ sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (role = Gimlet, serial serial0)
753753
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-c6d33b64-fb96-4129-bab1-7878a06a5f9b" } in 1
754754
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-e4d937e1-6ddc-4eca-bb08-c1f73791e608" } in 2
755755
zpools
756-
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB
757-
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB
758-
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB
756+
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB health: online
757+
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB health: online
758+
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB health: online
759759
datasets:
760760
oxp_073979dd-3248-44a5-9fa1-cc72a140d682/crypt/external_dns - id: 02c56a30-7d97-406d-bd34-1eb437fd517d, compression: off
761761
available: 1 GiB, used: 0 B
@@ -941,9 +941,9 @@ sled d81c6a84-79b8-4958-ae41-ea46c9b19763 (role = Gimlet, serial serial2)
941941
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-30c16fe4-4229-49d0-ab01-3138f2c7dff2" } in 1
942942
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-4930954e-9ac7-4453-b63f-5ab97c389a99" } in 2
943943
zpools
944-
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB
945-
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB
946-
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB
944+
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB health: online
945+
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB health: online
946+
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB health: online
947947
datasets:
948948
oxp_4930954e-9ac7-4453-b63f-5ab97c389a99/crypt/local_storage - id: 090bd88d-0a43-4040-a832-b13ae721f74f, compression: off
949949
available: 1 GiB, used: 0 B

dev-tools/reconfigurator-cli/tests/output/cmds-unsafe-zone-mgs-stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (role = Gimlet, serial serial1)
540540
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-72c59873-31ff-4e36-8d76-ff834009349a" } in 1
541541
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-b5fd5bc1-099e-4e77-8028-a9793c11f43b" } in 2
542542
zpools
543-
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB
544-
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB
545-
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB
543+
727522a7-934f-494d-b5b3-160968e74463: total size: 100 GiB health: online
544+
72c59873-31ff-4e36-8d76-ff834009349a: total size: 100 GiB health: online
545+
b5fd5bc1-099e-4e77-8028-a9793c11f43b: total size: 100 GiB health: online
546546
datasets:
547547
oxp_72c59873-31ff-4e36-8d76-ff834009349a/crypt/zone/oxz_crucible_e2fdefe7-95b2-4fd2-ae37-56929a06d58c - id: 0582030b-aab6-4d0e-b1d2-64562ee712cd, compression: off
548548
available: 1 GiB, used: 0 B
@@ -737,9 +737,9 @@ sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (role = Gimlet, serial serial0)
737737
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-c6d33b64-fb96-4129-bab1-7878a06a5f9b" } in 1
738738
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-e4d937e1-6ddc-4eca-bb08-c1f73791e608" } in 2
739739
zpools
740-
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB
741-
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB
742-
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB
740+
073979dd-3248-44a5-9fa1-cc72a140d682: total size: 100 GiB health: online
741+
c6d33b64-fb96-4129-bab1-7878a06a5f9b: total size: 100 GiB health: online
742+
e4d937e1-6ddc-4eca-bb08-c1f73791e608: total size: 100 GiB health: online
743743
datasets:
744744
oxp_073979dd-3248-44a5-9fa1-cc72a140d682/crypt/external_dns - id: 02c56a30-7d97-406d-bd34-1eb437fd517d, compression: off
745745
available: 1 GiB, used: 0 B
@@ -925,9 +925,9 @@ sled d81c6a84-79b8-4958-ae41-ea46c9b19763 (role = Gimlet, serial serial2)
925925
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-30c16fe4-4229-49d0-ab01-3138f2c7dff2" } in 1
926926
U2: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-4930954e-9ac7-4453-b63f-5ab97c389a99" } in 2
927927
zpools
928-
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB
929-
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB
930-
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB
928+
18b20749-0748-4105-bb10-7b13cfc776e2: total size: 100 GiB health: online
929+
30c16fe4-4229-49d0-ab01-3138f2c7dff2: total size: 100 GiB health: online
930+
4930954e-9ac7-4453-b63f-5ab97c389a99: total size: 100 GiB health: online
931931
datasets:
932932
oxp_4930954e-9ac7-4453-b63f-5ab97c389a99/crypt/local_storage - id: 090bd88d-0a43-4040-a832-b13ae721f74f, compression: off
933933
available: 1 GiB, used: 0 B

illumos-utils/src/zpool.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
77
use crate::{ExecutionError, PFEXEC, execute_async};
88
use camino::{Utf8Path, Utf8PathBuf};
9+
use schemars::JsonSchema;
10+
use serde::{Deserialize, Serialize};
11+
use std::fmt::Display;
912
use std::str::FromStr;
1013
use tokio::process::Command;
1114

@@ -60,7 +63,10 @@ pub struct GetInfoError {
6063
err: Error,
6164
}
6265

63-
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66+
#[derive(
67+
Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
68+
)]
69+
#[serde(rename_all = "snake_case")]
6470
pub enum ZpoolHealth {
6571
/// The device is online and functioning.
6672
Online,
@@ -94,6 +100,20 @@ impl FromStr for ZpoolHealth {
94100
}
95101
}
96102

103+
impl Display for ZpoolHealth {
104+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105+
let s = match self {
106+
ZpoolHealth::Online => "online",
107+
ZpoolHealth::Degraded => "degraded",
108+
ZpoolHealth::Faulted => "faulted",
109+
ZpoolHealth::Offline => "offline",
110+
ZpoolHealth::Removed => "removed",
111+
ZpoolHealth::Unavailable => "unavailable",
112+
};
113+
write!(f, "{s}")
114+
}
115+
}
116+
97117
/// Describes a Zpool.
98118
#[derive(Clone, Debug, PartialEq, Eq)]
99119
pub struct ZpoolInfo {

nexus/db-model/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ hex.workspace = true
2323
iddqd.workspace = true
2424
ipnetwork.workspace = true
2525
itertools.workspace = true
26+
illumos-utils.workspace = true
2627
macaddr.workspace = true
2728
newtype_derive.workspace = true
2829
omicron-cockroach-metrics.workspace = true

nexus/db-model/src/inventory.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use diesel::pg::Pg;
2727
use diesel::serialize::ToSql;
2828
use diesel::{serialize, sql_types};
2929
use iddqd::IdOrdMap;
30+
use illumos_utils::zpool::ZpoolHealth;
3031
use ipnetwork::IpNetwork;
3132
use nexus_db_schema::schema::inv_zone_manifest_non_boot;
3233
use nexus_db_schema::schema::inv_zone_manifest_zone;
@@ -2258,6 +2259,48 @@ impl From<InvNvmeDiskFirmware>
22582259
}
22592260
}
22602261

2262+
// See [`illumos_utils::zpool::ZpoolHealth`].
2263+
impl_enum_type!(
2264+
InvZpoolHealthEnum:
2265+
2266+
#[derive(Copy, Clone, Debug, AsExpression, FromSqlRow, PartialEq)]
2267+
pub enum InvZpoolHealth;
2268+
2269+
// Enum values
2270+
Online => b"online"
2271+
Degraded => b"degraded"
2272+
Faulted => b"faulted"
2273+
Offline => b"offline"
2274+
Removed => b"removed"
2275+
Unavailable => b"unavailable"
2276+
);
2277+
2278+
impl From<ZpoolHealth> for InvZpoolHealth {
2279+
fn from(value: ZpoolHealth) -> Self {
2280+
match value {
2281+
ZpoolHealth::Online => InvZpoolHealth::Online,
2282+
ZpoolHealth::Degraded => InvZpoolHealth::Degraded,
2283+
ZpoolHealth::Faulted => InvZpoolHealth::Faulted,
2284+
ZpoolHealth::Offline => InvZpoolHealth::Offline,
2285+
ZpoolHealth::Removed => InvZpoolHealth::Removed,
2286+
ZpoolHealth::Unavailable => InvZpoolHealth::Unavailable,
2287+
}
2288+
}
2289+
}
2290+
2291+
impl From<InvZpoolHealth> for ZpoolHealth {
2292+
fn from(value: InvZpoolHealth) -> Self {
2293+
match value {
2294+
InvZpoolHealth::Online => ZpoolHealth::Online,
2295+
InvZpoolHealth::Degraded => ZpoolHealth::Degraded,
2296+
InvZpoolHealth::Faulted => ZpoolHealth::Faulted,
2297+
InvZpoolHealth::Offline => ZpoolHealth::Offline,
2298+
InvZpoolHealth::Removed => ZpoolHealth::Removed,
2299+
InvZpoolHealth::Unavailable => ZpoolHealth::Unavailable,
2300+
}
2301+
}
2302+
}
2303+
22612304
/// See [`nexus_types::inventory::Zpool`].
22622305
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
22632306
#[diesel(table_name = inv_zpool)]
@@ -2267,6 +2310,7 @@ pub struct InvZpool {
22672310
pub id: DbTypedUuid<ZpoolKind>,
22682311
pub sled_id: DbTypedUuid<SledKind>,
22692312
pub total_size: ByteCount,
2313+
pub health: InvZpoolHealth,
22702314
}
22712315

22722316
impl InvZpool {
@@ -2281,6 +2325,7 @@ impl InvZpool {
22812325
id: zpool.id.into(),
22822326
sled_id: sled_id.into(),
22832327
total_size: zpool.total_size.into(),
2328+
health: zpool.health.into(),
22842329
}
22852330
}
22862331
}
@@ -2291,6 +2336,7 @@ impl From<InvZpool> for nexus_types::inventory::Zpool {
22912336
time_collected: pool.time_collected,
22922337
id: pool.id.into(),
22932338
total_size: *pool.total_size,
2339+
health: pool.health.into(),
22942340
}
22952341
}
22962342
}

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(233, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(234, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(234, "inv-zpool-health"),
3132
KnownVersion::new(233, "measurement-blueprints"),
3233
KnownVersion::new(232, "index-backfill-batch-size"),
3334
KnownVersion::new(231, "bgp-config-max-paths-not-null"),

0 commit comments

Comments
 (0)