mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-20 08:27:49 +02:00
Update KeyStoreVersion to have 0.8.0-rc1.
This commit is contained in:
@@ -49,11 +49,18 @@ impl Default for StoredValueInfo {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
// Do NOT EVER change the order.. this is used to check whether migrations are needed
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum KeyStoreVersion {
|
||||
Pre0_6,
|
||||
V0_6,
|
||||
V0_7,
|
||||
V0_8,
|
||||
V0_8_0_RC1,
|
||||
}
|
||||
|
||||
impl KeyStoreVersion {
|
||||
pub fn current() -> Self {
|
||||
KeyStoreVersion::V0_8_0_RC1
|
||||
}
|
||||
}
|
||||
|
||||
//------------ CommandKey ----------------------------------------------------
|
||||
@@ -164,7 +171,7 @@ where
|
||||
};
|
||||
|
||||
if !existed {
|
||||
store.set_version(&KeyStoreVersion::V0_8)?;
|
||||
store.set_version(&KeyStoreVersion::current())?;
|
||||
}
|
||||
|
||||
Ok(store)
|
||||
|
||||
@@ -35,7 +35,7 @@ use crate::daemon::config::CONFIG;
|
||||
use crate::daemon::http::statics::statics;
|
||||
use crate::daemon::http::{tls, tls_keys, HttpResponse, Request, RequestPath, RoutingResult};
|
||||
use crate::daemon::krillserver::KrillServer;
|
||||
use crate::upgrades::{post_start_upgrade, pre_start_upgrade};
|
||||
use crate::upgrades::{post_start_upgrade, pre_start_upgrade, update_storage_version};
|
||||
|
||||
//------------ State -----------------------------------------------------
|
||||
|
||||
@@ -76,14 +76,22 @@ pub async fn start() -> Result<(), Error> {
|
||||
// Create the server, this will create the necessary data sub-directories if needed
|
||||
let krill = KrillServer::build().await?;
|
||||
|
||||
// Perform upgrades that need a running krill server (e.g. clean up ROAs)
|
||||
post_start_upgrade(&CONFIG.data_dir, &krill)
|
||||
.map_err(|e| Error::Custom(format!("Could not upgrade Krill: {}", e)))
|
||||
.await?;
|
||||
|
||||
// Update the version identifiers for the storage dirs
|
||||
update_storage_version(&CONFIG.data_dir)
|
||||
.map_err(|e| Error::Custom(format!("Could not upgrade Krill: {}", e)))
|
||||
.await?;
|
||||
|
||||
// If archiving is enabled, now would be a good time to clean things up
|
||||
if let Some(days) = CONFIG.archive_threshold_days {
|
||||
krill.archive_old_commands(days).await?;
|
||||
}
|
||||
|
||||
// If the operator wanted to do the upgrade only, now is a good time to report success and stop
|
||||
if env::var(KRILL_ENV_UPGRADE_ONLY).is_ok() {
|
||||
println!("Krill upgrade successful");
|
||||
::std::process::exit(0);
|
||||
|
||||
+13
-7
@@ -111,22 +111,28 @@ pub fn pre_start_upgrade(work_dir: &PathBuf) -> Result<(), UpgradeError> {
|
||||
upgrade_pre_fix_info_0_8_0(work_dir)
|
||||
}
|
||||
|
||||
/// Should be called right after the KrillServer is initiated
|
||||
/// Should be called right after the KrillServer is initiated.
|
||||
pub async fn post_start_upgrade(work_dir: &PathBuf, server: &KrillServer) -> Result<(), UpgradeError> {
|
||||
let version_0_8 = KeyStoreVersion::V0_8;
|
||||
let version_0_8 = KeyStoreVersion::V0_8_0_RC1;
|
||||
let ca_store: AggregateStore<CertAuth> = AggregateStore::new(work_dir, "cas")?;
|
||||
let pubd_store: AggregateStore<Repository> = AggregateStore::new(work_dir, "pubd")?;
|
||||
if ca_store.get_version()? != version_0_8 {
|
||||
if ca_store.get_version()? < version_0_8 {
|
||||
info!("Will clean up redundant ROAs for all CAs and update version of storage dirs");
|
||||
roa_cleanup_0_8_0::roa_cleanup(server).await?;
|
||||
ca_store.set_version(&version_0_8)?;
|
||||
pubd_store.set_version(&version_0_8)?;
|
||||
info!("Upgraded Krill to version: {}", KRILL_VERSION);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update_storage_version(work_dir: &PathBuf) -> Result<(), UpgradeError> {
|
||||
let ca_store: AggregateStore<CertAuth> = AggregateStore::new(work_dir, "cas")?;
|
||||
let pubd_store: AggregateStore<Repository> = AggregateStore::new(work_dir, "pubd")?;
|
||||
let current = KeyStoreVersion::current();
|
||||
ca_store.set_version(¤t)?;
|
||||
pubd_store.set_version(¤t)?;
|
||||
info!("Upgraded Krill to version: {}", KRILL_VERSION);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn upgrade_pre_0_6_0_cas_commands(work_dir: &PathBuf) -> Result<(), UpgradeError> {
|
||||
let pre_0_6_0_ca_commands = pre_0_6_0::UpgradeCas;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user