mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
patches for dependency errors
This commit is contained in:
@@ -21,8 +21,9 @@ use crate::db::util::WithRevision;
|
||||
use crate::dependencies::{
|
||||
update_current_dependents, BreakageRes, DependencyError, TaggedDependencyError,
|
||||
};
|
||||
use crate::install::cleanup::update_dependents;
|
||||
use crate::s9pk::manifest::{Manifest, ManifestModel, PackageId};
|
||||
use crate::status::handle_broken_dependents;
|
||||
use crate::status::{handle_broken_dependents, DependencyErrors};
|
||||
use crate::util::{
|
||||
display_none, display_serializable, parse_duration, parse_stdin_deserializable, IoFormat,
|
||||
};
|
||||
@@ -339,6 +340,7 @@ pub fn configure<'a, Db: DbHandle>(
|
||||
.await
|
||||
.with_kind(crate::ErrorKind::NotFound)?;
|
||||
|
||||
spec.validate(&*manifest)?;
|
||||
spec.matches(&config)?; // check that new config matches spec
|
||||
spec.update(ctx, db, &*manifest, &*overrides, &mut config)
|
||||
.await?; // dereference pointers in the new config
|
||||
@@ -401,6 +403,17 @@ pub fn configure<'a, Db: DbHandle>(
|
||||
}
|
||||
|
||||
// track dependency health checks
|
||||
current_dependencies = current_dependencies
|
||||
.into_iter()
|
||||
.filter(|(dep_id, _)| {
|
||||
if dep_id != id && !manifest.dependencies.0.contains_key(dep_id) {
|
||||
log::warn!("Illegal dependency specified: {}", dep_id);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let mut deps = pkg_model.clone().current_dependencies().get_mut(db).await?;
|
||||
*deps = current_dependencies.clone();
|
||||
deps.save(db).await?;
|
||||
@@ -411,6 +424,14 @@ pub fn configure<'a, Db: DbHandle>(
|
||||
|
||||
// update dependencies
|
||||
update_current_dependents(db, id, ¤t_dependencies).await?;
|
||||
let mut errs = pkg_model
|
||||
.clone()
|
||||
.status()
|
||||
.dependency_errors()
|
||||
.get_mut(db)
|
||||
.await?;
|
||||
*errs = DependencyErrors::init(ctx, db, &*manifest, ¤t_dependencies).await?;
|
||||
errs.save(db).await;
|
||||
|
||||
// cache current config for dependents
|
||||
overrides.insert(id.clone(), config.clone());
|
||||
|
||||
@@ -283,7 +283,10 @@ pub async fn update_current_dependents<
|
||||
dependent_id: &PackageId,
|
||||
current_dependencies: I,
|
||||
) -> Result<(), Error> {
|
||||
for (dependency, dep_info) in current_dependencies {
|
||||
for (dependency, dep_info) in current_dependencies
|
||||
.into_iter()
|
||||
.filter(|(dependency, _)| dependency != &dependent_id)
|
||||
{
|
||||
if let Some(dependency_model) = crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(&dependency)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::path::Path;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use bollard::image::ListImagesOptions;
|
||||
use patch_db::{DbHandle, PatchDbHandle};
|
||||
|
||||
@@ -30,19 +28,12 @@ pub async fn update_dependents<'a, Db: DbHandle, I: IntoIterator<Item = &'a Pack
|
||||
.manifest()
|
||||
.get(db, true)
|
||||
.await?;
|
||||
if let Err(e) = man
|
||||
.dependencies
|
||||
.0
|
||||
.get(id)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("missing dependency info"),
|
||||
crate::ErrorKind::Database,
|
||||
)
|
||||
})?
|
||||
.satisfied(ctx, db, id, None, dep, &man.version, &man.volumes)
|
||||
.await?
|
||||
{
|
||||
if let Err(e) = if let Some(info) = man.dependencies.0.get(id) {
|
||||
info.satisfied(ctx, db, id, None, dep, &man.version, &man.volumes)
|
||||
.await?
|
||||
} else {
|
||||
Ok(())
|
||||
} {
|
||||
let mut errs = crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(&dep)
|
||||
|
||||
@@ -184,7 +184,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
||||
current_deps: Arc<BTreeMap<PackageId, CurrentDependencyInfo>>,
|
||||
mut db: Db,
|
||||
) -> Result<(), Error> {
|
||||
for (dep_id, dep_info) in &*current_deps {
|
||||
for (dep_id, dep_info) in current_deps.iter().filter(|(dep_id, _)| dep_id != &id) {
|
||||
if let Some(err) = match statuses.get(dep_id) {
|
||||
Some(MainStatus::Running { ref health, .. })
|
||||
| Some(MainStatus::BackingUp {
|
||||
@@ -412,17 +412,14 @@ impl DependencyErrors {
|
||||
current_dependencies: &BTreeMap<PackageId, CurrentDependencyInfo>,
|
||||
) -> Result<DependencyErrors, Error> {
|
||||
let mut res = BTreeMap::new();
|
||||
for dep_id in current_dependencies.keys() {
|
||||
if let Err(e) = manifest
|
||||
for (dep_id, info) in current_dependencies.keys().filter_map(|dep_id| {
|
||||
manifest
|
||||
.dependencies
|
||||
.0
|
||||
.get(dep_id)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
anyhow!("current dependency not in manifest"),
|
||||
crate::ErrorKind::Dependency,
|
||||
)
|
||||
})?
|
||||
.map(|info| (dep_id, info))
|
||||
}) {
|
||||
if let Err(e) = info
|
||||
.satisfied(
|
||||
ctx,
|
||||
db,
|
||||
|
||||
Reference in New Issue
Block a user