diff --git a/lib/charms/vault_k8s/v0/vault_client.py b/lib/charms/vault_k8s/v0/vault_client.py index 2488f64b..38528d92 100644 --- a/lib/charms/vault_k8s/v0/vault_client.py +++ b/lib/charms/vault_k8s/v0/vault_client.py @@ -12,6 +12,7 @@ from abc import abstractmethod from dataclasses import dataclass from enum import Enum +from io import IOBase from typing import List, Protocol import hvac @@ -404,7 +405,7 @@ def create_snapshot(self) -> requests.Response: """Create a snapshot of the Vault data.""" return self._client.sys.take_raft_snapshot() - def restore_snapshot(self, snapshot: bytes) -> requests.Response: + def restore_snapshot(self, snapshot: IOBase) -> requests.Response: """Restore a snapshot of the Vault data. Uses force_restore_raft_snapshot to restore the snapshot diff --git a/src/charm.py b/src/charm.py index afe7a56c..e3e5d63a 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1342,7 +1342,7 @@ def _restore_vault(self, snapshot: StreamingBody) -> bool: # hvac vault client expects bytes or a file-like object to restore the snapshot # StreamingBody implements the read() method # so it can be used as a file-like object in this context - response = vault.restore_snapshot(snapshot) # type: ignore[arg-type] + response = vault.restore_snapshot(snapshot) except VaultClientError as e: logger.error("Failed to restore snapshot: %s", e) return False