Skip to content

Commit da726ec

Browse files
committed
fix(toolchain): creating ci env no longer fails first try (#2618)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. --> Fixes RVT-4790
1 parent 34d4343 commit da726ec

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

packages/toolchain/toolchain/src/util/docker/build_remote.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub async fn build_remote(
3939
task.log("[Remote Build] Starting remote build process");
4040

4141
// Get or create CI namespace
42-
let _ci_namespace = get_or_create_ci_namespace(ctx, task.clone()).await?;
42+
let ci_env = get_or_create_ci_namespace(ctx, task.clone()).await?;
4343

4444
// Get build IDs for CI manager and runner
45-
let ci_manager_build_id = upload_ci_manager_build(ctx, task.clone()).await?;
46-
let ci_runner_build_id = upload_ci_runner_build(ctx, task.clone()).await?;
45+
let ci_manager_build_id = upload_ci_manager_build(ctx, task.clone(), &ci_env).await?;
46+
let ci_runner_build_id = upload_ci_runner_build(ctx, task.clone(), &ci_env).await?;
4747

48-
// Get or create ci-runner actor
48+
// Get or create ci-manager actor
4949
let (ci_runner_actor_id, ci_runner_endpoint) =
5050
get_or_create_ci_manager_actor(ctx, task.clone(), ci_manager_build_id, ci_runner_build_id)
5151
.await?;
@@ -126,17 +126,26 @@ async fn get_or_create_ci_namespace(
126126
Ok(TEMPEnvironment::from(*namespace_response.namespace))
127127
}
128128

129-
async fn upload_ci_manager_build(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result<Uuid> {
130-
upload_ci_build(ctx, task, "ci-manager", CI_MANAGER_RELEASE_URL).await
129+
async fn upload_ci_manager_build(
130+
ctx: &ToolchainCtx,
131+
task: task::TaskCtx,
132+
ci_env: &TEMPEnvironment
133+
) -> Result<Uuid> {
134+
upload_ci_build(ctx, task, ci_env, "ci-manager", CI_MANAGER_RELEASE_URL).await
131135
}
132136

133-
async fn upload_ci_runner_build(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result<Uuid> {
134-
upload_ci_build(ctx, task, "ci-runner", CI_RUNNER_RELEASE_URL).await
137+
async fn upload_ci_runner_build(
138+
ctx: &ToolchainCtx,
139+
task: task::TaskCtx,
140+
ci_env: &TEMPEnvironment
141+
) -> Result<Uuid> {
142+
upload_ci_build(ctx, task, ci_env, "ci-runner", CI_RUNNER_RELEASE_URL).await
135143
}
136144

137145
async fn upload_ci_build(
138146
ctx: &ToolchainCtx,
139147
task: task::TaskCtx,
148+
ci_env: &TEMPEnvironment,
140149
name: &str,
141150
url: &str,
142151
) -> Result<Uuid> {
@@ -145,11 +154,6 @@ async fn upload_ci_build(
145154
name
146155
));
147156

148-
// Get the CI environment
149-
let ci_env = get_ci_environment(ctx, task.clone())
150-
.await
151-
.context("Failed to get CI environment")?;
152-
153157
// Check if build already exists with this URL tag
154158
let tags_filter = serde_json::to_string(&serde_json::json!({
155159
"name": name,
@@ -221,10 +225,6 @@ async fn upload_ci_build(
221225
Ok(push_output.build_id)
222226
}
223227

224-
async fn get_ci_environment(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result<TEMPEnvironment> {
225-
get_or_create_ci_namespace(ctx, task).await
226-
}
227-
228228
async fn download_file(url: &str) -> Result<NamedTempFile> {
229229
let response = reqwest::get(url)
230230
.await

0 commit comments

Comments
 (0)