Skip to content

Commit 80851fa

Browse files
committed
rvs: Run watchers independently of TECs
Watch ApprovedImages and compute reference values independently of a TEC existing. Adopt ApprovedImages from the TEC in order to include them in uninstallation. Have PCR computation jobs owned by the ApprovedImages. This avoids conflicting watchers on ApprovedImages while using a simple flow. Test that adoption of an ApprovedImage works also when created 5 seconds before and after the TEC. Fixes: #216 Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
1 parent ff7c681 commit 80851fa

21 files changed

Lines changed: 500 additions & 351 deletions

File tree

.github/workflows/rust.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: "cargo build"
4747
run: cargo build --all-targets
4848
- name: "cargo test"
49-
run: cargo test --bins
49+
run: cargo test --bins --lib
5050
tests-release-stable:
5151
name: "Tests (release), stable toolchain"
5252
runs-on: "ubuntu-24.04"
@@ -70,7 +70,7 @@ jobs:
7070
- name: "cargo build (release)"
7171
run: cargo build --lib --release
7272
- name: "cargo test (release)"
73-
run: cargo test --bins --release
73+
run: cargo test --bins --lib --release
7474
tests-release-msrv:
7575
name: "Tests (release), minimum supported toolchain"
7676
runs-on: "ubuntu-24.04"
@@ -100,7 +100,7 @@ jobs:
100100
- name: "cargo build (release)"
101101
run: cargo build --lib --release
102102
- name: "cargo test (release)"
103-
run: cargo test --bins --release
103+
run: cargo test --bins --lib --release
104104
tests-other-channels:
105105
name: "Tests, unstable toolchain"
106106
runs-on: "ubuntu-24.04"
@@ -128,4 +128,4 @@ jobs:
128128
- name: "cargo build"
129129
run: cargo build --lib
130130
- name: "cargo test"
131-
run: cargo test --bins
131+
run: cargo test --bins --lib

Cargo.lock

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

Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ COPY operator/src/lib.rs operator/src/
1818
# Set only required crates as members to minimize rebuilds upon changes.
1919
RUN sed -i 's/members = .*/members = ["lib", "operator"]/' Cargo.toml && \
2020
sed -i '/\[dev-dependencies\]/,$d' operator/Cargo.toml && \
21+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
2122
make crds-rs
2223

2324
# In debug builds, build dependencies to avoid full rebuild.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ equal-conditions:
204204
lint: fmt-check clippy vet equal-conditions
205205

206206
test: crds-rs
207-
cargo test --workspace --bins
207+
cargo test --workspace --bins --lib
208208

209209
test-release: crds-rs
210-
cargo test --workspace --bins --release
210+
cargo test --workspace --bins --lib --release
211211

212212
integration-tests: generate trusted-cluster-gen crds-rs
213213
RUST_LOG=info REGISTRY=$(REGISTRY) TAG=$(TAG) \

attestation-key-register/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ COPY attestation-key-register/src/lib.rs attestation-key-register/src/
1515

1616
# Set only required crates as members to minimize rebuilds upon changes.
1717
RUN sed -i 's/members =.*/members = ["lib", "attestation-key-register"]/' Cargo.toml && \
18+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
1819
make crds-rs
1920

2021
# In debug builds, build dependencies to avoid full rebuild.

compute-pcrs/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ COPY compute-pcrs/src/lib.rs compute-pcrs/src/
1616

1717
# Set only required crates as members to minimize rebuilds upon changes.
1818
RUN sed -i 's/members =.*/members = ["compute-pcrs", "lib"]/' Cargo.toml && \
19+
sed -i '/trusted-cluster-operator-test-utils/d' lib/Cargo.toml && \
1920
git clone --depth 1 https://github.com/trusted-execution-clusters/reference-values && \
2021
make crds-rs
2122

docs/design/reference-values.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,16 @@ A reference value listing for Trustee could then look like this:
9393
## Data flow
9494

9595
![](../pics/rv-flow.png)
96+
97+
## Ownership
98+
99+
Unlike `reference-values`, `ApprovedImages` can live independently of a `TrustedExecutionCluster` object.
100+
They can be created without one existing, and reference values are written by jobs (that the `ApprovedImages` also own) to the `image-pcrs` ConfigMap, which is created by the operator and is also independent of `TrustedExecutionClusters`.
101+
102+
However, the `ApprovedImages` are adopted by the `TrustedExecutionCluster` object, both when created with a `TrustedExecutionCluster` existing and retroactively when created before `TrustedExecutionCluster` creation.
103+
This ensures that removal of a `TrustedExecutionCluster` acts as a complete uninstallation.
104+
Finalizers on the `ApprovedImages` ensure the PCR values are removed back out of `image-pcrs` again.
105+
106+
## Ownership flow
107+
108+
![](../pics/image-flow.png)

docs/pics/image-flow.png

126 KB
Loading

docs/usage/os-and-node-lifecycle.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Machines booting this image can now register and attest.
5252

5353
**NB:** Updating nodes is not supported yet. Updates incur one intermediary stage of PCR values (assuming no further update on that boot) because kernel update is effective one boot _before_ shim & GRUB update.
5454

55+
**NB:** The TrustedExecutionCluster object adopts ApprovedImages, including those that lived before it.
56+
This ensures that removal of a TrustedExecutionCluster acts as complete uninstallation.
57+
5558
# Disallowing a bootable container image
5659

5760
For the example above:

lib/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ serde_json.workspace = true
2121
[dev-dependencies]
2222
# Only a generate dependency, not a Rust dependency. Included here for auto-updates.
2323
kopium = "0.23.0"
24+
http.workspace = true
25+
tokio.workspace = true
26+
trusted-cluster-operator-test-utils = { path = "../test_utils" }

0 commit comments

Comments
 (0)