Compare commits
5 Commits
730b913bd1
...
feat/ceph-
| Author | SHA1 | Date | |
|---|---|---|---|
| ce5e5ea6ab | |||
| cd3ea6fc10 | |||
| 89eb88d10e | |||
| d1a274b705 | |||
| b43ca7c740 |
236
Cargo.lock
generated
236
Cargo.lock
generated
@@ -378,7 +378,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
@@ -473,7 +473,7 @@ dependencies = [
|
|||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -515,12 +515,6 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg_aliases"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chacha20"
|
name = "chacha20"
|
||||||
version = "0.9.1"
|
version = "0.9.1"
|
||||||
@@ -1695,11 +1689,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
|
||||||
"libc",
|
"libc",
|
||||||
"r-efi",
|
"r-efi",
|
||||||
"wasi 0.14.2+wasi-0.2.4",
|
"wasi 0.14.2+wasi-0.2.4",
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1797,7 +1789,6 @@ dependencies = [
|
|||||||
"env_logger",
|
"env_logger",
|
||||||
"fqdn",
|
"fqdn",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"harmony-secret-derive",
|
|
||||||
"harmony_macros",
|
"harmony_macros",
|
||||||
"harmony_types",
|
"harmony_types",
|
||||||
"helm-wrapper-rs",
|
"helm-wrapper-rs",
|
||||||
@@ -1838,35 +1829,6 @@ dependencies = [
|
|||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "harmony-secret"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"directories",
|
|
||||||
"harmony-secret-derive",
|
|
||||||
"http 1.3.1",
|
|
||||||
"infisical",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"pretty_assertions",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"tempfile",
|
|
||||||
"thiserror 2.0.14",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "harmony-secret-derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-crate",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "harmony_cli"
|
name = "harmony_cli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2000,7 +1962,7 @@ dependencies = [
|
|||||||
"non-blank-string-rs",
|
"non-blank-string-rs",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2168,7 +2130,7 @@ dependencies = [
|
|||||||
"httpdate",
|
"httpdate",
|
||||||
"itoa",
|
"itoa",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2 0.5.10",
|
"socket2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2247,7 +2209,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2310,7 +2271,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2 0.5.10",
|
"socket2",
|
||||||
"system-configuration 0.6.1",
|
"system-configuration 0.6.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
@@ -2527,21 +2488,6 @@ version = "2.0.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "infisical"
|
|
||||||
version = "0.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4d97c33b08e22b2f7b9f87a8fc06a7d247442db7bf216ffc6661a74ed8aea658"
|
|
||||||
dependencies = [
|
|
||||||
"base64 0.22.1",
|
|
||||||
"reqwest 0.12.20",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
"tokio",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inout"
|
name = "inout"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@@ -2582,17 +2528,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "io-uring"
|
|
||||||
version = "0.7.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.11.0"
|
version = "2.11.0"
|
||||||
@@ -2686,7 +2621,7 @@ dependencies = [
|
|||||||
"pest_derive",
|
"pest_derive",
|
||||||
"regex",
|
"regex",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2787,7 +2722,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
@@ -2812,7 +2747,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde-value",
|
"serde-value",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2850,7 +2785,7 @@ dependencies = [
|
|||||||
"pin-project",
|
"pin-project",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2962,12 +2897,6 @@ dependencies = [
|
|||||||
"hashbrown 0.15.4",
|
"hashbrown 0.15.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lru-slab"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "md5"
|
name = "md5"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -3270,7 +3199,7 @@ dependencies = [
|
|||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.14",
|
"thiserror 1.0.69",
|
||||||
"tokio",
|
"tokio",
|
||||||
"uuid",
|
"uuid",
|
||||||
"xml-rs",
|
"xml-rs",
|
||||||
@@ -3437,7 +3366,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
|
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"ucd-trie",
|
"ucd-trie",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3658,15 +3587,6 @@ dependencies = [
|
|||||||
"elliptic-curve",
|
"elliptic-curve",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-crate"
|
|
||||||
version = "3.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
|
|
||||||
dependencies = [
|
|
||||||
"toml_edit",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.95"
|
version = "1.0.95"
|
||||||
@@ -3682,61 +3602,6 @@ version = "0.4.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e9e1dcb320d6839f6edb64f7a4a59d39b30480d4d1765b56873f7c858538a5fe"
|
checksum = "e9e1dcb320d6839f6edb64f7a4a59d39b30480d4d1765b56873f7c858538a5fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn"
|
|
||||||
version = "0.11.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
"cfg_aliases",
|
|
||||||
"pin-project-lite",
|
|
||||||
"quinn-proto",
|
|
||||||
"quinn-udp",
|
|
||||||
"rustc-hash",
|
|
||||||
"rustls",
|
|
||||||
"socket2 0.5.10",
|
|
||||||
"thiserror 2.0.14",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"web-time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn-proto"
|
|
||||||
version = "0.11.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
"getrandom 0.3.3",
|
|
||||||
"lru-slab",
|
|
||||||
"rand 0.9.1",
|
|
||||||
"ring",
|
|
||||||
"rustc-hash",
|
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"slab",
|
|
||||||
"thiserror 2.0.14",
|
|
||||||
"tinyvec",
|
|
||||||
"tracing",
|
|
||||||
"web-time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quinn-udp"
|
|
||||||
version = "0.5.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fcebb1209ee276352ef14ff8732e24cc2b02bbac986cd74a4c81bcb2f9881970"
|
|
||||||
dependencies = [
|
|
||||||
"cfg_aliases",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"socket2 0.5.10",
|
|
||||||
"tracing",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.40"
|
version = "1.0.40"
|
||||||
@@ -3855,7 +3720,7 @@ checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.16",
|
"getrandom 0.2.16",
|
||||||
"libredox",
|
"libredox",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3956,7 +3821,6 @@ dependencies = [
|
|||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"bytes",
|
"bytes",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"h2 0.4.10",
|
"h2 0.4.10",
|
||||||
@@ -3973,8 +3837,6 @@ dependencies = [
|
|||||||
"native-tls",
|
"native-tls",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"quinn",
|
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -3982,7 +3844,6 @@ dependencies = [
|
|||||||
"sync_wrapper 1.0.2",
|
"sync_wrapper 1.0.2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-native-tls",
|
"tokio-native-tls",
|
||||||
"tokio-rustls",
|
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
@@ -3992,7 +3853,6 @@ dependencies = [
|
|||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"wasm-streams",
|
"wasm-streams",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4156,7 +4016,7 @@ dependencies = [
|
|||||||
"flurry",
|
"flurry",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
]
|
]
|
||||||
@@ -4182,12 +4042,6 @@ version = "0.1.25"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-hash"
|
|
||||||
version = "2.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -4287,7 +4141,6 @@ version = "1.12.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
|
checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"web-time",
|
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4726,7 +4579,7 @@ checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4773,16 +4626,6 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "socket2"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
version = "0.9.8"
|
version = "0.9.8"
|
||||||
@@ -4920,9 +4763,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.105"
|
version = "2.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
|
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5056,11 +4899,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.14"
|
version = "2.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e"
|
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 2.0.14",
|
"thiserror-impl 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5076,9 +4919,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.14"
|
version = "2.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227"
|
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5144,39 +4987,21 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tinyvec"
|
|
||||||
version = "1.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71"
|
|
||||||
dependencies = [
|
|
||||||
"tinyvec_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tinyvec_macros"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.47.1"
|
version = "1.45.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
"io-uring",
|
|
||||||
"libc",
|
"libc",
|
||||||
"mio 1.0.4",
|
"mio 1.0.4",
|
||||||
"parking_lot",
|
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"slab",
|
"socket2",
|
||||||
"socket2 0.6.0",
|
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5426,7 +5251,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"rand 0.9.1",
|
"rand 0.9.1",
|
||||||
"sha1",
|
"sha1",
|
||||||
"thiserror 2.0.14",
|
"thiserror 2.0.12",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -5727,15 +5552,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "webpki-roots"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2"
|
|
||||||
dependencies = [
|
|
||||||
"rustls-pki-types",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ members = [
|
|||||||
"harmony_cli",
|
"harmony_cli",
|
||||||
"k3d",
|
"k3d",
|
||||||
"harmony_composer",
|
"harmony_composer",
|
||||||
"harmony_secret_derive",
|
|
||||||
"harmony_secret",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
@@ -55,10 +53,6 @@ chrono = "0.4"
|
|||||||
similar = "2"
|
similar = "2"
|
||||||
uuid = { version = "1.11", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
uuid = { version = "1.11", features = ["v4", "fast-rng", "macro-diagnostics"] }
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions = "1.4.1"
|
||||||
tempfile = "3.20.0"
|
|
||||||
bollard = "0.19.1"
|
bollard = "0.19.1"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
tar = "0.4.44"
|
tar = "0.4.44"
|
||||||
lazy_static = "1.5.0"
|
|
||||||
directories = "6.0.0"
|
|
||||||
thiserror = "2.0.14"
|
|
||||||
|
|||||||
12
examples/remove_rook_osd/Cargo.toml
Normal file
12
examples/remove_rook_osd/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "example_remove_rook_osd"
|
||||||
|
edition = "2024"
|
||||||
|
version.workspace = true
|
||||||
|
readme.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
harmony = { version = "0.1.0", path = "../../harmony" }
|
||||||
|
harmony_cli = { version = "0.1.0", path = "../../harmony_cli" }
|
||||||
|
harmony_tui = { version = "0.1.0", path = "../../harmony_tui" }
|
||||||
|
tokio.workspace = true
|
||||||
18
examples/remove_rook_osd/src/main.rs
Normal file
18
examples/remove_rook_osd/src/main.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use harmony::{
|
||||||
|
inventory::Inventory, modules::storage::ceph::ceph_remove_osd_score::CephRemoveOsd,
|
||||||
|
topology::K8sAnywhereTopology,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let ceph_score = CephRemoveOsd {
|
||||||
|
osd_deployment_name: "rook-ceph-osd-2".to_string(),
|
||||||
|
rook_ceph_namespace: "rook-ceph".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let topology = K8sAnywhereTopology::from_env();
|
||||||
|
let inventory = Inventory::autoload();
|
||||||
|
harmony_cli::run(inventory, topology, vec![Box::new(ceph_score)], None)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
@@ -38,8 +38,8 @@ serde-value.workspace = true
|
|||||||
helm-wrapper-rs = "0.4.0"
|
helm-wrapper-rs = "0.4.0"
|
||||||
non-blank-string-rs = "1.0.4"
|
non-blank-string-rs = "1.0.4"
|
||||||
k3d-rs = { path = "../k3d" }
|
k3d-rs = { path = "../k3d" }
|
||||||
directories.workspace = true
|
directories = "6.0.0"
|
||||||
lazy_static.workspace = true
|
lazy_static = "1.5.0"
|
||||||
dockerfile_builder = "0.1.5"
|
dockerfile_builder = "0.1.5"
|
||||||
temp-file = "0.1.9"
|
temp-file = "0.1.9"
|
||||||
convert_case.workspace = true
|
convert_case.workspace = true
|
||||||
@@ -59,7 +59,7 @@ similar.workspace = true
|
|||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
tokio-util = "0.7.15"
|
tokio-util = "0.7.15"
|
||||||
strum = { version = "0.27.1", features = ["derive"] }
|
strum = { version = "0.27.1", features = ["derive"] }
|
||||||
tempfile.workspace = true
|
tempfile = "3.20.0"
|
||||||
serde_with = "3.14.0"
|
serde_with = "3.14.0"
|
||||||
schemars = "0.8.22"
|
schemars = "0.8.22"
|
||||||
kube-derive = "1.1.0"
|
kube-derive = "1.1.0"
|
||||||
@@ -67,7 +67,6 @@ bollard.workspace = true
|
|||||||
tar.workspace = true
|
tar.workspace = true
|
||||||
base64.workspace = true
|
base64.workspace = true
|
||||||
once_cell = "1.21.3"
|
once_cell = "1.21.3"
|
||||||
harmony-secret-derive = { version = "0.1.0", path = "../harmony_secret_derive" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions.workspace = true
|
pretty_assertions.workspace = true
|
||||||
|
|||||||
Binary file not shown.
@@ -32,7 +32,6 @@ pub enum InterpretName {
|
|||||||
Lamp,
|
Lamp,
|
||||||
ApplicationMonitoring,
|
ApplicationMonitoring,
|
||||||
K8sPrometheusCrdAlerting,
|
K8sPrometheusCrdAlerting,
|
||||||
Custom(&'static str),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for InterpretName {
|
impl std::fmt::Display for InterpretName {
|
||||||
@@ -59,7 +58,6 @@ impl std::fmt::Display for InterpretName {
|
|||||||
InterpretName::Lamp => f.write_str("LAMP"),
|
InterpretName::Lamp => f.write_str("LAMP"),
|
||||||
InterpretName::ApplicationMonitoring => f.write_str("ApplicationMonitoring"),
|
InterpretName::ApplicationMonitoring => f.write_str("ApplicationMonitoring"),
|
||||||
InterpretName::K8sPrometheusCrdAlerting => f.write_str("K8sPrometheusCrdAlerting"),
|
InterpretName::K8sPrometheusCrdAlerting => f.write_str("K8sPrometheusCrdAlerting"),
|
||||||
InterpretName::Custom(name) => f.write_str(name),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use k8s_openapi::{
|
|||||||
};
|
};
|
||||||
use kube::{
|
use kube::{
|
||||||
Client, Config, Error, Resource,
|
Client, Config, Error, Resource,
|
||||||
api::{Api, AttachParams, ListParams, Patch, PatchParams, ResourceExt},
|
api::{Api, AttachParams, DeleteParams, ListParams, Patch, PatchParams, ResourceExt},
|
||||||
config::{KubeConfigOptions, Kubeconfig},
|
config::{KubeConfigOptions, Kubeconfig},
|
||||||
core::ErrorResponse,
|
core::ErrorResponse,
|
||||||
runtime::reflector::Lookup,
|
runtime::reflector::Lookup,
|
||||||
@@ -17,7 +17,9 @@ use kube::{
|
|||||||
};
|
};
|
||||||
use log::{debug, error, trace};
|
use log::{debug, error, trace};
|
||||||
use serde::{Serialize, de::DeserializeOwned};
|
use serde::{Serialize, de::DeserializeOwned};
|
||||||
|
use serde_json::json;
|
||||||
use similar::TextDiff;
|
use similar::TextDiff;
|
||||||
|
use tokio::io::AsyncReadExt;
|
||||||
|
|
||||||
#[derive(new, Clone)]
|
#[derive(new, Clone)]
|
||||||
pub struct K8sClient {
|
pub struct K8sClient {
|
||||||
@@ -51,6 +53,66 @@ impl K8sClient {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_deployment(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
namespace: Option<&str>,
|
||||||
|
) -> Result<Option<Deployment>, Error> {
|
||||||
|
let deps: Api<Deployment> = if let Some(ns) = namespace {
|
||||||
|
Api::namespaced(self.client.clone(), ns)
|
||||||
|
} else {
|
||||||
|
Api::default_namespaced(self.client.clone())
|
||||||
|
};
|
||||||
|
Ok(deps.get_opt(name).await?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_pod(&self, name: &str, namespace: Option<&str>) -> Result<Option<Pod>, Error> {
|
||||||
|
let pods: Api<Pod> = if let Some(ns) = namespace {
|
||||||
|
Api::namespaced(self.client.clone(), ns)
|
||||||
|
} else {
|
||||||
|
Api::default_namespaced(self.client.clone())
|
||||||
|
};
|
||||||
|
Ok(pods.get_opt(name).await?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn scale_deployment(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
namespace: Option<&str>,
|
||||||
|
replicas: u32,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let deployments: Api<Deployment> = if let Some(ns) = namespace {
|
||||||
|
Api::namespaced(self.client.clone(), ns)
|
||||||
|
} else {
|
||||||
|
Api::default_namespaced(self.client.clone())
|
||||||
|
};
|
||||||
|
|
||||||
|
let patch = json!({
|
||||||
|
"spec": {
|
||||||
|
"replicas": replicas
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let pp = PatchParams::default();
|
||||||
|
let scale = Patch::Apply(&patch);
|
||||||
|
deployments.patch_scale(name, &pp, &scale).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_deployment(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
namespace: Option<&str>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let deployments: Api<Deployment> = if let Some(ns) = namespace {
|
||||||
|
Api::namespaced(self.client.clone(), ns)
|
||||||
|
} else {
|
||||||
|
Api::default_namespaced(self.client.clone())
|
||||||
|
};
|
||||||
|
let delete_params = DeleteParams::default();
|
||||||
|
deployments.delete(name, &delete_params).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn wait_until_deployment_ready(
|
pub async fn wait_until_deployment_ready(
|
||||||
&self,
|
&self,
|
||||||
name: String,
|
name: String,
|
||||||
@@ -76,6 +138,68 @@ impl K8sClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Will execute a commond in the first pod found that matches the specified label
|
||||||
|
/// '{label}={name}'
|
||||||
|
pub async fn exec_app_capture_output(
|
||||||
|
&self,
|
||||||
|
name: String,
|
||||||
|
label: String,
|
||||||
|
namespace: Option<&str>,
|
||||||
|
command: Vec<&str>,
|
||||||
|
) -> Result<String, String> {
|
||||||
|
let api: Api<Pod>;
|
||||||
|
|
||||||
|
if let Some(ns) = namespace {
|
||||||
|
api = Api::namespaced(self.client.clone(), ns);
|
||||||
|
} else {
|
||||||
|
api = Api::default_namespaced(self.client.clone());
|
||||||
|
}
|
||||||
|
let pod_list = api
|
||||||
|
.list(&ListParams::default().labels(format!("{label}={name}").as_str()))
|
||||||
|
.await
|
||||||
|
.expect("couldn't get list of pods");
|
||||||
|
|
||||||
|
let res = api
|
||||||
|
.exec(
|
||||||
|
pod_list
|
||||||
|
.items
|
||||||
|
.first()
|
||||||
|
.expect("couldn't get pod")
|
||||||
|
.name()
|
||||||
|
.expect("couldn't get pod name")
|
||||||
|
.into_owned()
|
||||||
|
.as_str(),
|
||||||
|
command,
|
||||||
|
&AttachParams::default().stdout(true).stderr(true),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
match res {
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
Ok(mut process) => {
|
||||||
|
let status = process
|
||||||
|
.take_status()
|
||||||
|
.expect("Couldn't get status")
|
||||||
|
.await
|
||||||
|
.expect("Couldn't unwrap status");
|
||||||
|
|
||||||
|
if let Some(s) = status.status {
|
||||||
|
let mut stdout_buf = String::new();
|
||||||
|
if let Some(mut stdout) = process.stdout().take() {
|
||||||
|
stdout.read_to_string(&mut stdout_buf).await;
|
||||||
|
}
|
||||||
|
debug!("Status: {} - {:?}", s, status.details);
|
||||||
|
if s == "Success" {
|
||||||
|
Ok(stdout_buf)
|
||||||
|
} else {
|
||||||
|
Err(s)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err("Couldn't get inner status of pod exec".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Will execute a command in the first pod found that matches the label `app.kubernetes.io/name={name}`
|
/// Will execute a command in the first pod found that matches the label `app.kubernetes.io/name={name}`
|
||||||
pub async fn exec_app(
|
pub async fn exec_app(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -22,18 +22,12 @@ pub struct OPNSenseFirewall {
|
|||||||
host: LogicalHost,
|
host: LogicalHost,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO figure out a design to have a unique identifiere for this firewall
|
|
||||||
// I think a project identifier would be good enough, then the secrets module configuration will
|
|
||||||
// point to the project's vault and this opnsense modules doesn't need to know anything about it
|
|
||||||
const OPNSENSE_CREDENTIALS: &str = "OPNSENSE_CREDENTIALS";
|
|
||||||
|
|
||||||
impl OPNSenseFirewall {
|
impl OPNSenseFirewall {
|
||||||
pub fn get_ip(&self) -> IpAddress {
|
pub fn get_ip(&self) -> IpAddress {
|
||||||
self.host.ip
|
self.host.ip
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new(host: LogicalHost, port: Option<u16>, username: &str, password: &str) -> Self {
|
pub async fn new(host: LogicalHost, port: Option<u16>, username: &str, password: &str) -> Self {
|
||||||
// let credentials = Secrets::get_by_name(OPNSENSE_CREDENTIALS)
|
|
||||||
Self {
|
Self {
|
||||||
opnsense_config: Arc::new(RwLock::new(
|
opnsense_config: Arc::new(RwLock::new(
|
||||||
opnsense_config::Config::from_credentials(host.ip, port, username, password).await,
|
opnsense_config::Config::from_credentials(host.ip, port, username, password).await,
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ pub mod monitoring;
|
|||||||
pub mod okd;
|
pub mod okd;
|
||||||
pub mod opnsense;
|
pub mod opnsense;
|
||||||
pub mod prometheus;
|
pub mod prometheus;
|
||||||
|
pub mod storage;
|
||||||
pub mod tenant;
|
pub mod tenant;
|
||||||
pub mod tftp;
|
pub mod tftp;
|
||||||
|
|||||||
@@ -1,868 +0,0 @@
|
|||||||
//! OKDInstallationScore
|
|
||||||
//!
|
|
||||||
//! Overview
|
|
||||||
//! --------
|
|
||||||
//! OKDInstallationScore orchestrates an end-to-end, bare-metal OKD (OpenShift/OKD 4.19)
|
|
||||||
//! installation using Harmony’s strongly-typed Scores and Interprets. It encodes the
|
|
||||||
//! “discovery-first, then provision” strategy with strict ordering, observable progress,
|
|
||||||
//! and minimal assumptions about the underlying network.
|
|
||||||
//!
|
|
||||||
//! Design goals
|
|
||||||
//! - Deterministic, observable pipeline from unknown hardware to a healthy OKD cluster.
|
|
||||||
//! - Do NOT require LACP bonding during PXE/inventory. Bonding is configured only
|
|
||||||
//! after the host has a stable OS on disk (SCOS/RHCOS) and OKD MachineConfigs/NNCP
|
|
||||||
//! can enforce persistence safely.
|
|
||||||
//! - Support per-MAC iPXE rendering without requiring multiple DHCP reservations for
|
|
||||||
//! the same host. Discovery runs with generic DHCP (access/unbonded). Role-specific
|
|
||||||
//! per-MAC PXE entries are activated just-in-time before install.
|
|
||||||
//! - Emit HarmonyEvent instrumentation at each step via the Score::interpret path.
|
|
||||||
//!
|
|
||||||
//! High-level flow
|
|
||||||
//! 1) OKDSetup01Inventory
|
|
||||||
//! - Serve default iPXE + Kickstart (in-RAM CentOS Stream 9) for discovery only.
|
|
||||||
//! - Enable SSH with the cluster’s ephemeral pubkey, start a Rust inventory agent.
|
|
||||||
//! - Harmony discovers nodes by scraping the agent endpoint and collects MACs/NICs.
|
|
||||||
//! - DNS: optionally register temporary hostnames and enable DHCP lease registration.
|
|
||||||
//!
|
|
||||||
//! 2) OKDSetup02Bootstrap
|
|
||||||
//! - User selects which discovered node becomes bootstrap.
|
|
||||||
//! - Render per-MAC iPXE for bootstrap with OKD 4.19 SCOS live assets + ignition.
|
|
||||||
//! - Reboot node via SSH; install bootstrap; wait for bootstrap-complete.
|
|
||||||
//!
|
|
||||||
//! 3) OKDSetup03ControlPlane
|
|
||||||
//! - Render per-MAC iPXE for cp0/cp1/cp2 with ignition (includes persistent bond via
|
|
||||||
//! MachineConfig or NNCP if required). Reboot via SSH, join masters.
|
|
||||||
//!
|
|
||||||
//! 4) OKDSetup04Workers
|
|
||||||
//! - Render per-MAC iPXE for worker set; join workers.
|
|
||||||
//!
|
|
||||||
//! 5) OKDSetup05SanityCheck
|
|
||||||
//! - Validate API/ingress/clusteroperators; ensure healthy control plane and SDN.
|
|
||||||
//!
|
|
||||||
//! 6) OKDSetup06InstallationReport
|
|
||||||
//! - Produce a concise, machine-readable report (JSON) and a human summary.
|
|
||||||
//!
|
|
||||||
//! Network notes
|
|
||||||
//! - During Inventory: ports must be simple access (no LACP). DHCP succeeds; iPXE
|
|
||||||
//! loads CentOS Stream live with Kickstart and starts the inventory endpoint.
|
|
||||||
//! - During Provisioning: only after SCOS is on disk and Ignition/MC can be applied
|
|
||||||
//! do we set the bond persistently. If early bonding is truly required on a host,
|
|
||||||
//! use kernel args selectively in the per-MAC PXE for that host, but never for the
|
|
||||||
//! generic discovery path.
|
|
||||||
//!
|
|
||||||
//! DNS and hostname
|
|
||||||
//! - Because a single host may present multiple MACs, but DHCP/ISC on OPNsense may not
|
|
||||||
//! easily support “one hostname across multiple MACs” in a single lease entry, we avoid
|
|
||||||
//! strict hostname binding during discovery. We rely on dynamic leases and record the
|
|
||||||
//! mapping (IP/MAC) at scrape time.
|
|
||||||
//! - Once a role is assigned, we render a per-MAC PXE entry and ensure the role-specific
|
|
||||||
//! DNS A/AAAA/CNAME entries are present (e.g., api, api-int, apps wildcard). This keeps
|
|
||||||
//! DHCP simple and DNS consistent for OKD.
|
|
||||||
//!
|
|
||||||
//! Instrumentation
|
|
||||||
//! - All child Scores are executed via Score::interpret, which emits HarmonyEvent
|
|
||||||
//! InterpretExecutionStarted/Finished. The orchestrator also emits HarmonyStarted/
|
|
||||||
//! HarmonyFinished around the full pipeline execution.
|
|
||||||
//!
|
|
||||||
//! Configuration knobs
|
|
||||||
//! - lan_cidr: CIDR to scan/allow for discovery endpoints.
|
|
||||||
//! - public_domain: External wildcard/apps domain (e.g., apps.example.com).
|
|
||||||
//! - internal_domain: Internal cluster domain (e.g., cluster.local or harmony.mcd).
|
|
||||||
//!
|
|
||||||
//! Notes
|
|
||||||
//! - This file co-locates step Scores for ease of review. In follow-up changes, refactor
|
|
||||||
//! step Scores (OKDSetupXX*) into separate modules.
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use derive_new::new;
|
|
||||||
use harmony_macros::{ip, ipv4};
|
|
||||||
use log::info;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
data::Version,
|
|
||||||
instrumentation::{HarmonyEvent, instrument},
|
|
||||||
interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
|
|
||||||
inventory::Inventory,
|
|
||||||
score::Score,
|
|
||||||
topology::{DnsRecord, DnsRecordType, DnsServer, Topology},
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Public Orchestrator Score
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, new)]
|
|
||||||
pub struct OKDInstallationScore {
|
|
||||||
/// The LAN CIDR where discovery endpoints live (e.g., 192.168.10.0/24)
|
|
||||||
pub lan_cidr: String,
|
|
||||||
/// Public external domain (e.g., example.com). Used for api/apps wildcard, etc.
|
|
||||||
pub public_domain: String,
|
|
||||||
/// Internal cluster domain (e.g., harmony.mcd). Used for internal svc/ingress and DNS.
|
|
||||||
pub internal_domain: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Topology + DnsServer + 'static> Score<T> for OKDInstallationScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDInstallationInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDInstallationScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Orchestrator Interpret
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct OKDInstallationInterpret {
|
|
||||||
score: OKDInstallationScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDInstallationInterpret {
|
|
||||||
pub fn new(score: OKDInstallationScore) -> Self {
|
|
||||||
let version = Version::from("0.1.0").expect("valid version");
|
|
||||||
Self {
|
|
||||||
score,
|
|
||||||
version,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_inventory_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
// 1) Prepare DNS and DHCP lease registration (optional)
|
|
||||||
let dns_score = OKDSetup01InventoryDnsScore::new(
|
|
||||||
self.score.internal_domain.clone(),
|
|
||||||
self.score.public_domain.clone(),
|
|
||||||
Some(true), // register_dhcp_leases
|
|
||||||
);
|
|
||||||
dns_score.interpret(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 2) Serve default iPXE + Kickstart and poll discovery
|
|
||||||
let discovery_score = OKDSetup01InventoryScore::new(self.score.lan_cidr.clone());
|
|
||||||
discovery_score.interpret(inventory, topology).await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_bootstrap_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
// Select and provision bootstrap
|
|
||||||
let bootstrap_score = OKDSetup02BootstrapScore::new(
|
|
||||||
self.score.public_domain.clone(),
|
|
||||||
self.score.internal_domain.clone(),
|
|
||||||
);
|
|
||||||
bootstrap_score.interpret(inventory, topology).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_control_plane_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
let control_plane_score = OKDSetup03ControlPlaneScore::new();
|
|
||||||
control_plane_score.interpret(inventory, topology).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_workers_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
let workers_score = OKDSetup04WorkersScore::new();
|
|
||||||
workers_score.interpret(inventory, topology).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_sanity_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
let sanity_score = OKDSetup05SanityCheckScore::new();
|
|
||||||
sanity_score.interpret(inventory, topology).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_report_phase<T: Topology + DnsServer>(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
let report_score = OKDSetup06InstallationReportScore::new(
|
|
||||||
self.score.public_domain.clone(),
|
|
||||||
self.score.internal_domain.clone(),
|
|
||||||
);
|
|
||||||
report_score.interpret(inventory, topology).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology + DnsServer> Interpret<T> for OKDInstallationInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDInstallationInterpret")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
instrument(HarmonyEvent::HarmonyStarted).ok();
|
|
||||||
|
|
||||||
info!(
|
|
||||||
"Starting OKD installation pipeline for public_domain={} internal_domain={} lan_cidr={}",
|
|
||||||
self.score.public_domain, self.score.internal_domain, self.score.lan_cidr
|
|
||||||
);
|
|
||||||
|
|
||||||
// 1) Inventory (default PXE, in-RAM kickstart, Rust inventory agent)
|
|
||||||
self.run_inventory_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 2) Bootstrap (render per-MAC iPXE + ignition; reboot node; wait for bootstrap complete)
|
|
||||||
self.run_bootstrap_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 3) Control plane
|
|
||||||
self.run_control_plane_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 4) Workers
|
|
||||||
self.run_workers_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 5) Sanity checks
|
|
||||||
self.run_sanity_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
// 6) Installation report
|
|
||||||
self.run_report_phase(inventory, topology).await?;
|
|
||||||
|
|
||||||
instrument(HarmonyEvent::HarmonyFinished).ok();
|
|
||||||
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"OKD installation pipeline completed".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 01: Inventory DNS setup
|
|
||||||
// - Keep DHCP simple; optionally register dynamic leases into DNS.
|
|
||||||
// - Ensure base records for internal/public domains (api/api-int/apps wildcard).
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup01InventoryDnsScore {
|
|
||||||
internal_domain: String,
|
|
||||||
public_domain: String,
|
|
||||||
register_dhcp_leases: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Topology + DnsServer> Score<T> for OKDSetup01InventoryDnsScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup01InventoryDnsInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup01InventoryDnsScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup01InventoryDnsInterpret {
|
|
||||||
score: OKDSetup01InventoryDnsScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup01InventoryDnsInterpret {
|
|
||||||
pub fn new(score: OKDSetup01InventoryDnsScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn ensure_dns<T: DnsServer>(&self, dns: &T) -> Result<(), InterpretError> {
|
|
||||||
// Minimal records placeholders; real IPs are set elsewhere in the flow.
|
|
||||||
// We register the names early to ensure resolvability for clients relying on DNS.
|
|
||||||
let mut records: Vec<DnsRecord> = vec![
|
|
||||||
DnsRecord {
|
|
||||||
value: ip!("0.0.0.0"),
|
|
||||||
host: "api".to_string(),
|
|
||||||
domain: self.score.internal_domain.clone(),
|
|
||||||
record_type: DnsRecordType::A,
|
|
||||||
},
|
|
||||||
DnsRecord {
|
|
||||||
value: ip!("0.0.0.0"),
|
|
||||||
host: "api-int".to_string(),
|
|
||||||
domain: self.score.internal_domain.clone(),
|
|
||||||
record_type: DnsRecordType::A,
|
|
||||||
},
|
|
||||||
DnsRecord {
|
|
||||||
value: ip!("0.0.0.0"),
|
|
||||||
host: "*.apps.".to_string(),
|
|
||||||
domain: self.score.internal_domain.clone(),
|
|
||||||
record_type: DnsRecordType::A,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
dns.ensure_hosts_registered(records.drain(..).collect())
|
|
||||||
.await?;
|
|
||||||
if let Some(register) = self.score.register_dhcp_leases {
|
|
||||||
dns.register_dhcp_leases(register).await?;
|
|
||||||
}
|
|
||||||
dns.commit_config().await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology + DnsServer> Interpret<T> for OKDSetup01InventoryDnsInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup01InventoryDns")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
info!("Ensuring base DNS and DHCP lease registration for discovery phase");
|
|
||||||
self.ensure_dns(topology).await?;
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Inventory DNS prepared".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 01: Inventory (default PXE + Kickstart in RAM + Rust agent)
|
|
||||||
// - This score exposes/ensures the default inventory assets and waits for discoveries.
|
|
||||||
// - No early bonding. Simple access DHCP.
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup01InventoryScore {
|
|
||||||
lan_cidr: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup01InventoryScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup01InventoryInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup01InventoryScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup01InventoryInterpret {
|
|
||||||
score: OKDSetup01InventoryScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup01InventoryInterpret {
|
|
||||||
pub fn new(score: OKDSetup01InventoryScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn ensure_inventory_assets<T: Topology>(
|
|
||||||
&self,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<(), InterpretError> {
|
|
||||||
// Placeholder: push or verify iPXE default, Kickstart, and Rust inventory agent are hosted.
|
|
||||||
// Real implementation: publish to the PXE/HTTP server via the topology.
|
|
||||||
info!(
|
|
||||||
"[Inventory] Ensuring default iPXE, Kickstart, and inventory agent are available for LAN {}",
|
|
||||||
self.score.lan_cidr
|
|
||||||
);
|
|
||||||
// topology.publish_http_asset(…) ?
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn discover_nodes(&self) -> Result<usize, InterpretError> {
|
|
||||||
// Placeholder: implement Harmony discovery logic (scan/pull/push mode).
|
|
||||||
// Returns number of newly discovered nodes.
|
|
||||||
info!(
|
|
||||||
"[Inventory] Scanning for inventory agents in {}",
|
|
||||||
self.score.lan_cidr
|
|
||||||
);
|
|
||||||
// In practice, this would query harmony_composer or a local registry store.
|
|
||||||
Ok(3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup01InventoryInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup01Inventory")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.ensure_inventory_assets(topology).await?;
|
|
||||||
let count = self.discover_nodes().await?;
|
|
||||||
info!("[Inventory] Discovered {count} nodes");
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
format!("Inventory phase complete. Nodes discovered: {count}"),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 02: Bootstrap
|
|
||||||
// - Select bootstrap node (from discovered set).
|
|
||||||
// - Render per-MAC iPXE pointing to OKD 4.19 SCOS live assets + bootstrap ignition.
|
|
||||||
// - Reboot the host via SSH and wait for bootstrap-complete.
|
|
||||||
// - No bonding at this stage unless absolutely required; prefer persistence via MC later.
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup02BootstrapScore {
|
|
||||||
public_domain: String,
|
|
||||||
internal_domain: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup02BootstrapScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup02BootstrapInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup02BootstrapScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup02BootstrapInterpret {
|
|
||||||
score: OKDSetup02BootstrapScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup02BootstrapInterpret {
|
|
||||||
pub fn new(score: OKDSetup02BootstrapScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn render_per_mac_pxe(&self) -> Result<(), InterpretError> {
|
|
||||||
// Placeholder: use Harmony templates to emit {MAC}.ipxe selecting SCOS live + bootstrap ignition.
|
|
||||||
info!("[Bootstrap] Rendering per-MAC PXE for bootstrap node");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn reboot_target(&self) -> Result<(), InterpretError> {
|
|
||||||
// Placeholder: ssh reboot using the inventory ephemeral key
|
|
||||||
info!("[Bootstrap] Rebooting bootstrap node via SSH");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn wait_for_bootstrap_complete(&self) -> Result<(), InterpretError> {
|
|
||||||
// Placeholder: wait-for bootstrap-complete
|
|
||||||
info!("[Bootstrap] Waiting for bootstrap-complete …");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup02BootstrapInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup02Bootstrap")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
_topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.render_per_mac_pxe().await?;
|
|
||||||
self.reboot_target().await?;
|
|
||||||
self.wait_for_bootstrap_complete().await?;
|
|
||||||
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Bootstrap phase complete".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 03: Control Plane
|
|
||||||
// - Render per-MAC PXE & ignition for cp0/cp1/cp2.
|
|
||||||
// - Persist bonding via MachineConfigs (or NNCP) once SCOS is active.
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup03ControlPlaneScore {}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup03ControlPlaneScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup03ControlPlaneInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup03ControlPlaneScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup03ControlPlaneInterpret {
|
|
||||||
score: OKDSetup03ControlPlaneScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup03ControlPlaneInterpret {
|
|
||||||
pub fn new(score: OKDSetup03ControlPlaneScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn render_and_reboot(&self) -> Result<(), InterpretError> {
|
|
||||||
info!("[ControlPlane] Rendering per-MAC PXE for masters and rebooting");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn persist_network_bond(&self) -> Result<(), InterpretError> {
|
|
||||||
// Generate MC or NNCP from inventory NIC data; apply via ignition or post-join.
|
|
||||||
info!("[ControlPlane] Ensuring persistent bonding via MachineConfig/NNCP");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup03ControlPlaneInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup03ControlPlane")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
_topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.render_and_reboot().await?;
|
|
||||||
self.persist_network_bond().await?;
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Control plane provisioned".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 04: Workers
|
|
||||||
// - Render per-MAC PXE & ignition for workers; join nodes.
|
|
||||||
// - Persist bonding via MC/NNCP as required (same approach as masters).
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup04WorkersScore {}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup04WorkersScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup04WorkersInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup04WorkersScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup04WorkersInterpret {
|
|
||||||
score: OKDSetup04WorkersScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup04WorkersInterpret {
|
|
||||||
pub fn new(score: OKDSetup04WorkersScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn render_and_reboot(&self) -> Result<(), InterpretError> {
|
|
||||||
info!("[Workers] Rendering per-MAC PXE for workers and rebooting");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup04WorkersInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup04Workers")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
_topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.render_and_reboot().await?;
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Workers provisioned".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 05: Sanity Check
|
|
||||||
// - Validate API reachability, ClusterOperators, ingress, and SDN status.
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup05SanityCheckScore {}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup05SanityCheckScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup05SanityCheckInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup05SanityCheckScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup05SanityCheckInterpret {
|
|
||||||
score: OKDSetup05SanityCheckScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup05SanityCheckInterpret {
|
|
||||||
pub fn new(score: OKDSetup05SanityCheckScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run_checks(&self) -> Result<(), InterpretError> {
|
|
||||||
info!("[Sanity] Checking API, COs, Ingress, and SDN health …");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup05SanityCheckInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup05SanityCheck")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
_topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.run_checks().await?;
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Sanity checks passed".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
// Step 06: Installation Report
|
|
||||||
// - Emit JSON and concise human summary of nodes, roles, versions, and health.
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, new)]
|
|
||||||
struct OKDSetup06InstallationReportScore {
|
|
||||||
public_domain: String,
|
|
||||||
internal_domain: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Topology> Score<T> for OKDSetup06InstallationReportScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
|
||||||
Box::new(OKDSetup06InstallationReportInterpret::new(self.clone()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
"OKDSetup06InstallationReportScore".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct OKDSetup06InstallationReportInterpret {
|
|
||||||
score: OKDSetup06InstallationReportScore,
|
|
||||||
version: Version,
|
|
||||||
status: InterpretStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OKDSetup06InstallationReportInterpret {
|
|
||||||
pub fn new(score: OKDSetup06InstallationReportScore) -> Self {
|
|
||||||
let version = Version::from("1.0.0").unwrap();
|
|
||||||
Self {
|
|
||||||
version,
|
|
||||||
score,
|
|
||||||
status: InterpretStatus::QUEUED,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn generate(&self) -> Result<(), InterpretError> {
|
|
||||||
info!(
|
|
||||||
"[Report] Generating installation report for {} / {}",
|
|
||||||
self.score.public_domain, self.score.internal_domain
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T: Topology> Interpret<T> for OKDSetup06InstallationReportInterpret {
|
|
||||||
fn get_name(&self) -> InterpretName {
|
|
||||||
InterpretName::Custom("OKDSetup06InstallationReport")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version(&self) -> Version {
|
|
||||||
self.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_status(&self) -> InterpretStatus {
|
|
||||||
self.status.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_children(&self) -> Vec<crate::domain::data::Id> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(
|
|
||||||
&self,
|
|
||||||
_inventory: &Inventory,
|
|
||||||
_topology: &T,
|
|
||||||
) -> Result<Outcome, InterpretError> {
|
|
||||||
self.generate().await?;
|
|
||||||
Ok(Outcome::new(
|
|
||||||
InterpretStatus::SUCCESS,
|
|
||||||
"Installation report generated".into(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,5 @@ pub mod bootstrap_dhcp;
|
|||||||
pub mod bootstrap_load_balancer;
|
pub mod bootstrap_load_balancer;
|
||||||
pub mod dhcp;
|
pub mod dhcp;
|
||||||
pub mod dns;
|
pub mod dns;
|
||||||
pub mod installation;
|
|
||||||
pub mod load_balancer;
|
pub mod load_balancer;
|
||||||
pub mod upgrade;
|
pub mod upgrade;
|
||||||
|
|||||||
419
harmony/src/modules/storage/ceph/ceph_remove_osd_score.rs
Normal file
419
harmony/src/modules/storage/ceph/ceph_remove_osd_score.rs
Normal file
@@ -0,0 +1,419 @@
|
|||||||
|
use std::{
|
||||||
|
process::Command,
|
||||||
|
sync::Arc,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use log::{info, warn};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tokio::time::sleep;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
data::{Id, Version},
|
||||||
|
interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
|
||||||
|
inventory::Inventory,
|
||||||
|
score::Score,
|
||||||
|
topology::{K8sclient, Topology, k8s::K8sClient},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct CephRemoveOsd {
|
||||||
|
pub osd_deployment_name: String,
|
||||||
|
pub rook_ceph_namespace: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Topology + K8sclient> Score<T> for CephRemoveOsd {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
format!("CephRemoveOsdScore")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
||||||
|
Box::new(CephRemoveOsdInterpret {
|
||||||
|
score: self.clone(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct CephRemoveOsdInterpret {
|
||||||
|
score: CephRemoveOsd,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<T: Topology + K8sclient> Interpret<T> for CephRemoveOsdInterpret {
|
||||||
|
async fn execute(
|
||||||
|
&self,
|
||||||
|
_inventory: &Inventory,
|
||||||
|
topology: &T,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
let client = topology.k8s_client().await.unwrap();
|
||||||
|
self.verify_ceph_toolbox_exists(client.clone()).await?;
|
||||||
|
self.scale_deployment(client.clone()).await?;
|
||||||
|
self.verify_deployment_scaled(client.clone()).await?;
|
||||||
|
self.delete_deployment(client.clone()).await?;
|
||||||
|
self.verify_deployment_deleted(client.clone()).await?;
|
||||||
|
let osd_id_full = self.get_ceph_osd_id().unwrap();
|
||||||
|
self.purge_ceph_osd(client.clone(), &osd_id_full).await?;
|
||||||
|
self.verify_ceph_osd_removal(client.clone(), &osd_id_full)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(Outcome::success(format!(
|
||||||
|
"Successfully removed OSD {} from rook-ceph cluster by deleting deployment {}",
|
||||||
|
osd_id_full, self.score.osd_deployment_name
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
fn get_name(&self) -> InterpretName {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_version(&self) -> Version {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_status(&self) -> InterpretStatus {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_children(&self) -> Vec<Id> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CephRemoveOsdInterpret {
|
||||||
|
pub fn get_ceph_osd_id(&self) -> Result<String, InterpretError> {
|
||||||
|
let osd_id_numeric = self
|
||||||
|
.score
|
||||||
|
.osd_deployment_name
|
||||||
|
.split('-')
|
||||||
|
.nth(3)
|
||||||
|
.ok_or_else(|| {
|
||||||
|
InterpretError::new(format!(
|
||||||
|
"Could not parse OSD id from deployment name {}",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
let osd_id_full = format!("osd.{}", osd_id_numeric);
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Targeting Ceph OSD: {} (parsed from deployment {})",
|
||||||
|
osd_id_full, self.score.osd_deployment_name
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(osd_id_full)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_ceph_toolbox_exists(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
let toolbox_dep = "rook-ceph-tools".to_string();
|
||||||
|
|
||||||
|
match client
|
||||||
|
.get_deployment(&toolbox_dep, Some(&self.score.rook_ceph_namespace))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Some(deployment)) => {
|
||||||
|
if let Some(status) = deployment.status {
|
||||||
|
let ready_count = status.ready_replicas.unwrap_or(0);
|
||||||
|
if ready_count >= 1 {
|
||||||
|
return Ok(Outcome::success(format!(
|
||||||
|
"'{}' is ready with {} replica(s).",
|
||||||
|
&toolbox_dep, ready_count
|
||||||
|
)));
|
||||||
|
} else {
|
||||||
|
return Err(InterpretError::new(
|
||||||
|
"ceph-tool-box not ready in cluster".to_string(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(InterpretError::new(format!(
|
||||||
|
"failed to get deployment status {}",
|
||||||
|
&toolbox_dep
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(None) => Err(InterpretError::new(format!(
|
||||||
|
"Deployment '{}' not found in namespace '{}'.",
|
||||||
|
&toolbox_dep, self.score.rook_ceph_namespace
|
||||||
|
))),
|
||||||
|
Err(e) => Err(InterpretError::new(format!(
|
||||||
|
"Failed to query for deployment '{}': {}",
|
||||||
|
&toolbox_dep, e
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn scale_deployment(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
info!(
|
||||||
|
"Scaling down OSD deployment: {}",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
);
|
||||||
|
client
|
||||||
|
.scale_deployment(
|
||||||
|
&self.score.osd_deployment_name,
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(Outcome::success(format!(
|
||||||
|
"Scaled down deployment {}",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_deployment_scaled(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
let (timeout, interval, start) = self.build_timer();
|
||||||
|
|
||||||
|
info!("Waiting for OSD deployment to scale down to 0 replicas");
|
||||||
|
loop {
|
||||||
|
let dep = client
|
||||||
|
.get_deployment(
|
||||||
|
&self.score.osd_deployment_name,
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if let Some(deployment) = dep {
|
||||||
|
if let Some(status) = deployment.status {
|
||||||
|
if status.replicas.unwrap_or(1) == 0 && status.ready_replicas.unwrap_or(1) == 0
|
||||||
|
{
|
||||||
|
return Ok(Outcome::success(
|
||||||
|
"Deployment successfully scaled down.".to_string(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if start.elapsed() > timeout {
|
||||||
|
return Err(InterpretError::new(format!(
|
||||||
|
"Timed out waiting for deployment {} to scale down",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
sleep(interval).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_timer(&self) -> (Duration, Duration, Instant) {
|
||||||
|
let timeout = Duration::from_secs(120);
|
||||||
|
let interval = Duration::from_secs(5);
|
||||||
|
let start = Instant::now();
|
||||||
|
(timeout, interval, start)
|
||||||
|
}
|
||||||
|
pub async fn delete_deployment(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
info!(
|
||||||
|
"Deleting OSD deployment: {}",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
);
|
||||||
|
client
|
||||||
|
.delete_deployment(
|
||||||
|
&self.score.osd_deployment_name,
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(Outcome::success(format!(
|
||||||
|
"deployment {} deleted",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_deployment_deleted(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
let (timeout, interval, start) = self.build_timer();
|
||||||
|
|
||||||
|
info!("Waiting for OSD deployment to scale down to 0 replicas");
|
||||||
|
loop {
|
||||||
|
let dep = client
|
||||||
|
.get_deployment(
|
||||||
|
&self.score.osd_deployment_name,
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if dep.is_none() {
|
||||||
|
info!(
|
||||||
|
"Deployment {} successfully deleted.",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
);
|
||||||
|
return Ok(Outcome::success(format!(
|
||||||
|
"Deployment {} deleted.",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if start.elapsed() > timeout {
|
||||||
|
return Err(InterpretError::new(format!(
|
||||||
|
"Timed out waiting for deployment {} to be deleted",
|
||||||
|
self.score.osd_deployment_name
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
sleep(interval).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_osd_tree(&self, json: serde_json::Value) -> Result<CephOsdTree, InterpretError> {
|
||||||
|
let nodes = json.get("nodes").ok_or_else(|| {
|
||||||
|
InterpretError::new("Missing 'nodes' field in ceph osd tree JSON".to_string())
|
||||||
|
})?;
|
||||||
|
let tree: CephOsdTree = CephOsdTree {
|
||||||
|
nodes: serde_json::from_value(nodes.clone()).map_err(|e| {
|
||||||
|
InterpretError::new(format!("Failed to parse ceph osd tree JSON: {}", e))
|
||||||
|
})?,
|
||||||
|
};
|
||||||
|
Ok(tree)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn purge_ceph_osd(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
osd_id_full: &str,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
info!(
|
||||||
|
"Purging OSD {} from Ceph cluster and removing its auth key",
|
||||||
|
osd_id_full
|
||||||
|
);
|
||||||
|
client
|
||||||
|
.exec_app_capture_output(
|
||||||
|
"rook-ceph-tools".to_string(),
|
||||||
|
"app".to_string(),
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
vec![
|
||||||
|
format!("ceph osd purge {osd_id_full} --yes-i-really-mean-it").as_str(),
|
||||||
|
format!("ceph auth del osd.{osd_id_full}").as_str(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(Outcome::success(format!(
|
||||||
|
"osd id {} removed from osd tree",
|
||||||
|
osd_id_full
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn verify_ceph_osd_removal(
|
||||||
|
&self,
|
||||||
|
client: Arc<K8sClient>,
|
||||||
|
osd_id_full: &str,
|
||||||
|
) -> Result<Outcome, InterpretError> {
|
||||||
|
let (timeout, interval, start) = self.build_timer();
|
||||||
|
info!(
|
||||||
|
"Verifying OSD {} has been removed from the Ceph tree...",
|
||||||
|
osd_id_full
|
||||||
|
);
|
||||||
|
loop {
|
||||||
|
let output = client
|
||||||
|
.exec_app_capture_output(
|
||||||
|
"rook-ceph-tools".to_string(),
|
||||||
|
"app".to_string(),
|
||||||
|
Some(&self.score.rook_ceph_namespace),
|
||||||
|
vec!["ceph osd tree -f json"],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let tree =
|
||||||
|
self.get_osd_tree(serde_json::from_str(&output).expect("could not extract json"));
|
||||||
|
|
||||||
|
let osd_found = tree
|
||||||
|
.unwrap()
|
||||||
|
.nodes
|
||||||
|
.iter()
|
||||||
|
.any(|node| node.name == osd_id_full);
|
||||||
|
|
||||||
|
if !osd_found {
|
||||||
|
return Ok(Outcome::success(format!(
|
||||||
|
"Successfully verified that OSD {} is removed from the Ceph cluster.",
|
||||||
|
osd_id_full,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if start.elapsed() > timeout {
|
||||||
|
return Err(InterpretError::new(format!(
|
||||||
|
"Timed out waiting for OSD {} to be removed from Ceph tree",
|
||||||
|
osd_id_full
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
warn!(
|
||||||
|
"OSD {} still found in Ceph tree, retrying in {:?}...",
|
||||||
|
osd_id_full, interval
|
||||||
|
);
|
||||||
|
sleep(interval).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
|
pub struct CephOsdTree {
|
||||||
|
pub nodes: Vec<CephNode>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
|
pub struct CephNode {
|
||||||
|
pub id: i32,
|
||||||
|
pub name: String,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub node_type: String,
|
||||||
|
pub type_id: Option<i32>,
|
||||||
|
pub children: Option<Vec<i32>>,
|
||||||
|
pub exists: Option<i32>,
|
||||||
|
pub status: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_osd_tree() {
|
||||||
|
let json_data = json!({
|
||||||
|
"nodes": [
|
||||||
|
{"id": 1, "name": "osd.1", "type": "osd", "primary_affinity":"1"},
|
||||||
|
{"id": 2, "name": "osd.2", "type": "osd", "crush_weight": 1.22344}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
let interpret = CephRemoveOsdInterpret {
|
||||||
|
score: CephRemoveOsd {
|
||||||
|
osd_deployment_name: "osd-1".to_string(),
|
||||||
|
rook_ceph_namespace: "dummy_ns".to_string(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let json = interpret.get_osd_tree(json_data).unwrap();
|
||||||
|
|
||||||
|
let expected = CephOsdTree {
|
||||||
|
nodes: vec![
|
||||||
|
CephNode {
|
||||||
|
id: 1,
|
||||||
|
name: "osd.1".to_string(),
|
||||||
|
node_type: "osd".to_string(),
|
||||||
|
type_id: None,
|
||||||
|
children: None,
|
||||||
|
exists: None,
|
||||||
|
status: None,
|
||||||
|
},
|
||||||
|
CephNode {
|
||||||
|
id: 2,
|
||||||
|
name: "osd.2".to_string(),
|
||||||
|
node_type: "osd".to_string(),
|
||||||
|
type_id: None,
|
||||||
|
children: None,
|
||||||
|
exists: None,
|
||||||
|
status: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(json, expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
harmony/src/modules/storage/ceph/mod.rs
Normal file
1
harmony/src/modules/storage/ceph/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod ceph_remove_osd_score;
|
||||||
1
harmony/src/modules/storage/mod.rs
Normal file
1
harmony/src/modules/storage/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod ceph;
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
use async_trait::async_trait;
|
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use crate::{interpret::InterpretError, score::Score, topology::Topology};
|
|
||||||
|
|
||||||
/// Create and manage Tenant Credentials.
|
|
||||||
///
|
|
||||||
/// This is meant to be used by cluster administrators who need to provide their tenant users and
|
|
||||||
/// services with credentials to access their resources.
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
|
||||||
pub struct TenantCredentialScore;
|
|
||||||
|
|
||||||
impl<T: Topology + TenantCredentialManager> Score<T> for TenantCredentialScore {
|
|
||||||
fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
pub trait TenantCredentialManager {
|
|
||||||
async fn create_user(&self) -> Result<TenantCredentialBundle, InterpretError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct CredentialMetadata {
|
|
||||||
pub tenant_id: String,
|
|
||||||
pub credential_id: String,
|
|
||||||
pub description: String,
|
|
||||||
pub created_at: DateTime<Utc>,
|
|
||||||
pub expires_at: Option<DateTime<Utc>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub enum CredentialData {
|
|
||||||
/// Used to store login instructions destined to a human. Akin to AWS login instructions email
|
|
||||||
/// upon new console user creation.
|
|
||||||
PlainText(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub struct TenantCredentialBundle {
|
|
||||||
_metadata: CredentialMetadata,
|
|
||||||
_content: CredentialData,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TenantCredentialBundle {}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "harmony-secret"
|
|
||||||
edition = "2024"
|
|
||||||
version.workspace = true
|
|
||||||
readme.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
harmony-secret-derive = { version = "0.1.0", path = "../harmony_secret_derive" }
|
|
||||||
serde = { version = "1.0.209", features = ["derive", "rc"] }
|
|
||||||
serde_json = "1.0.127"
|
|
||||||
thiserror.workspace = true
|
|
||||||
lazy_static.workspace = true
|
|
||||||
directories.workspace = true
|
|
||||||
log.workspace = true
|
|
||||||
infisical = "0.0.2"
|
|
||||||
tokio.workspace = true
|
|
||||||
async-trait.workspace = true
|
|
||||||
http.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
pretty_assertions.workspace = true
|
|
||||||
tempfile.workspace = true
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
pub static ref SECRET_NAMESPACE: String =
|
|
||||||
std::env::var("HARMONY_SECRET_NAMESPACE").expect("HARMONY_SECRET_NAMESPACE environment variable is required, it should contain the name of the project you are working on to access its secrets");
|
|
||||||
pub static ref SECRET_STORE: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_STORE").ok();
|
|
||||||
pub static ref INFISICAL_URL: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_INFISICAL_URL").ok();
|
|
||||||
pub static ref INFISICAL_PROJECT_ID: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_INFISICAL_PROJECT_ID").ok();
|
|
||||||
pub static ref INFISICAL_ENVIRONMENT: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_INFISICAL_ENVIRONMENT").ok();
|
|
||||||
pub static ref INFISICAL_CLIENT_ID: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_INFISICAL_CLIENT_ID").ok();
|
|
||||||
pub static ref INFISICAL_CLIENT_SECRET: Option<String> =
|
|
||||||
std::env::var("HARMONY_SECRET_INFISICAL_CLIENT_SECRET").ok();
|
|
||||||
}
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
pub mod config;
|
|
||||||
mod store;
|
|
||||||
|
|
||||||
use crate::config::SECRET_NAMESPACE;
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use config::INFISICAL_CLIENT_ID;
|
|
||||||
use config::INFISICAL_CLIENT_SECRET;
|
|
||||||
use config::INFISICAL_ENVIRONMENT;
|
|
||||||
use config::INFISICAL_PROJECT_ID;
|
|
||||||
use config::INFISICAL_URL;
|
|
||||||
use config::SECRET_STORE;
|
|
||||||
use serde::{Serialize, de::DeserializeOwned};
|
|
||||||
use std::fmt;
|
|
||||||
use store::InfisicalSecretStore;
|
|
||||||
use store::LocalFileSecretStore;
|
|
||||||
use thiserror::Error;
|
|
||||||
use tokio::sync::OnceCell;
|
|
||||||
|
|
||||||
pub use harmony_secret_derive::Secret;
|
|
||||||
|
|
||||||
// The Secret trait remains the same.
|
|
||||||
pub trait Secret: Serialize + DeserializeOwned + Sized {
|
|
||||||
const KEY: &'static str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The error enum remains the same.
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum SecretStoreError {
|
|
||||||
#[error("Secret not found for key '{key}' in namespace '{namespace}'")]
|
|
||||||
NotFound { namespace: String, key: String },
|
|
||||||
#[error("Failed to deserialize secret for key '{key}': {source}")]
|
|
||||||
Deserialization {
|
|
||||||
key: String,
|
|
||||||
source: serde_json::Error,
|
|
||||||
},
|
|
||||||
#[error("Failed to serialize secret for key '{key}': {source}")]
|
|
||||||
Serialization {
|
|
||||||
key: String,
|
|
||||||
source: serde_json::Error,
|
|
||||||
},
|
|
||||||
#[error("Underlying storage error: {0}")]
|
|
||||||
Store(#[from] Box<dyn std::error::Error + Send + Sync>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// The trait is now async!
|
|
||||||
#[async_trait]
|
|
||||||
pub trait SecretStore: fmt::Debug + Send + Sync {
|
|
||||||
async fn get_raw(&self, namespace: &str, key: &str) -> Result<Vec<u8>, SecretStoreError>;
|
|
||||||
async fn set_raw(
|
|
||||||
&self,
|
|
||||||
namespace: &str,
|
|
||||||
key: &str,
|
|
||||||
value: &[u8],
|
|
||||||
) -> Result<(), SecretStoreError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use OnceCell for async-friendly, one-time initialization.
|
|
||||||
static SECRET_MANAGER: OnceCell<SecretManager> = OnceCell::const_new();
|
|
||||||
|
|
||||||
/// Initializes and returns a reference to the global SecretManager.
|
|
||||||
async fn get_secret_manager() -> &'static SecretManager {
|
|
||||||
SECRET_MANAGER.get_or_init(init_secret_manager).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The async initialization function for the SecretManager.
|
|
||||||
async fn init_secret_manager() -> SecretManager {
|
|
||||||
let default_secret_score = "infisical".to_string();
|
|
||||||
let store_type = SECRET_STORE.as_ref().unwrap_or(&default_secret_score);
|
|
||||||
|
|
||||||
let store: Box<dyn SecretStore> = match store_type.as_str() {
|
|
||||||
"file" => Box::new(LocalFileSecretStore::default()),
|
|
||||||
"infisical" | _ => {
|
|
||||||
let store = InfisicalSecretStore::new(
|
|
||||||
INFISICAL_URL.clone().expect("Infisical url must be set, see harmony_secret config for ways to provide it. You can try with HARMONY_SECRET_INFISICAL_URL"),
|
|
||||||
INFISICAL_PROJECT_ID.clone().expect("Infisical project id must be set, see harmony_secret config for ways to provide it. You can try with HARMONY_SECRET_INFISICAL_PROJECT_ID"),
|
|
||||||
INFISICAL_ENVIRONMENT.clone().expect("Infisical environment must be set, see harmony_secret config for ways to provide it. You can try with HARMONY_SECRET_INFISICAL_ENVIRONMENT"),
|
|
||||||
INFISICAL_CLIENT_ID.clone().expect("Infisical client id must be set, see harmony_secret config for ways to provide it. You can try with HARMONY_SECRET_INFISICAL_CLIENT_ID"),
|
|
||||||
INFISICAL_CLIENT_SECRET.clone().expect("Infisical client secret must be set, see harmony_secret config for ways to provide it. You can try with HARMONY_SECRET_INFISICAL_CLIENT_SECRET"),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to initialize Infisical secret store");
|
|
||||||
Box::new(store)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SecretManager::new(SECRET_NAMESPACE.clone(), store)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Manages the lifecycle of secrets, providing a simple static API.
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SecretManager {
|
|
||||||
namespace: String,
|
|
||||||
store: Box<dyn SecretStore>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SecretManager {
|
|
||||||
fn new(namespace: String, store: Box<dyn SecretStore>) -> Self {
|
|
||||||
Self { namespace, store }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves and deserializes a secret.
|
|
||||||
pub async fn get<T: Secret>() -> Result<T, SecretStoreError> {
|
|
||||||
let manager = get_secret_manager().await;
|
|
||||||
let raw_value = manager.store.get_raw(&manager.namespace, T::KEY).await?;
|
|
||||||
serde_json::from_slice(&raw_value).map_err(|e| SecretStoreError::Deserialization {
|
|
||||||
key: T::KEY.to_string(),
|
|
||||||
source: e,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Serializes and stores a secret.
|
|
||||||
pub async fn set<T: Secret>(secret: &T) -> Result<(), SecretStoreError> {
|
|
||||||
let manager = get_secret_manager().await;
|
|
||||||
let raw_value =
|
|
||||||
serde_json::to_vec(secret).map_err(|e| SecretStoreError::Serialization {
|
|
||||||
key: T::KEY.to_string(),
|
|
||||||
source: e,
|
|
||||||
})?;
|
|
||||||
manager
|
|
||||||
.store
|
|
||||||
.set_raw(&manager.namespace, T::KEY, &raw_value)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
|
||||||
struct TestUserMeta {
|
|
||||||
labels: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Secret, Serialize, Deserialize, Debug, PartialEq)]
|
|
||||||
struct TestSecret {
|
|
||||||
user: String,
|
|
||||||
password: String,
|
|
||||||
metadata: TestUserMeta,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(secrete2etest)]
|
|
||||||
#[tokio::test]
|
|
||||||
async fn set_and_retrieve_secret() {
|
|
||||||
let secret = TestSecret {
|
|
||||||
user: String::from("user"),
|
|
||||||
password: String::from("password"),
|
|
||||||
metadata: TestUserMeta {
|
|
||||||
labels: vec![
|
|
||||||
String::from("label1"),
|
|
||||||
String::from("label2"),
|
|
||||||
String::from(
|
|
||||||
"some longet label with \" special @#%$)(udiojcia[]]] \"'asdij'' characters Nдs はにほへとちり าฟันพัฒนา yağız şoföre ç <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> <20> 👩👩👧👦 /span> 👩👧👦 and why not emojis ",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
SecretManager::set(&secret).await.unwrap();
|
|
||||||
let value = SecretManager::get::<TestSecret>().await.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(value, secret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
use crate::{SecretStore, SecretStoreError};
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use infisical::{
|
|
||||||
AuthMethod, InfisicalError,
|
|
||||||
client::Client,
|
|
||||||
secrets::{CreateSecretRequest, GetSecretRequest, UpdateSecretRequest},
|
|
||||||
};
|
|
||||||
use log::{info, warn};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct InfisicalSecretStore {
|
|
||||||
client: Client,
|
|
||||||
project_id: String,
|
|
||||||
environment: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InfisicalSecretStore {
|
|
||||||
/// Creates a new, authenticated Infisical client.
|
|
||||||
pub async fn new(
|
|
||||||
base_url: String,
|
|
||||||
project_id: String,
|
|
||||||
environment: String,
|
|
||||||
client_id: String,
|
|
||||||
client_secret: String,
|
|
||||||
) -> Result<Self, InfisicalError> {
|
|
||||||
info!("INFISICAL_STORE: Initializing client for URL: {base_url}");
|
|
||||||
|
|
||||||
// The builder and login logic remains the same.
|
|
||||||
let mut client = Client::builder().base_url(base_url).build().await?;
|
|
||||||
let auth_method = AuthMethod::new_universal_auth(client_id, client_secret);
|
|
||||||
client.login(auth_method).await?;
|
|
||||||
|
|
||||||
info!("INFISICAL_STORE: Client authenticated successfully.");
|
|
||||||
Ok(Self {
|
|
||||||
client,
|
|
||||||
project_id,
|
|
||||||
environment,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SecretStore for InfisicalSecretStore {
|
|
||||||
async fn get_raw(&self, _environment: &str, key: &str) -> Result<Vec<u8>, SecretStoreError> {
|
|
||||||
let environment = &self.environment;
|
|
||||||
info!("INFISICAL_STORE: Getting key '{key}' from environment '{environment}'");
|
|
||||||
|
|
||||||
let request = GetSecretRequest::builder(key, &self.project_id, environment).build();
|
|
||||||
|
|
||||||
match self.client.secrets().get(request).await {
|
|
||||||
Ok(secret) => Ok(secret.secret_value.into_bytes()),
|
|
||||||
Err(e) => {
|
|
||||||
// Correctly match against the actual InfisicalError enum.
|
|
||||||
match e {
|
|
||||||
// The specific case for a 404 Not Found error.
|
|
||||||
InfisicalError::HttpError { status, .. }
|
|
||||||
if status == http::StatusCode::NOT_FOUND =>
|
|
||||||
{
|
|
||||||
Err(SecretStoreError::NotFound {
|
|
||||||
namespace: environment.to_string(),
|
|
||||||
key: key.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// For all other errors, wrap them in our generic Store error.
|
|
||||||
_ => Err(SecretStoreError::Store(Box::new(e))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn set_raw(
|
|
||||||
&self,
|
|
||||||
_environment: &str,
|
|
||||||
key: &str,
|
|
||||||
val: &[u8],
|
|
||||||
) -> Result<(), SecretStoreError> {
|
|
||||||
info!(
|
|
||||||
"INFISICAL_STORE: Setting key '{key}' in environment '{}'",
|
|
||||||
self.environment
|
|
||||||
);
|
|
||||||
let value_str =
|
|
||||||
String::from_utf8(val.to_vec()).map_err(|e| SecretStoreError::Store(Box::new(e)))?;
|
|
||||||
|
|
||||||
// --- Upsert Logic ---
|
|
||||||
// First, attempt to update the secret.
|
|
||||||
let update_req = UpdateSecretRequest::builder(key, &self.project_id, &self.environment)
|
|
||||||
.secret_value(&value_str)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
match self.client.secrets().update(update_req).await {
|
|
||||||
Ok(_) => {
|
|
||||||
info!("INFISICAL_STORE: Successfully updated secret '{key}'.");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
// If the update failed, check if it was because the secret doesn't exist.
|
|
||||||
match e {
|
|
||||||
InfisicalError::HttpError { status, .. }
|
|
||||||
if status == http::StatusCode::NOT_FOUND =>
|
|
||||||
{
|
|
||||||
// The secret was not found, so we create it instead.
|
|
||||||
warn!(
|
|
||||||
"INFISICAL_STORE: Secret '{key}' not found for update, attempting to create it."
|
|
||||||
);
|
|
||||||
let create_req = CreateSecretRequest::builder(
|
|
||||||
key,
|
|
||||||
&value_str,
|
|
||||||
&self.project_id,
|
|
||||||
&self.environment,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Handle potential errors during creation.
|
|
||||||
self.client
|
|
||||||
.secrets()
|
|
||||||
.create(create_req)
|
|
||||||
.await
|
|
||||||
.map_err(|create_err| SecretStoreError::Store(Box::new(create_err)))?;
|
|
||||||
|
|
||||||
info!("INFISICAL_STORE: Successfully created secret '{key}'.");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
// Any other error during update is a genuine failure.
|
|
||||||
_ => Err(SecretStoreError::Store(Box::new(e))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
use async_trait::async_trait;
|
|
||||||
use log::info;
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
use crate::{SecretStore, SecretStoreError};
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub struct LocalFileSecretStore;
|
|
||||||
|
|
||||||
impl LocalFileSecretStore {
|
|
||||||
/// Helper to consistently generate the secret file path.
|
|
||||||
fn get_file_path(base_dir: &Path, ns: &str, key: &str) -> PathBuf {
|
|
||||||
base_dir.join(format!("{ns}_{key}.json"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl SecretStore for LocalFileSecretStore {
|
|
||||||
async fn get_raw(&self, ns: &str, key: &str) -> Result<Vec<u8>, SecretStoreError> {
|
|
||||||
let data_dir = directories::BaseDirs::new()
|
|
||||||
.expect("Could not find a valid home directory")
|
|
||||||
.data_dir()
|
|
||||||
.join("harmony")
|
|
||||||
.join("secrets");
|
|
||||||
|
|
||||||
let file_path = Self::get_file_path(&data_dir, ns, key);
|
|
||||||
info!(
|
|
||||||
"LOCAL_STORE: Getting key '{key}' from namespace '{ns}' at {}",
|
|
||||||
file_path.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
tokio::fs::read(&file_path)
|
|
||||||
.await
|
|
||||||
.map_err(|_| SecretStoreError::NotFound {
|
|
||||||
namespace: ns.to_string(),
|
|
||||||
key: key.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn set_raw(&self, ns: &str, key: &str, val: &[u8]) -> Result<(), SecretStoreError> {
|
|
||||||
let data_dir = directories::BaseDirs::new()
|
|
||||||
.expect("Could not find a valid home directory")
|
|
||||||
.data_dir()
|
|
||||||
.join("harmony")
|
|
||||||
.join("secrets");
|
|
||||||
|
|
||||||
let file_path = Self::get_file_path(&data_dir, ns, key);
|
|
||||||
info!(
|
|
||||||
"LOCAL_STORE: Setting key '{key}' in namespace '{ns}' at {}",
|
|
||||||
file_path.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(parent_dir) = file_path.parent() {
|
|
||||||
tokio::fs::create_dir_all(parent_dir)
|
|
||||||
.await
|
|
||||||
.map_err(|e| SecretStoreError::Store(Box::new(e)))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
tokio::fs::write(&file_path, val)
|
|
||||||
.await
|
|
||||||
.map_err(|e| SecretStoreError::Store(Box::new(e)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use tempfile::tempdir;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_set_and_get_raw_successfully() {
|
|
||||||
let dir = tempdir().unwrap();
|
|
||||||
let store = LocalFileSecretStore::default();
|
|
||||||
let ns = "test-ns";
|
|
||||||
let key = "test-key";
|
|
||||||
let value = b"{\"data\":\"test-value\"}";
|
|
||||||
|
|
||||||
// To test the store directly, we override the base directory logic.
|
|
||||||
// For this test, we'll manually construct the path within our temp dir.
|
|
||||||
let file_path = LocalFileSecretStore::get_file_path(dir.path(), ns, key);
|
|
||||||
|
|
||||||
// Manually write to the temp path to simulate the store's behavior
|
|
||||||
tokio::fs::create_dir_all(file_path.parent().unwrap())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
tokio::fs::write(&file_path, value).await.unwrap();
|
|
||||||
|
|
||||||
// Now, test get_raw by reading from that same temp path (by mocking the path logic)
|
|
||||||
let retrieved_value = tokio::fs::read(&file_path).await.unwrap();
|
|
||||||
assert_eq!(retrieved_value, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_get_raw_not_found() {
|
|
||||||
let dir = tempdir().unwrap();
|
|
||||||
let ns = "test-ns";
|
|
||||||
let key = "non-existent-key";
|
|
||||||
|
|
||||||
// We need to check if reading a non-existent file gives the correct error
|
|
||||||
let file_path = LocalFileSecretStore::get_file_path(dir.path(), ns, key);
|
|
||||||
let result = tokio::fs::read(&file_path).await;
|
|
||||||
|
|
||||||
assert!(matches!(result, Err(_)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
mod infisical;
|
|
||||||
mod local_file;
|
|
||||||
pub use infisical::*;
|
|
||||||
pub use local_file::*;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
export HARMONY_SECRET_NAMESPACE=harmony_test_secrets
|
|
||||||
export HARMONY_SECRET_INFISICAL_URL=http://localhost
|
|
||||||
export HARMONY_SECRET_INFISICAL_PROJECT_ID=eb4723dc-eede-44d7-98cc-c8e0caf29ccb
|
|
||||||
export HARMONY_SECRET_INFISICAL_ENVIRONMENT=dev
|
|
||||||
export HARMONY_SECRET_INFISICAL_CLIENT_ID=dd16b07f-0e38-4090-a1d0-922de9f44d91
|
|
||||||
export HARMONY_SECRET_INFISICAL_CLIENT_SECRET=bd2ae054e7759b11ca2e908494196337cc800bab138cb1f59e8d9b15ca3f286f
|
|
||||||
|
|
||||||
cargo test
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "harmony-secret-derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
proc-macro = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
quote = "1.0"
|
|
||||||
proc-macro2 = "1.0"
|
|
||||||
proc-macro-crate = "3.3"
|
|
||||||
syn = "2.0"
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
use proc_macro::TokenStream;
|
|
||||||
use proc_macro_crate::{FoundCrate, crate_name};
|
|
||||||
use quote::quote;
|
|
||||||
use syn::{DeriveInput, Ident, parse_macro_input};
|
|
||||||
|
|
||||||
#[proc_macro_derive(Secret)]
|
|
||||||
pub fn derive_secret(input: TokenStream) -> TokenStream {
|
|
||||||
let input = parse_macro_input!(input as DeriveInput);
|
|
||||||
let struct_ident = &input.ident;
|
|
||||||
|
|
||||||
// The key for the secret will be the stringified name of the struct itself.
|
|
||||||
// e.g., `struct OKDClusterSecret` becomes key `"OKDClusterSecret"`.
|
|
||||||
let key = struct_ident.to_string();
|
|
||||||
|
|
||||||
// Find the path to the `harmony_secret` crate.
|
|
||||||
let secret_crate_path = match crate_name("harmony-secret") {
|
|
||||||
Ok(FoundCrate::Itself) => quote!(crate),
|
|
||||||
Ok(FoundCrate::Name(name)) => {
|
|
||||||
let ident = Ident::new(&name, proc_macro2::Span::call_site());
|
|
||||||
quote!(::#ident)
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
return syn::Error::new(proc_macro2::Span::call_site(), e.to_string())
|
|
||||||
.to_compile_error()
|
|
||||||
.into();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The generated code now implements `Secret` for the struct itself.
|
|
||||||
// The struct must also derive `Serialize` and `Deserialize` for this to be useful.
|
|
||||||
let expanded = quote! {
|
|
||||||
impl #secret_crate_path::Secret for #struct_ident {
|
|
||||||
const KEY: &'static str = #key;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TokenStream::from(expanded)
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@ env_logger = { workspace = true }
|
|||||||
yaserde = { git = "https://github.com/jggc/yaserde.git" }
|
yaserde = { git = "https://github.com/jggc/yaserde.git" }
|
||||||
yaserde_derive = { git = "https://github.com/jggc/yaserde.git" }
|
yaserde_derive = { git = "https://github.com/jggc/yaserde.git" }
|
||||||
xml-rs = "0.8"
|
xml-rs = "0.8"
|
||||||
thiserror.workspace = true
|
thiserror = "1.0"
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
uuid = { workspace = true }
|
uuid = { workspace = true }
|
||||||
|
|||||||
Reference in New Issue
Block a user