From 7243ad9e9b94ea399e83a893ae06c81be3ae0ff8 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 23 Jun 2022 02:12:11 +0200 Subject: [PATCH] storage classes --- bundles/postgresql/items.py | 2 +- bundles/postgresql/metadata.py | 26 +++++++++++++++++++------- bundles/zfs/metadata.py | 4 ++++ nodes/home.server.py | 3 +++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/bundles/postgresql/items.py b/bundles/postgresql/items.py index 8c21054..1f851d6 100644 --- a/bundles/postgresql/items.py +++ b/bundles/postgresql/items.py @@ -6,7 +6,7 @@ directories = { 'group': 'postgres', 'needs': [ 'pkg_apt:postgresql', - 'zfs_dataset:tank/postgresql', + f"zfs_dataset:{node.metadata.get('zfs/storage_classes/ssd')}/postgresql", ], 'needed_by': [ 'svc_systemd:postgresql', diff --git a/bundles/postgresql/metadata.py b/bundles/postgresql/metadata.py index 0c20730..b5191bc 100644 --- a/bundles/postgresql/metadata.py +++ b/bundles/postgresql/metadata.py @@ -1,3 +1,6 @@ +from importlib.metadata import metadata + + root_password = repo.vault.password_for(f'{node.name} postgresql root') defaults = { @@ -23,13 +26,22 @@ defaults = { 'grafana_rows': set(), } -if node.has_bundle('zfs'): - defaults['zfs'] = { - 'datasets': { - 'tank/postgresql': { - 'mountpoint': '/var/lib/postgresql', - 'recordsize': '8192', - 'atime': 'off', + +@metadata_reactor.provides( + 'zfs/datasets', +) +def zfs(metadata): + if not node.has_bundle('zfs'): + return {} + + return { + 'zfs': { + 'datasets': { + f"{metadata.get('zfs/storage_classes/ssd')}/postgresql": { + 'mountpoint': '/var/lib/postgresql', + 'recordsize': '8192', + 'atime': 'off', + }, }, }, } diff --git a/bundles/zfs/metadata.py b/bundles/zfs/metadata.py index d91112c..eeb4afb 100644 --- a/bundles/zfs/metadata.py +++ b/bundles/zfs/metadata.py @@ -78,9 +78,13 @@ defaults = { 'datasets': {}, 'pools': {}, 'kernel_params': {}, + 'storage_classes': { + 'ssd': 'tank', + }, }, } + @metadata_reactor.provides( 'zfs/datasets' ) diff --git a/nodes/home.server.py b/nodes/home.server.py index ccc59f3..1ce290c 100644 --- a/nodes/home.server.py +++ b/nodes/home.server.py @@ -136,6 +136,9 @@ }, 'zfs': { 'zfs_arc_max_percent': 75, + 'storage_classes': { + 'ssd': 'ssd', + }, 'pools': { 'tank': { 'type': 'mirror',