add the upgradeTo field in the details

This commit is contained in:
Tamo 2025-01-23 01:52:08 +01:00
parent bfb57b22db
commit acf8471f32
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
15 changed files with 59 additions and 25 deletions

View File

@ -291,8 +291,8 @@ fn snapshot_details(d: &Details) -> String {
Details::IndexSwap { swaps } => {
format!("{{ swaps: {swaps:?} }}")
}
Details::UpgradeDatabase { from } => {
format!("{{ from: v{}.{}.{} }}", from.0, from.1, from.2)
Details::UpgradeDatabase { from, to } => {
format!("{{ from: {from:?}, to: {to:?} }}")
}
}
}

View File

@ -8,7 +8,7 @@ snapshot_kind: text
----------------------------------------------------------------------
### All Tasks:
0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
1 {uid: 1, status: enqueued, details: { from: v1.12.0 }, kind: UpgradeDatabase { from: (1, 12, 0) }}
1 {uid: 1, status: enqueued, details: { from: (1, 12, 0), to: (1, 13, 0) }, kind: UpgradeDatabase { from: (1, 12, 0) }}
----------------------------------------------------------------------
### Status:
enqueued [0,1,]

View File

@ -75,7 +75,7 @@ pub fn upgrade_index_scheduler(
finished_at: None,
error: None,
canceled_by: None,
details: Some(Details::UpgradeDatabase { from }),
details: Some(Details::UpgradeDatabase { from, to }),
status: Status::Enqueued,
kind: KindWithContent::UpgradeDatabase { from },
},

View File

@ -548,7 +548,7 @@ impl crate::IndexScheduler {
Details::Dump { dump_uid: _ } => {
assert_eq!(kind.as_kind(), Kind::DumpCreation);
}
Details::UpgradeDatabase { from: _ } => {
Details::UpgradeDatabase { from: _, to: _ } => {
assert_eq!(kind.as_kind(), Kind::UpgradeDatabase);
}
}

View File

@ -116,6 +116,8 @@ pub struct DetailsView {
pub swaps: Option<Vec<IndexSwap>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upgrade_from: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upgrade_to: Option<String>,
}
impl DetailsView {
@ -236,10 +238,17 @@ impl DetailsView {
Some(left)
}
},
// We want the earliest version
upgrade_from: match (self.upgrade_from.clone(), other.upgrade_from.clone()) {
(None, None) => None,
(None, Some(from)) | (Some(from), None) => Some(from),
(Some(_), Some(from)) => Some(from),
(Some(from), Some(_)) => Some(from),
},
// And the latest
upgrade_to: match (self.upgrade_to.clone(), other.upgrade_to.clone()) {
(None, None) => None,
(None, Some(to)) | (Some(to), None) => Some(to),
(Some(_), Some(to)) => Some(to),
},
}
}
@ -318,8 +327,9 @@ impl From<Details> for DetailsView {
Details::IndexSwap { swaps } => {
DetailsView { swaps: Some(swaps), ..Default::default() }
}
Details::UpgradeDatabase { from } => DetailsView {
Details::UpgradeDatabase { from, to } => DetailsView {
upgrade_from: Some(format!("v{}.{}.{}", from.0, from.1, from.2)),
upgrade_to: Some(format!("v{}.{}.{}", to.0, to.1, to.2)),
..Default::default()
},
}

View File

@ -16,7 +16,7 @@ use crate::batches::BatchId;
use crate::error::ResponseError;
use crate::keys::Key;
use crate::settings::{Settings, Unchecked};
use crate::InstanceUid;
use crate::{versioning, InstanceUid};
pub type TaskId = u32;
@ -269,9 +269,14 @@ impl KindWithContent {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::UpgradeDatabase { from } => {
Some(Details::UpgradeDatabase { from: (from.0, from.1, from.2) })
}
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: (from.0, from.1, from.2),
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
),
}),
}
}
@ -330,9 +335,14 @@ impl KindWithContent {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::UpgradeDatabase { from } => {
Some(Details::UpgradeDatabase { from: *from })
}
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
),
}),
}
}
}
@ -373,9 +383,14 @@ impl From<&KindWithContent> for Option<Details> {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::UpgradeDatabase { from } => {
Some(Details::UpgradeDatabase { from: *from })
}
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (
versioning::VERSION_MAJOR.parse().unwrap(),
versioning::VERSION_MINOR.parse().unwrap(),
versioning::VERSION_PATCH.parse().unwrap(),
),
}),
}
}
}
@ -630,6 +645,7 @@ pub enum Details {
},
UpgradeDatabase {
from: (u32, u32, u32),
to: (u32, u32, u32),
},
}

Binary file not shown.

View File

@ -8,7 +8,8 @@ snapshot_kind: text
"uid": 20,
"progress": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"stats": {
"totalNbTasks": 1,

View File

@ -8,7 +8,8 @@ snapshot_kind: text
"uid": 20,
"progress": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"stats": {
"totalNbTasks": 1,

View File

@ -8,7 +8,8 @@ snapshot_kind: text
"uid": 20,
"progress": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"stats": {
"totalNbTasks": 1,

View File

@ -12,7 +12,8 @@ snapshot_kind: text
"type": "upgradeDatabase",
"canceledBy": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"error": null,
"duration": "[duration]",

View File

@ -12,7 +12,8 @@ snapshot_kind: text
"type": "upgradeDatabase",
"canceledBy": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"error": null,
"duration": "[duration]",

View File

@ -12,7 +12,8 @@ snapshot_kind: text
"type": "upgradeDatabase",
"canceledBy": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"error": null,
"duration": "[duration]",

View File

@ -8,7 +8,8 @@ snapshot_kind: text
"uid": 20,
"progress": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"stats": {
"totalNbTasks": 1,

View File

@ -12,7 +12,8 @@ snapshot_kind: text
"type": "upgradeDatabase",
"canceledBy": null,
"details": {
"upgradeFrom": "v1.12.0"
"upgradeFrom": "v1.12.0",
"upgradeTo": "v1.13.0"
},
"error": null,
"duration": "[duration]",