1use std::collections::{BTreeMap, BTreeSet};
9use std::sync::Mutex;
10use std::time::Duration;
11
12use tokio::sync::{Notify, mpsc, oneshot, watch};
13use tracing::{info, warn};
14
15use super::records::RecordSelection;
16use super::{Engine, Occupant};
17use crate::api;
18use crate::cache;
19use crate::config::{ByteSize, Config};
20use crate::docker::{DockerApi, Tty, TtySize};
21use crate::github::GithubApi;
22use crate::isolation;
23use crate::scheduler::{SlotRef, StopReason};
24use crate::sizing::auto;
25use crate::store::Store;
26use crate::sync::lock;
27use crate::time;
28
29pub(super) const CANCEL_GRACE: Duration = Duration::from_secs(90);
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
36pub enum Shutdown {
37 No,
39 Graceful,
41 Detach,
44 Force,
46}
47
48impl Shutdown {
49 pub fn stopping(self) -> Option<api::Stopping> {
51 match self {
52 Shutdown::No => None,
53 Shutdown::Graceful => Some(api::Stopping::WaitsForJobs),
54 Shutdown::Detach => Some(api::Stopping::LeavesJobs),
55 Shutdown::Force => Some(api::Stopping::KillsJobs),
56 }
57 }
58}
59
60#[derive(Debug, Clone, Copy, PartialEq, Eq)]
62pub enum RunningJobs {
63 Keep,
65 Kill,
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq)]
71pub enum RunningSlots {
72 Drain,
74 Keep,
76}
77
78#[derive(Debug, Clone, Copy, PartialEq, Eq)]
80pub enum Author {
81 Owner,
84 AutoSizing,
86}
87
88pub fn same_slice(running: &Config, new: &Config) -> Result<(), ControlError> {
91 if new.host.slice == running.host.slice {
92 return Ok(());
93 }
94 Err(ControlError::Invalid(format!(
95 "restart runnerd to change the slice: it runs in {}, and host.slice is {} in the new config",
96 running.host.slice, new.host.slice
97 )))
98}
99
100#[derive(Debug, Clone, PartialEq, Eq)]
102pub enum Target {
103 Repository(String),
105 All,
107}
108
109#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
111pub enum ControlError {
112 #[error("{0}")]
114 NotFound(String),
115 #[error("{message}")]
117 Busy {
118 message: String,
120 jobs: Vec<api::RunningJob>,
122 },
123 #[error("{0}")]
125 Conflict(String),
126 #[error("{0}")]
128 Invalid(String),
129 #[error("{0}")]
131 Failed(String),
132 #[error("{0}")]
134 NotRecorded(String),
135 #[error("runnerd is stopping")]
137 Stopped,
138}
139
140#[derive(Debug)]
142pub enum Command {
143 Pause {
145 target: Target,
147 jobs: RunningJobs,
149 reply: oneshot::Sender<Result<api::Paused, ControlError>>,
151 },
152 Resume {
154 target: Target,
156 reply: oneshot::Sender<Result<(), ControlError>>,
158 },
159 Reseed {
161 profile: String,
163 reply: oneshot::Sender<Result<(), ControlError>>,
165 },
166 CleanCache {
168 name: String,
170 reply: oneshot::Sender<Result<(), ControlError>>,
172 },
173 ReplaceConfig {
175 config: Box<Config>,
177 memory_max: Option<u64>,
179 cpus: Option<u64>,
181 commit: Commit,
183 running: RunningSlots,
185 author: Author,
187 reply: oneshot::Sender<Result<Vec<String>, ControlError>>,
190 },
191 RemoveRecords {
193 selection: RecordSelection,
195 reply: oneshot::Sender<Result<api::RemovedRecords, ControlError>>,
197 },
198 OpenShell {
200 job: u64,
202 size: TtySize,
204 reply: oneshot::Sender<Result<Tty, ControlError>>,
206 },
207 CloseShell {
209 container: String,
211 },
212}
213
214pub struct Commit(Box<dyn FnOnce() -> Result<Option<String>, String> + Send>);
217
218impl Commit {
219 pub fn new(write: impl FnOnce() -> Result<Option<String>, String> + Send + 'static) -> Commit {
221 Commit(Box::new(write))
222 }
223
224 pub async fn run(self) -> Result<Option<String>, String> {
226 tokio::task::spawn_blocking(self.0)
227 .await
228 .unwrap_or_else(|join_error| Err(join_error.to_string()))
229 }
230}
231
232impl std::fmt::Debug for Commit {
233 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
234 f.write_str("Commit")
235 }
236}
237
238#[derive(Debug)]
240pub struct Commands(mpsc::UnboundedReceiver<Command>);
241
242impl Commands {
243 pub async fn recv(&mut self) -> Option<Command> {
245 self.0.recv().await
246 }
247}
248
249#[derive(Debug)]
251pub struct Control {
252 repositories: Mutex<BTreeSet<String>>,
255 paused: Mutex<BTreeSet<String>>,
256 store: Store,
258 shutdown: watch::Sender<Shutdown>,
259 pub(super) wake: Notify,
260 commands: mpsc::UnboundedSender<Command>,
261}
262
263impl Control {
264 pub fn new(
268 repositories: impl IntoIterator<Item = String>,
269 paused: impl IntoIterator<Item = String>,
270 store: Store,
271 ) -> (Control, Commands) {
272 let repositories: BTreeSet<String> = repositories.into_iter().collect();
273 let paused: BTreeSet<String> = paused
274 .into_iter()
275 .filter(|repository| repositories.contains(repository))
276 .collect();
277 drop(store.paused(paused.iter().cloned().collect()));
279 let (commands, receiver) = mpsc::unbounded_channel();
280 let control = Control {
281 repositories: Mutex::new(repositories),
282 paused: Mutex::new(paused),
283 store,
284 shutdown: watch::Sender::new(Shutdown::No),
285 wake: Notify::new(),
286 commands,
287 };
288 (control, Commands(receiver))
289 }
290
291 pub fn mode(&self) -> Shutdown {
293 *self.shutdown.borrow()
294 }
295
296 pub(super) async fn hurried(&self) {
298 let mut mode = self.shutdown.subscribe();
299 let _ = mode.wait_for(|mode| *mode >= Shutdown::Detach).await;
301 }
302
303 pub async fn set_paused(&self, target: &Target, paused: bool) -> Result<(), ControlError> {
309 let recorded = {
310 let repositories = lock(&self.repositories);
311 let names: Vec<&String> = match target {
312 Target::Repository(repository) => {
313 let Some(name) = repositories.get(repository) else {
314 return Err(not_configured(repository, repositories.iter()));
315 };
316 vec![name]
317 }
318 Target::All => repositories.iter().collect(),
319 };
320 let mut set = lock(&self.paused);
321 for name in names {
322 if paused {
323 set.insert(name.clone());
324 } else {
325 set.remove(name);
326 }
327 }
328 self.store.paused(set.iter().cloned().collect())
330 };
331 self.wake.notify_one();
332 if recorded.await {
333 return Ok(());
334 }
335 let name = match target {
336 Target::Repository(repository) => repository.as_str(),
337 Target::All => "every repository",
338 };
339 let (done, undone) = if paused {
340 ("paused", "resumes it")
341 } else {
342 ("resumed", "pauses it again")
343 };
344 let message = format!(
345 "{name} is {done} until runnerd restarts, but the job history cannot record it, so a restart {undone}"
346 );
347 warn!("{message}");
348 Err(ControlError::NotRecorded(message))
349 }
350
351 fn set_repositories(&self, repositories: BTreeSet<String>) {
353 let mut configured = lock(&self.repositories);
354 let mut paused = lock(&self.paused);
355 let before = paused.len();
356 paused.retain(|repository| repositories.contains(repository));
357 if paused.len() != before {
358 drop(self.store.paused(paused.iter().cloned().collect()));
360 }
361 *configured = repositories;
362 }
363
364 pub fn shutdown(&self, mode: Shutdown) -> Shutdown {
367 self.shutdown.send_if_modified(|shutdown| {
368 let changed = mode > *shutdown;
369 *shutdown = (*shutdown).max(mode);
370 changed
371 });
372 self.wake.notify_one();
373 self.mode()
374 }
375
376 pub fn is_paused(&self, repository: &str) -> bool {
378 lock(&self.paused).contains(repository)
379 }
380
381 async fn send<T>(
382 &self,
383 command: impl FnOnce(oneshot::Sender<T>) -> Command,
384 ) -> Result<T, ControlError> {
385 let (reply, answer) = oneshot::channel();
386 self.commands
387 .send(command(reply))
388 .map_err(|_| ControlError::Stopped)?;
389 answer.await.map_err(|_| ControlError::Stopped)
390 }
391
392 pub async fn pause(
396 &self,
397 target: Target,
398 jobs: RunningJobs,
399 ) -> Result<api::Paused, ControlError> {
400 self.send(|reply| Command::Pause {
401 target,
402 jobs,
403 reply,
404 })
405 .await?
406 }
407
408 pub async fn resume(&self, target: Target) -> Result<(), ControlError> {
411 self.send(|reply| Command::Resume { target, reply }).await?
412 }
413
414 pub async fn reseed(&self, profile: &str) -> Result<(), ControlError> {
416 self.send(|reply| Command::Reseed {
417 profile: profile.to_owned(),
418 reply,
419 })
420 .await?
421 }
422
423 pub async fn clean_cache(&self, name: &str) -> Result<(), ControlError> {
425 self.send(|reply| Command::CleanCache {
426 name: name.to_owned(),
427 reply,
428 })
429 .await?
430 }
431
432 pub async fn remove_records(
434 &self,
435 selection: RecordSelection,
436 ) -> Result<api::RemovedRecords, ControlError> {
437 self.send(|reply| Command::RemoveRecords { selection, reply })
438 .await?
439 }
440
441 pub async fn open_shell(&self, job: u64, size: TtySize) -> Result<Tty, ControlError> {
444 self.send(|reply| Command::OpenShell { job, size, reply })
445 .await?
446 }
447
448 pub fn close_shell(&self, container: String) {
450 let _ = self.commands.send(Command::CloseShell { container });
451 }
452
453 pub async fn replace_config(
461 &self,
462 config: Config,
463 memory_max: Option<u64>,
464 cpus: Option<u64>,
465 commit: Commit,
466 running: RunningSlots,
467 author: Author,
468 ) -> Result<Vec<String>, ControlError> {
469 self.send(|reply| Command::ReplaceConfig {
470 config: Box::new(config),
471 memory_max,
472 cpus,
473 commit,
474 running,
475 author,
476 reply,
477 })
478 .await?
479 }
480}
481
482fn not_configured<'name>(
484 repository: &str,
485 configured: impl Iterator<Item = &'name String>,
486) -> ControlError {
487 let configured: Vec<&str> = configured.map(String::as_str).collect();
488 let configured = if configured.is_empty() {
489 "none is configured".to_owned()
490 } else {
491 format!("configured: {}", configured.join(", "))
492 };
493 ControlError::NotFound(format!(
494 "{repository} is not a configured repository; {configured}"
495 ))
496}
497
498fn list(jobs: &[api::RunningJob]) -> String {
500 jobs.iter()
501 .map(ToString::to_string)
502 .collect::<Vec<_>>()
503 .join(", ")
504}
505
506impl<G: GithubApi + 'static, D: DockerApi + 'static> Engine<G, D> {
507 pub(super) async fn command(&mut self, command: Command) {
509 match command {
510 Command::Pause {
511 target,
512 jobs,
513 reply,
514 } => {
515 let _ = reply.send(self.pause(&target, jobs).await);
516 }
517 Command::Resume { target, reply } => {
518 let _ = reply.send(self.control.set_paused(&target, false).await);
519 }
520 Command::Reseed { profile, reply } => {
521 let _ = reply.send(self.request_reseed(&profile));
522 }
523 Command::CleanCache { name, reply } => {
524 let _ = reply.send(self.clean_cache(&name).await);
525 }
526 Command::ReplaceConfig {
527 config,
528 memory_max,
529 cpus,
530 commit,
531 running,
532 author,
533 reply,
534 } => {
535 if let Err(refused) = same_slice(&self.config, &config) {
536 let _ = reply.send(Err(refused));
537 return;
538 }
539 if running == RunningSlots::Keep
540 && let Some(occupied) = self.occupied_past(&config)
541 {
542 let _ = reply.send(Err(ControlError::Conflict(occupied)));
543 return;
544 }
545 let undone = match author {
546 Author::Owner => self.undone_raises(&config).await,
547 Author::AutoSizing => Vec::new(),
548 };
549 let answer = match commit.run().await {
550 Ok(warning) => {
551 for line in &undone {
552 warn!("config replaced: {line}");
553 }
554 self.reload(*config, memory_max, cpus);
555 Ok(warning.into_iter().chain(undone).collect())
556 }
557 Err(message) => Err(ControlError::Failed(message)),
558 };
559 let _ = reply.send(answer);
560 }
561 Command::RemoveRecords { selection, reply } => {
562 let _ = reply.send(self.remove_records(&selection).await);
563 }
564 Command::OpenShell { job, size, reply } => {
565 let opened = self.open_shell(job, size).await;
566 if let Err(Ok(tty)) = reply.send(opened) {
568 self.close_shell(&tty.container).await;
569 }
570 }
571 Command::CloseShell { container } => self.close_shell(&container).await,
572 }
573 }
574
575 pub(super) async fn pause(
579 &mut self,
580 target: &Target,
581 running: RunningJobs,
582 ) -> Result<api::Paused, ControlError> {
583 let repositories: BTreeSet<String> = match target {
584 Target::Repository(repository) if !self.repositories.contains_key(repository) => {
585 return Err(not_configured(repository, self.repositories.keys()));
586 }
587 Target::Repository(repository) => BTreeSet::from([repository.clone()]),
588 Target::All => self.repositories.keys().cloned().collect(),
589 };
590 self.take_found();
591 let runners: Vec<(SlotRef, Occupant)> = self
592 .occupied()
593 .filter(|(_, occupant)| repositories.contains(&occupant.repository))
594 .map(|(slot, occupant)| (slot, occupant.clone()))
595 .collect();
596 let jobs: Vec<api::RunningJob> = runners
597 .iter()
598 .filter(|(_, occupant)| occupant.busy || occupant.job.is_some())
599 .map(|(_, occupant)| occupant.running_job())
600 .collect();
601 if running == RunningJobs::Keep && !jobs.is_empty() {
602 let mut by_repository: BTreeMap<&str, Vec<api::RunningJob>> = BTreeMap::new();
603 for job in &jobs {
604 by_repository
605 .entry(&job.repository)
606 .or_default()
607 .push(job.clone());
608 }
609 let runs: Vec<String> = by_repository
610 .iter()
611 .map(|(repository, jobs)| format!("{repository} runs {}", list(jobs)))
612 .collect();
613 return Err(ControlError::Busy {
615 message: runs.join("; "),
616 jobs,
617 });
618 }
619 let recorded = self.control.set_paused(target, true).await;
621 match target {
622 Target::Repository(repository) => info!("{repository}: paused"),
623 Target::All => info!("paused every repository"),
624 }
625 let mut stopped = Vec::new();
626 if running == RunningJobs::Keep {
627 return recorded.map(|()| api::Paused { stopped });
628 }
629 for (slot, occupant) in runners {
630 let repository = &occupant.repository;
631 let cancelled = if let Some(job) = occupant.job {
632 self.cancel(repository, job).await
633 } else {
634 if occupant.busy {
635 warn!(
636 "{repository}: {} runs a job its log has not named yet; GitHub fails it once the runner is gone",
637 occupant.runner_name
638 );
639 }
640 false
641 };
642 if cancelled {
643 self.cancelling.insert(
645 occupant.runner_name.clone(),
646 tokio::time::Instant::now() + CANCEL_GRACE,
647 );
648 } else {
649 self.kill(&slot).await;
650 if self
651 .occupied()
652 .any(|(_, candidate)| candidate.runner_name == occupant.runner_name)
653 {
654 continue;
655 }
656 }
657 stopped.push(occupant.running_job());
658 }
659 match recorded {
660 Ok(()) => Ok(api::Paused { stopped }),
661 Err(ControlError::NotRecorded(message)) if !stopped.is_empty() => Err(
662 ControlError::NotRecorded(format!("{message}; stopped {}", list(&stopped))),
663 ),
664 Err(error) => Err(error),
665 }
666 }
667
668 pub(super) async fn kill_cancelled(&mut self) {
670 let now = tokio::time::Instant::now();
671 let running: BTreeSet<String> = self
672 .occupied()
673 .map(|(_, occupant)| occupant.runner_name.clone())
674 .collect();
675 self.cancelling.retain(|name, _| running.contains(name));
676 let overdue: Vec<(SlotRef, String)> = self
677 .occupied()
678 .filter(|(_, occupant)| {
679 self.cancelling
680 .get(&occupant.runner_name)
681 .is_some_and(|deadline| *deadline <= now)
682 })
683 .map(|(slot, occupant)| (slot, occupant.runner_name.clone()))
684 .collect();
685 for (slot, name) in overdue {
686 warn!(
687 "{name} did not exit {}s after its run was cancelled",
688 CANCEL_GRACE.as_secs()
689 );
690 self.kill(&slot).await;
692 }
693 }
694
695 async fn cancel(&self, repository: &str, job: u64) -> bool {
697 let run = match self.github.job(repository, job).await {
698 Ok(details) => details.run_id,
699 Err(error) => {
700 warn!("{repository}: cannot read job {job} to cancel its run: {error}");
701 return false;
702 }
703 };
704 match self.github.cancel_run(repository, run).await {
705 Ok(()) => {
706 info!("{repository}: cancelled run {run} of job {job}");
707 true
708 }
709 Err(error) => {
710 warn!("{repository}: cannot cancel run {run}: {error}");
711 false
712 }
713 }
714 }
715
716 pub(super) fn request_reseed(&mut self, profile: &str) -> Result<(), ControlError> {
718 if !self.config.profiles.contains_key(profile) {
719 return Err(ControlError::NotFound(format!(
720 "{profile} is not a configured profile"
721 )));
722 }
723 if self.is_reseeding(profile) {
724 return Err(ControlError::Conflict(format!(
725 "{profile} is reseeding already"
726 )));
727 }
728 if self.shell_profiles().contains(profile) {
730 return Err(ControlError::Conflict(format!(
731 "a shell is open in a record of {profile}, which mounts its snapshot; reseed it once the shell exits"
732 )));
733 }
734 info!("{profile}: reseeding once its slots are free");
735 self.reseed_requested.insert(profile.to_owned());
736 Ok(())
737 }
738
739 pub(super) async fn clean_cache(&mut self, name: &str) -> Result<(), ControlError> {
742 let Some(volume) = cache::volumes(&self.names, &self.config)
743 .into_iter()
744 .find(|volume| volume.name == name)
745 else {
746 return Err(ControlError::NotFound(format!(
747 "{name} is not a cache volume of this config; `runnerctl caches` lists them"
748 )));
749 };
750 let using: Vec<SlotRef> = match &volume.kind {
751 api::CacheKind::Snapshot { profile } => {
752 return Err(ControlError::Invalid(format!(
753 "{name} is {profile}'s snapshot, which every slot's layers sit on; reseed {profile} to rebuild it"
754 )));
755 }
756 api::CacheKind::Slot { profile, slot } => {
757 if self.reseeds.contains_key(profile) {
758 return Err(ControlError::Conflict(format!(
759 "{profile} is reseeding, which writes {name}"
760 )));
761 }
762 self.occupied()
763 .filter(|(at, _)| at.profile == *profile && at.index + 1 == *slot)
764 .map(|(at, _)| at)
765 .collect()
766 }
767 api::CacheKind::Pnpm
768 | api::CacheKind::Maven
769 | api::CacheKind::Mirror
770 | api::CacheKind::Build => self.occupied().map(|(at, _)| at).collect(),
771 };
772 let shared = matches!(volume.kind, api::CacheKind::Pnpm | api::CacheKind::Maven);
773 if shared && !self.records.shells.is_empty() {
774 return Err(ControlError::Conflict(format!(
775 "a shell open in a record mounts {name}; clean it once the shell exits"
776 )));
777 }
778 let idle = using
781 .iter()
782 .filter(|slot| {
783 self.occupant(slot)
784 .is_some_and(|occupant| !occupant.busy && occupant.job.is_none())
785 })
786 .map(|slot| (slot.clone(), StopReason::Clean))
787 .collect();
788 self.remove_idle(idle).await;
789 let users: Vec<api::RunningJob> = using
790 .iter()
791 .filter_map(|slot| self.occupant(slot))
792 .map(Occupant::running_job)
793 .collect();
794 if !users.is_empty() {
795 return Err(ControlError::Busy {
796 message: format!(
797 "{name} is in use by {}; clean it once they finish",
798 list(&users)
799 ),
800 jobs: users,
801 });
802 }
803 if volume.kind == api::CacheKind::Build {
804 let Some(cache) = self.build_cache.clone() else {
805 return Err(ControlError::Failed(
806 "the build cache did not open when runnerd started; its log says why"
807 .to_owned(),
808 ));
809 };
810 let trimmed = tokio::task::spawn_blocking(move || cache.clear())
811 .await
812 .map_err(|error| ControlError::Failed(format!("cannot empty {name}: {error}")))?;
813 info!(
814 "emptied {name}: {} entries, {}",
815 trimmed.before.entries,
816 ByteSize(trimmed.before.bytes)
817 );
818 self.trim_due = true;
819 return Ok(());
820 }
821 if volume.kind == api::CacheKind::Mirror && self.mirror_up {
822 cache::mirror_down(&*self.docker, &self.names)
823 .await
824 .map_err(|error| {
825 ControlError::Failed(format!("cannot stop the mirror: {error}"))
826 })?;
827 self.mirror_up = false;
828 }
829 self.docker
830 .remove_volume(name)
831 .await
832 .map_err(|error| ControlError::Failed(format!("cannot remove {name}: {error}")))?;
833 info!("removed {name}");
834 if let api::CacheKind::Slot { profile, slot } = &volume.kind {
836 self.ran.remove(&SlotRef {
837 profile: profile.clone(),
838 index: slot.saturating_sub(1),
839 });
840 }
841 self.trim_due = true;
843 Ok(())
844 }
845
846 async fn undone_raises(&self, config: &Config) -> Vec<String> {
849 let now = time::now_ms() / 1000;
850 let since = now.saturating_sub(auto::UNDONE_RAISES).saturating_mul(1000);
851 match self.store.sizing_changes(since).await {
852 Ok(changes) => auto::undone_raises(&self.config, config, &changes, now),
853 Err(store_error) => {
854 warn!(
855 "cannot read auto sizing's changes to compare a new config with: {store_error}"
856 );
857 Vec::new()
858 }
859 }
860 }
861
862 fn occupied_past(&self, config: &Config) -> Option<String> {
864 self.slots.iter().find_map(|(name, slots)| {
865 let kept = config
866 .profiles
867 .get(name)
868 .map_or(0, |profile| profile.slots as usize);
869 slots
870 .iter()
871 .enumerate()
872 .skip(kept)
873 .find(|(_, slot)| slot.is_some())
874 .map(|(index, _)| {
875 format!(
876 "{name}'s slot {} has a runner, and the new config keeps {kept} slots",
877 index + 1
878 )
879 })
880 })
881 }
882
883 pub(super) fn reload(&mut self, config: Config, memory_max: Option<u64>, cpus: Option<u64>) {
888 let mut old = std::mem::replace(&mut self.config, config);
889 if let Some(cache) = &self.build_cache {
890 cache.set_max_size(self.config.caches.build.max_size.0);
891 }
892 for (name, profile) in &self.config.profiles {
893 let slots = self.slots.entry(name.clone()).or_default();
894 if slots.len() < profile.slots as usize {
895 slots.resize(profile.slots as usize, None);
896 }
897 self.retired.remove(name);
898 }
899 for (name, profile) in std::mem::take(&mut old.profiles) {
900 if !self.config.profiles.contains_key(&name) {
901 self.retired.insert(name, profile);
902 }
903 }
904 self.drop_closed_slots();
905 self.images.stale_due = true;
906 let names: BTreeSet<String> = self
907 .config
908 .repositories
909 .iter()
910 .map(|repository| repository.name.clone())
911 .collect();
912 let removed: Vec<String> = self
913 .repositories
914 .keys()
915 .filter(|name| !names.contains(*name))
916 .cloned()
917 .collect();
918 self.draining.extend(removed);
919 self.draining.retain(|name| !names.contains(name));
920 self.repositories.retain(|name, _| names.contains(name));
921 for name in &names {
922 self.repositories.entry(name.clone()).or_default();
923 }
924 self.control.set_repositories(names);
925 let profiles = &self.config.profiles;
926 self.reseed_requested
927 .retain(|name| profiles.contains_key(name));
928 self.oversized.retain(|name| profiles.contains_key(name));
929 self.measure_due.retain(|name| profiles.contains_key(name));
930 self.reseed_due.retain(|name| profiles.contains_key(name));
931 self.isolation = isolation::backend(self.config.host.isolation);
932 self.memory_max = memory_max;
933 self.cpus = cpus;
934 self.caches
935 .send_replace(cache::volumes(&self.names, &self.config));
936 info!("reloaded the config");
937 }
938}