From 71ff7c3344e65bed4e0cebdd6c5908ad88aafa57 Mon Sep 17 00:00:00 2001 From: Hannes Laimer Date: Mon, 4 Mar 2024 14:26:18 +0100 Subject: [PATCH] datastore: remove datastore from internal cache based on maintenance mode We keep a DataStore cache, so ChunkStore's and lock files are kept by the proxy process and don't have to be reopened every time. However, for specific maintenance modes, e.g. 'offline', our process should not keep file in that datastore open. This clears the cache entry of a datastore if it is in a specific maintanance mode and the last task finished, which also drops any files still open by the process. Signed-off-by: Hannes Laimer Reviewed-by: Gabriel Goller Tested-by: Gabriel Goller --- pbs-api-types/src/maintenance.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index 1b03ca94..a605cc17 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -77,6 +77,12 @@ pub struct MaintenanceMode { } impl MaintenanceMode { + /// Used for deciding whether the datastore is cleared from the internal cache after the last + /// task finishes, so all open files are closed. + pub fn is_offline(&self) -> bool { + self.ty == MaintenanceType::Offline + } + pub fn check(&self, operation: Option) -> Result<(), Error> { if self.ty == MaintenanceType::Delete { bail!("datastore is being deleted");