public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
@ 2023-11-28 15:25 Christian Ebner
  2023-11-28 17:49 ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2023-11-28 15:25 UTC (permalink / raw)
  To: pbs-devel

Introduce a dedicated datastore disk schema for disks, to semantically
distinguish between datastore name and datastore disk name.

Further, adapt the systemd mount unit description accordingly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-api-types/src/datastore.rs         |  6 ++++++
 src/api2/node/disks/directory.rs       |  8 ++++----
 src/api2/node/disks/zfs.rs             |  4 ++--
 src/bin/proxmox_backup_manager/disk.rs | 10 +++++-----
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
index 1f619c9d..4150c6c6 100644
--- a/pbs-api-types/src/datastore.rs
+++ b/pbs-api-types/src/datastore.rs
@@ -102,6 +102,12 @@ pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.")
     .max_length(32)
     .schema();
 
+pub const DATASTORE_DISK_SCHEMA: Schema = StringSchema::new("Datastore disk name.")
+    .format(&PROXMOX_SAFE_ID_FORMAT)
+    .min_length(3)
+    .max_length(32)
+    .schema();
+
 pub const CHUNK_DIGEST_SCHEMA: Schema = StringSchema::new("Chunk digest (SHA256).")
     .format(&CHUNK_DIGEST_FORMAT)
     .schema();
diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 5e1cb124..c43eb125 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -8,7 +8,7 @@ use proxmox_section_config::SectionConfigData;
 use proxmox_sys::task_log;
 
 use pbs_api_types::{
-    DataStoreConfig, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT,
+    DataStoreConfig, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_DISK_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT,
     PRIV_SYS_MODIFY, UPID_SCHEMA,
 };
 
@@ -112,7 +112,7 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
                 schema: NODE_SCHEMA,
             },
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             disk: {
                 schema: BLOCKDEVICE_NAME_SCHEMA,
@@ -227,7 +227,7 @@ pub fn create_datastore_disk(
                 schema: NODE_SCHEMA,
             },
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
         }
     },
