migrate-system-disk: add better logging
This commit is contained in:
parent
e834c109d5
commit
6e676c49d1
@ -96,6 +96,8 @@ pub async fn ensure_system_disk(svc: &Services<'_>) -> Result<(), P5xError> {
|
|||||||
|
|
||||||
|
|
||||||
pub async fn migrate_system_disk_if_necessary(svc: &Services<'_>) -> Result<(), P5xError> {
|
pub async fn migrate_system_disk_if_necessary(svc: &Services<'_>) -> Result<(), P5xError> {
|
||||||
|
info!(target: "p5x", "Ensuring that system disk is mounted on the correct LXC container...");
|
||||||
|
|
||||||
// Load the dynamic-kv and get the current host/mount
|
// Load the dynamic-kv and get the current host/mount
|
||||||
let client = Client::try_default().await.map_err(P5xError::KubeError)?;
|
let client = Client::try_default().await.map_err(P5xError::KubeError)?;
|
||||||
let namespace = fs::read_to_string("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
let namespace = fs::read_to_string("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||||
@ -110,6 +112,8 @@ pub async fn migrate_system_disk_if_necessary(svc: &Services<'_>) -> Result<(),
|
|||||||
let current_mount = data.get("api-pve-disk").expect("Could not find api-pve-disk in dynamic-kv config");
|
let current_mount = data.get("api-pve-disk").expect("Could not find api-pve-disk in dynamic-kv config");
|
||||||
let current_pve_id: i32 = data.get("api-pve-id").expect("Could not find api-pve-id in dynamic-kv config").parse().unwrap();
|
let current_pve_id: i32 = data.get("api-pve-id").expect("Could not find api-pve-id in dynamic-kv config").parse().unwrap();
|
||||||
|
|
||||||
|
debug!(target: "p5x", "Existing mount: {current_host} ({current_pve_id}) as {current_mount}");
|
||||||
|
|
||||||
// Load the labels for this pod's node
|
// Load the labels for this pod's node
|
||||||
let pod_name = env::var("POD_NAME")
|
let pod_name = env::var("POD_NAME")
|
||||||
.or_else(|_| gethostname().into_string())
|
.or_else(|_| gethostname().into_string())
|
||||||
@ -131,12 +135,17 @@ pub async fn migrate_system_disk_if_necessary(svc: &Services<'_>) -> Result<(),
|
|||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!(target: "p5x", "Current context: {pve_host} ({pve_id})");
|
||||||
|
|
||||||
// If the disk is already on our LXC container (K8s node), we're done
|
// If the disk is already on our LXC container (K8s node), we're done
|
||||||
if pve_id == current_pve_id {
|
if pve_id == current_pve_id {
|
||||||
|
info!(target: "p5x", "System disk is already mounted to our LXC container.");
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we need to migrate the disk to this node
|
// Otherwise, we need to migrate the disk to this node
|
||||||
|
info!(target: "p5x", "Attempting to migrate unmanaged system volume from {current_pve_id} to {pve_id}...");
|
||||||
|
|
||||||
// FIXME: Consideration: What if the disk is still mounted somewhere?
|
// FIXME: Consideration: What if the disk is still mounted somewhere?
|
||||||
transfer_unmanaged(
|
transfer_unmanaged(
|
||||||
svc, current_mount, current_host, current_pve_id, pve_host, pve_id).await?;
|
svc, current_mount, current_host, current_pve_id, pve_host, pve_id).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user