Get repo for migration but don't 'warm' the cache as this also triggers cleanups..

This commit is contained in:
Tim Bruijnzeels
2022-02-23 14:17:18 +01:00
parent ee81d03db7
commit b047f5cfa3
2 changed files with 22 additions and 19 deletions
@@ -72,16 +72,6 @@ impl CaObjectsMigration {
info!("Populate the CA Objects Store introduced in Krill 0.9.0");
let store = AggregateStore::<OldCertAuth>::disk(&config.data_dir, CASERVER_DIR)?;
// for ca in
// if store.warm().is_err() {
// // most likely we are dealing with off by one errors in old krill info files. Archive them for migration and try again.
// for c in store.list()? {
// let info_key = KeyStoreKey::scoped(c.to_string(), "info.json".to_string());
// kv.drop_key(&info_key)?;
// }
// }
let ca_objects_store =
CaObjectsStore::disk(&config.upgrade_data_dir(), config.issuance_timing.clone(), signer)?;
+22 -9
View File
@@ -75,16 +75,29 @@ impl PubdObjectsMigration {
fn populate_repo_content(config: Arc<Config>) -> UpgradeResult<()> {
info!("Populate the repository content based on current state");
let old_store = AggregateStore::<OldRepository>::disk(&config.data_dir, PUBSERVER_DIR)?;
if old_store.warm().is_err() {
// This is most likely because the info last event is off by one which affected
// some old version. Try archiving the info.json to force that the publication
// server is rebuilt from scratch.
let kv = KeyValueStore::disk(&config.data_dir, PUBSERVER_DIR)?;
let info = KeyStoreKey::scoped("0".to_string(), "info.json".to_string());
kv.archive_to(&info, "archived")?;
}
let old_repo = old_store.get_latest(&Self::repository_handle())?;
let repo_handle = Self::repository_handle();
let old_repo = match old_store.get_latest(&repo_handle) {
Ok(repo) => repo,
Err(_) => {
// most likely an off by one error in the info.json of early releases
// try to move the info file out of the way and reload.
let kv = KeyValueStore::disk(&config.data_dir, PUBSERVER_DIR)?;
let info_key = KeyStoreKey::scoped(repo_handle.to_string(), "info.json".to_string());
let tmp_key = KeyStoreKey::scoped(repo_handle.to_string(), "tmp-info.json".to_string());
kv.move_key(&info_key, &tmp_key)?;
// Get latest (may still error)
let res = old_store.get_latest(&repo_handle);
// move the key back to leave things as they were
kv.move_key(&tmp_key, &info_key)?;
// Get the repo or error out if this failed.
res?
}
};
let publishers = old_repo
.publishers