@@ -296,7 +296,7 @@ fn create_datastore_mount_unit(
 
     let unit = SystemdUnitSection {
         Description: format!(
-            "Mount datatstore '{}' under '{}'",
+            "Mount datastore disk '{}' under '{}'",
             datastore_name, mount_point
         ),
         ..Default::default()
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 673dc1bf..52c011db 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -6,7 +6,7 @@ use proxmox_schema::api;
 use proxmox_sys::{task_error, task_log};
 
 use pbs_api_types::{
-    DataStoreConfig, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem, DATASTORE_SCHEMA,
+    DataStoreConfig, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem, DATASTORE_DISK_SCHEMA,
     DISK_ARRAY_SCHEMA, DISK_LIST_SCHEMA, NODE_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID_SCHEMA,
     ZFS_ASHIFT_SCHEMA, ZPOOL_NAME_SCHEMA,
 };
@@ -117,7 +117,7 @@ pub fn zpool_details(name: String) -> Result<Value, Error> {
                 schema: NODE_SCHEMA,
             },
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             devices: {
                 schema: DISK_LIST_SCHEMA,
diff --git a/src/bin/proxmox_backup_manager/disk.rs b/src/bin/proxmox_backup_manager/disk.rs
index fae8829f..4c040c4a 100644
--- a/src/bin/proxmox_backup_manager/disk.rs
+++ b/src/bin/proxmox_backup_manager/disk.rs
@@ -5,8 +5,8 @@ use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
 use proxmox_schema::api;
 
 use pbs_api_types::{
-    ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_SCHEMA, DISK_LIST_SCHEMA,
-    ZFS_ASHIFT_SCHEMA,
+    ZfsCompressionType, ZfsRaidLevel, BLOCKDEVICE_NAME_SCHEMA, DATASTORE_DISK_SCHEMA,
+    DISK_LIST_SCHEMA, ZFS_ASHIFT_SCHEMA,
 };
 use proxmox_backup::tools::disks::{complete_disk_name, FileSystemType, SmartAttribute};
 
@@ -141,7 +141,7 @@ async fn initialize_disk(
    input: {
         properties: {
            name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             devices: {
                 schema: DISK_LIST_SCHEMA,
@@ -282,7 +282,7 @@ fn list_datastore_mounts(
    input: {
         properties: {
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
             disk: {
                 schema: BLOCKDEVICE_NAME_SCHEMA,
@@ -321,7 +321,7 @@ async fn create_datastore_disk(
    input: {
         properties: {
             name: {
-                schema: DATASTORE_SCHEMA,
+                schema: DATASTORE_DISK_SCHEMA,
             },
         },
    },
-- 
2.39.2





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
  2023-11-28 15:25 [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema Christian Ebner
@ 2023-11-28 17:49 ` Thomas Lamprecht
  2023-11-29  8:24   ` Christian Ebner
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lamprecht @ 2023-11-28 17:49 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Christian Ebner

Am 28/11/2023 um 16:25 schrieb Christian Ebner:
> Introduce a dedicated datastore disk schema for disks, to semantically
> distinguish between datastore name and datastore disk name.
> 
> Further, adapt the systemd mount unit description accordingly.
> 
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
>  pbs-api-types/src/datastore.rs         |  6 ++++++
>  src/api2/node/disks/directory.rs       |  8 ++++----
>  src/api2/node/disks/zfs.rs             |  4 ++--
>  src/bin/proxmox_backup_manager/disk.rs | 10 +++++-----
>  4 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index 1f619c9d..4150c6c6 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -102,6 +102,12 @@ pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.")
>      .max_length(32)
>      .schema();
>  
> +pub const DATASTORE_DISK_SCHEMA: Schema = StringSchema::new("Datastore disk name.")
> +    .format(&PROXMOX_SAFE_ID_FORMAT)
> +    .min_length(3)
> +    .max_length(32)
> +    .schema();
> +

this is not really helping me, while that might be because its late, I also think
that this needs a different name, as what is a datastore-disk here actually?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
  2023-11-28 17:49 ` Thomas Lamprecht
@ 2023-11-29  8:24   ` Christian Ebner
  2023-11-29  8:56     ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2023-11-29  8:24 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox Backup Server development discussion

> On 28.11.2023 18:49 CET Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>  
> Am 28/11/2023 um 16:25 schrieb Christian Ebner:
> > Introduce a dedicated datastore disk schema for disks, to semantically
> > distinguish between datastore name and datastore disk name.
> > 
> > Further, adapt the systemd mount unit description accordingly.
> > 
> > Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> > ---
> >  pbs-api-types/src/datastore.rs         |  6 ++++++
> >  src/api2/node/disks/directory.rs       |  8 ++++----
> >  src/api2/node/disks/zfs.rs             |  4 ++--
> >  src/bin/proxmox_backup_manager/disk.rs | 10 +++++-----
> >  4 files changed, 17 insertions(+), 11 deletions(-)
> > 
> > diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> > index 1f619c9d..4150c6c6 100644
> > --- a/pbs-api-types/src/datastore.rs
> > +++ b/pbs-api-types/src/datastore.rs
> > @@ -102,6 +102,12 @@ pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.")
> >      .max_length(32)
> >      .schema();
> >  
> > +pub const DATASTORE_DISK_SCHEMA: Schema = StringSchema::new("Datastore disk name.")
> > +    .format(&PROXMOX_SAFE_ID_FORMAT)
> > +    .min_length(3)
> > +    .max_length(32)
> > +    .schema();
> > +
> 
> this is not really helping me, while that might be because its late, I also think
> that this needs a different name, as what is a datastore-disk here actually?

The intention was to distinguish between the datastore itself and the disk, on which the datastore might be created upon, as these are 2 independent entities. Most of the time they will be referred to by the same name, as e.g. created by `proxmox-backup-manager disk fs create foo --disk sdd --add-datastore true`.

I choose to refer to this as `datastore disk` as that is what the API methods in src/api2/node/disks/directory.rs are called.

Unfortunately, that does not really match up with ZFS, as there the name refers to the zpool.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
  2023-11-29  8:24   ` Christian Ebner
@ 2023-11-29  8:56     ` Thomas Lamprecht
  2023-11-29  9:13       ` Christian Ebner
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lamprecht @ 2023-11-29  8:56 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Christian Ebner

Am 29/11/2023 um 09:24 schrieb Christian Ebner:
>> On 28.11.2023 18:49 CET Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
>> this is not really helping me, while that might be because its late, I also think
>> that this needs a different name, as what is a datastore-disk here actually?
> 
> The intention was to distinguish between the datastore itself and the disk, on which the datastore might be created upon, as these are 2 independent entities. Most of the time they will be referred to by the same name, as e.g. created by `proxmox-backup-manager disk fs create foo --disk sdd --add-datastore true`.
> 

The base intention I get, and I think too that this could/should be
improved.

> I choose to refer to this as `datastore disk` as that is what the API methods in src/api2/node/disks/directory.rs are called.
> 
> Unfortunately, that does not really match up with ZFS, as there the name refers to the zpool.
> 

Why not STORAGE_NAME_SCHEMA then? As this is used as datastore name
is only for convenience and might not happen if one doesn't ticks the
"add as datastore" checkbox.
So having this naming hardwired to datastore or disk, while it isn't
necessarily related to either type, is IMO just not that ideal.

As description you could then use something like:

"Name of the Storage. Will be also used for any datastore name, if part of an transaction."

(not really ideal as it's worded a bit overly generic, but just to convey
the base idea).




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
  2023-11-29  8:56     ` Thomas Lamprecht
@ 2023-11-29  9:13       ` Christian Ebner
  2023-11-29  9:21         ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2023-11-29  9:13 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox Backup Server development discussion

> On 29.11.2023 09:56 CET Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>  
> Am 29/11/2023 um 09:24 schrieb Christian Ebner:
> >> On 28.11.2023 18:49 CET Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> >> this is not really helping me, while that might be because its late, I also think
> >> that this needs a different name, as what is a datastore-disk here actually?
> > 
> > The intention was to distinguish between the datastore itself and the disk, on which the datastore might be created upon, as these are 2 independent entities. Most of the time they will be referred to by the same name, as e.g. created by `proxmox-backup-manager disk fs create foo --disk sdd --add-datastore true`.
> > 
> 
> The base intention I get, and I think too that this could/should be
> improved.
> 
> > I choose to refer to this as `datastore disk` as that is what the API methods in src/api2/node/disks/directory.rs are called.
> > 
> > Unfortunately, that does not really match up with ZFS, as there the name refers to the zpool.
> > 
> 
> Why not STORAGE_NAME_SCHEMA then? As this is used as datastore name
> is only for convenience and might not happen if one doesn't ticks the
> "add as datastore" checkbox.
> So having this naming hardwired to datastore or disk, while it isn't
> necessarily related to either type, is IMO just not that ideal.

Ah yes, referring to it as storage name is way better, didn't come to mind yesterday.
This is generic enough to cover all cases.
 
> 
> As description you could then use something like:
> 
> "Name of the Storage. Will be also used for any datastore name, if part of an transaction."

Maybe I will reduce this to a more compact:
"Storage name. Implies the datastore name, if part of a transaction."

Any opinions on that?

> 
> (not really ideal as it's worded a bit overly generic, but just to convey
> the base idea).




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema
  2023-11-29  9:13       ` Christian Ebner
@ 2023-11-29  9:21         ` Thomas Lamprecht
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2023-11-29  9:21 UTC (permalink / raw)
  To: Christian Ebner, Proxmox Backup Server development discussion

Am 29/11/2023 um 10:13 schrieb Christian Ebner:
>> As description you could then use something like:
>>
>> "Name of the Storage. Will be also used for any datastore name, if part of an transaction."
> Maybe I will reduce this to a more compact:
> "Storage name. Implies the datastore name, if part of a transaction."
> 
> Any opinions on that?

fine for me.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-29  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28 15:25 [pbs-devel] [PATCH proxmox-backup] api: add dedicated datastore disk schema Christian Ebner
2023-11-28 17:49 ` Thomas Lamprecht
2023-11-29  8:24   ` Christian Ebner
2023-11-29  8:56     ` Thomas Lamprecht
2023-11-29  9:13       ` Christian Ebner
2023-11-29  9:21         ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal