Skip to content

Commit 750cdcc

Browse files
committed
checkpoint
1 parent 06de2d3 commit 750cdcc

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,22 @@ build-azl3: azl3-builder-image version-vars
185185
-e TRIDENT_VERSION="$(LOCAL_BUILD_TRIDENT_VERSION)" \
186186
-v $(PWD):/work -w /work $(AZL3_BUILDER_IMAGE) \
187187
cargo build --color always --target-dir target/azl3 --release --features dangerous-options,grpc-preview
188+
@docker run --rm \
189+
-e TRIDENT_VERSION="$(LOCAL_BUILD_TRIDENT_VERSION)" \
190+
-v $(PWD):/work -w /work $(AZL3_BUILDER_IMAGE) \
191+
cargo build --color always --target-dir target/azl3 --release -p launcher
192+
188193

189194
bin/trident-azl3: build-azl3
190195
@cp -u target/azl3/release/trident bin/trident-azl3
196+
bin/launcher: build-azl3
197+
@cp -u target/azl3/release/launcher bin/launcher
198+
191199

192200
# This will do a proper build on azl3, exactly as the pipelines would, with the custom registry and all.
193201
bin/trident-rpms-azl3.tar.gz: packaging/docker/Dockerfile.full packaging/systemd/*.service packaging/rpm/trident.spec artifacts/osmodifier packaging/selinux-policy-trident/* version-vars
194202
$(eval CARGO_REGISTRIES_BMP_PUBLICPACKAGES_TOKEN := $(shell az account get-access-token --query "join(' ', ['Bearer', accessToken])" --output tsv))
195-
203+
196204
@mkdir -p bin/
197205
@tmpdir=$$(mktemp -d) && \
198206
export CARGO_REGISTRIES_BMP_PUBLICPACKAGES_TOKEN="$(CARGO_REGISTRIES_BMP_PUBLICPACKAGES_TOKEN)" &&\
@@ -564,7 +572,7 @@ IS_UBUNTU_24_OR_NEWER := $(shell \
564572
RUN_NETLAUNCH_TRIDENT_BIN ?= $(if $(filter yes,$(IS_UBUNTU_24_OR_NEWER)),bin/trident-azl3,bin/trident)
565573

566574
.PHONY: run-netlaunch run-netlaunch-stream
567-
run-netlaunch: $(NETLAUNCH_CONFIG) $(TRIDENT_CONFIG) $(NETLAUNCH_ISO) bin/netlaunch validate artifacts/osmodifier $(RUN_NETLAUNCH_TRIDENT_BIN)
575+
run-netlaunch: $(NETLAUNCH_CONFIG) $(TRIDENT_CONFIG) $(NETLAUNCH_ISO) bin/netlaunch artifacts/osmodifier $(RUN_NETLAUNCH_TRIDENT_BIN) bin/launcher
568576
@echo "Using trident binary: $(RUN_NETLAUNCH_TRIDENT_BIN)"
569577
@mkdir -p artifacts/test-image
570578
@cp $(RUN_NETLAUNCH_TRIDENT_BIN) artifacts/test-image/trident
@@ -1016,7 +1024,7 @@ $(MINIMAL_IMAGE):
10161024
@tests/images/testimages.py download-image minimal
10171025

10181026
MINIMAL_IMAGE_AARCH64 = artifacts/minimal_aarch64.vhdx
1019-
$(MINIMAL_IMAGE_AARCH64):
1027+
$(MINIMAL_IMAGE_AARCH64):
10201028
@mkdir -p artifacts
10211029
@tests/images/testimages.py download-image minimal_aarch64
10221030

crates/launcher/src/main.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use futures::StreamExt;
1515
use log::{debug, error, info, trace, warn, LevelFilter};
1616
use semver::Version;
1717
use sha2::{Digest, Sha256};
18-
use tonic::transport::Endpoint;
18+
use tonic::{transport::Endpoint, Streaming};
1919
use trident_proto::v1::{
2020
servicing_response::Response as ResponseBody, update_service_client::UpdateServiceClient,
2121
FinalizeUpdateRequest, HostConfiguration, LogLevel, RebootHandling, RebootManagement,
22-
StageUpdateRequest, StatusCode, UpdateRequest,
22+
ServicingResponse, StageUpdateRequest, StatusCode, UpdateRequest,
2323
};
2424
use url::Url;
2525
use uuid::Uuid;
@@ -149,8 +149,13 @@ async fn trigger(url: &Url, hash: Option<String>) -> Result<(), anyhow::Error> {
149149
}))
150150
.await?;
151151

152-
// Iterate through the stream until we get a Control message
153-
let mut stream = response.into_inner();
152+
handle_servicing_stream(response.into_inner()).await
153+
}
154+
155+
async fn handle_servicing_stream(
156+
mut stream: Streaming<ServicingResponse>,
157+
) -> Result<(), anyhow::Error> {
158+
// Iterate through the stream until we get a Completed message
154159
loop {
155160
match stream.next().await {
156161
Some(Ok(response)) => match response.response {
@@ -174,15 +179,16 @@ async fn trigger(url: &Url, hash: Option<String>) -> Result<(), anyhow::Error> {
174179
"Trident install succeeded: status={:?}",
175180
final_status.status()
176181
);
177-
break;
182+
break Ok(());
178183
} else {
179184
error!("Trident install failed: status={:?}", final_status.status());
180185
match final_status.error {
181186
Some(err) => {
182-
return Err(anyhow::anyhow!(err.message));
187+
error!("Trident reported error: {}", err.message);
188+
break Err(anyhow::anyhow!(err.message));
183189
}
184190
None => {
185-
return Err(anyhow::anyhow!("Trident install failed"));
191+
break Err(anyhow::anyhow!("Trident install failed"));
186192
}
187193
}
188194
}
@@ -193,17 +199,15 @@ async fn trigger(url: &Url, hash: Option<String>) -> Result<(), anyhow::Error> {
193199
}
194200
},
195201
Some(Err(e)) => {
196-
return Err(anyhow::anyhow!("Error reading from Trident stream: {e}"));
202+
break Err(anyhow::anyhow!("Error reading from Trident stream: {e}"));
197203
}
198204
None => {
199-
return Err(anyhow::anyhow!(
205+
break Err(anyhow::anyhow!(
200206
"Trident install stream ended without control message"
201207
));
202208
}
203209
}
204210
}
205-
206-
Ok(())
207211
}
208212

209213
/// Query the Omaha server at the given URL for the given app and track to fetch

tests/images/trident-mos/files/download-trident.service

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ ExecStart=chmod +x /usr/bin/trident
1010
ExecStart=/sbin/restorecon -v /usr/bin/trident
1111
ExecStart=/bin/bash -c "curl $(grep -oP '^\s*phonehome: \\K.*(?=phonehome)' /etc/trident/config.yaml)files/osmodifier -o /usr/bin/osmodifier -f"
1212
ExecStart=/bin/chmod +x /usr/bin/osmodifier
13+
ExecStart=/bin/bash -c "curl $(grep -oP '^\s*phonehome: \\K.*(?=phonehome)' /etc/trident/config.yaml)files/launcher -o /usr/bin/launcher -f"
14+
ExecStart=/bin/chmod +x /usr/bin/launcher
1315
Type=oneshot
1416

1517
[Install]
16-
WantedBy=trident-install.service
18+
WantedBy=trident-install.service

0 commit comments

Comments
 (0)