MCPcopy Create free account
hub / github.com/Qovery/engine / build_and_push_services

Method build_and_push_services

lib-engine/src/environment/task.rs:121–202  ·  view source on GitHub ↗
(
        environment_id: Uuid,
        project_id: Uuid,
        services: Vec<&mut dyn Service>,
        option: &DeploymentOption,
        infra_ctx: &InfrastructureContext,
        max_build_in_pa

Source from the content-addressed store, hash-verified

119 }
120
121 pub fn build_and_push_services(
122 environment_id: Uuid,
123 project_id: Uuid,
124 services: Vec<&mut dyn Service>,
125 option: &DeploymentOption,
126 infra_ctx: &InfrastructureContext,
127 max_build_in_parallel: usize,
128 mk_logger: impl Fn(&dyn Service) -> EnvLogger + Send + Sync,
129 abort: &dyn Abort,
130 ) -> Result<(), Box<EngineError>> {
131 // Only keep services that have something to build
132 let metrics_registry: Arc<dyn MetricsRegistry> = Arc::from(infra_ctx.metrics_registry().clone_dyn());
133 let services = services
134 .into_iter()
135 .filter(|srv| srv.build().is_some())
136 .collect::<Vec<_>>();
137
138 // If nothing to build, do nothing
139 if services.is_empty() {
140 return Ok(());
141 };
142
143 let max_build_in_parallel = max(min(max_build_in_parallel, services.len()), 1);
144
145 // To convert ContainerError to EngineError
146 let cr_registry = infra_ctx.container_registry();
147 let cr_to_engine_error = |err: ContainerRegistryError| -> EngineError {
148 let event_details = cr_registry.get_event_details(Stage::Environment(EnvironmentStep::BuiltError));
149 to_engine_error(event_details, err)
150 };
151
152 // We wrap should_abort, to allow to notify parallel build threads to abort when one of them fails
153 let abort_flag = AtomicAbortStatus::new(AbortStatus::None);
154 let abort_status = || AbortStatus::merge(abort_flag.load(Ordering::Relaxed), abort.status());
155
156 // Prepare our tasks
157 let img_retention_time_sec = infra_ctx
158 .kubernetes()
159 .advanced_settings()
160 .registry_image_retention_time_sec;
161 let resource_ttl = infra_ctx.kubernetes().advanced_settings().resource_ttl();
162 let cr_registry = infra_ctx.container_registry();
163 let build_platform = infra_ctx.build_platform();
164
165 services.iter().for_each(|service| {
166 metrics_registry.start_record(*service.long_id(), StepLabel::Service, StepName::BuildQueueing);
167 });
168
169 let build_tasks = services
170 .into_iter()
171 .map(|service| {
172 || {
173 metrics_registry.stop_record(*service.long_id(), StepName::BuildQueueing, StepStatus::Success);
174 Self::build_and_push_service(
175 service,
176 option,
177 cr_registry,
178 build_platform,

Callers

nothing calls this directly

Calls 15

EnvironmentClass · 0.85
container_registryMethod · 0.80
statusMethod · 0.80
kubernetesMethod · 0.80
resource_ttlMethod · 0.80
build_platformMethod · 0.80
start_recordMethod · 0.80
to_engine_errorFunction · 0.50
clone_dynMethod · 0.45
metrics_registryMethod · 0.45
buildMethod · 0.45
get_event_detailsMethod · 0.45

Tested by

no test coverage detected