public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max Carrara" <m.carrara@proxmox.com>
To: "Fiona Ebner" <f.ebner@proxmox.com>,
	"Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [RFC storage 10/23] plugin: introduce new_backup_provider() method
Date: Thu, 25 Jul 2024 17:32:49 +0200	[thread overview]
Message-ID: <D2YQ94DKZGX2.UTRN4DJU5WYQ@proxmox.com> (raw)
In-Reply-To: <74a748f3-f7ff-4de5-aa1d-3378ae22c642@proxmox.com>

On Thu Jul 25, 2024 at 3:11 PM CEST, Fiona Ebner wrote:
> Am 25.07.24 um 11:48 schrieb Max Carrara:
> > On Tue Jul 23, 2024 at 11:56 AM CEST, Fiona Ebner wrote:
> >> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> > 
> > Some overall thoughts:
> > 
> > 1.  I'm really, really happy to see documentation in this module here,
> >     that's fantastic! :)
> > 
> >     While the contents of the docs seem fine, I would suggest you used
> >     POD instead. You can find an example in one of my recent series. [1]
> >     I mainly prefer POD solely because it's what Perl uses; it also
> >     indirectly makes sure we all use the same kind of format for
> >     documenting our Perl code.
> > 
> >     Of course, we've currently not decided on any particular format, but
> >     because the opportunity arose, I wanted to pitch POD here
> >     nevertheless. ;)
> > 
>
> I'll look into it for v2. Agreed, following a standard for documenting
> an API module has its merits.

Sweet!

>
> > 2.  I would personally prefer a namespace like `PVE::Backup::Provider`
> >     instead of `PVE::BackupProvider`, simply because it leaves room for
> >     further packages and reduces churn in the long term, IMO.
> > 
>
> There's a risk though that PVE::Backup::Provider and PVE::Backup::Foo
> are unrelated things that have no real business sharing a namespace.

Hmm, fair point - on second thought, `PVE::Backup` indeed seems a bit
too generic.

>
> >     The same goes for backup provider plugins - IMO namespacing them
> >     like e.g. `PVE::Backup::Provider::Plugin::Foo` where `Foo` is a
> >     (concrete) plugin.
> > 
>
> The BackupProvider namespace is already intended for the plugins, adding
> an extra level with "Plugin" would just bloat the module names,
> especially if we decide to go the same route as for storage plugins and
> have a "Custom" sub-namespace.

I understand what you mean, yeah. Would perhaps something like
`PVE::BackupProvider::Plugin::*` be better?

The reason why I'm suggesting this is because in `PVE::Storage::*`,
every plugin lives alongside `Plugin.pm`, even though the extra
directory wouldn't really hurt IMO. E.g. `PVE::Storage::DirPlugin` would
then be `PVE::Storage::Plugin::Dir`.

The reason why I'm suggesting *something* like that here is to reduce
some clutter and simply keep related things grouped. Also, IMO it's
better to consider the overall package structure beforehand, simply to
avoid any churn in the future - something I've noticed while poking
around the storage API.

Maybe I'm being a bit pedantic here (tbh I probably am), but it's just
something that I wanted to mention anyhow.

>
> >     While this seems long or somewhat excessive, I think it enforces a
> >     clear package / module hierarchy and keeps things tidier in the long
> >     term, and those couple extra keystrokes don't really hurt anyone.
> > 
>
> I get where you're coming from, I just feel like BackupProvider might be
> better as its own separate thing, containing the plugins for the
> specific purpose. But I don't have a strong opinion about it, and am
> fine making such changes if other developers prefer it too :)

I agree now that BackupProvider should remain on its own; I otherwise
don't have any strong opinions about it either (though I would like to
shove plugins one directory level deeper ;P). As I said, I'm probably
just a bit pedantic here; feel free to disregard these suggestions if
you think they're not applicable :)

>
> > The above two methods - `backup_nbd` and `backup_directory` - is there
> > perhaps a way to merge them? I'm not sure if what I'm having in mind
> > here is actually feasible, but what I mean is "making the method
> > agnostic to the type of backup". As in, perhaps pass a hash that
> > contains a `type` key for the type of backup being made, and instead of
> > having long method signatures, include the remaining parameters as the
> > remaining keys. For example:
> > 
> > {
> >     'type' => 'lxc-dir',  # type names are just examples here
> >     'directory' => '/foo/bar/baz',
> >     'bandwidth_limit' => 42,
> >     ...
> > }
> > 
> > {
> >     'type' => 'vm-nbd',
> >     'device_name' => '...',
> >     'nbd_path' => '...',
> >     ...
> > }
> > 
> > You get the point :P
> > 
> > IMO it would make it easier to extend later, and also make it more
> > straightforward to introduce new parameters / deprecate old ones, while
> > the method signature stays stable otherwise.
> > 
> > The same goes for the different cleanup methods further down below;
> > instead of having a separate method for each "type of cleanup being
> > performed", let the implementor handle it according to the data the
> > method receives.
> > 
> > IMHO I think it's best to be completely agnostic over VM / LXC backups
> > (and their specific types) wherever possible and let the data describe
> > what's going on instead.
> > 
>
> The point about extensibility is a good one. The API wouldn't need to
> change even if we implement new mechanisms. But thinking about it some
> more, is there anything really gained? Because we will not force plugins
> to implement the methods for new mechanisms of course, they can just
> continue supporting what they support. Each mechanism will have its own
> specific set of parameters, so throwing everything into a catch-all
> method and hash might make it too generic.

The main point is indeed extensibility, but it also makes maintaining
the API a bit easier. Should we (in the future) decide to add or remove
any parameters, we don't need to touch the signature - and in turn, we
don't need to tediously `grep` for every call site to ensure that
they're updated accordingly.

With hashes one could instead always just check if the required
arguments have been provided.

>
> Or think about the documentation for the single backup method: it would
> become super lengthy and describe all backup mechanisms, while a plugin
> most likely only cares about a single one and would have an easier time
> with a method that captures that mechanism's parameters explicitly.
> Won't the end result be making the implementors life slightly harder,
> because it first needs to extract the parameters for the specific mechanism?

Yes, I agree - this does create a bit of a double-edged sword -
implementors are responsible for handling the hash correctly; of course
they could lob it all into one generic method and call it a day, or they
could introduce a separate helper function for each `type`, for example.

The up- and downside of a generic method would be that it's up to the
implementor on how to deal with it.

At the same time, it would allow their plugin to handle different API
versions a bit easier as well, because the method signature wouldn't
change - only the data changes. If they wanted their plugin to support
multiple API versions all at once, they could certainly do it that way
and aren't restricted by a fixed set of parameters.

Now that I've given it some more thought, there are quite a bunch of ups
and downs, though I'm personally still in favour of the more generic
method, as it would reduce maintenance cost in the long run, IMO for
both us and implementors. The initial cost of adding the parameter
extraction / handling would be higher, I agree, but I feel like it's
more worth in the long run.

Also, IMO lengthy documentation is better than having a rigid API ;P

>
> > For the specific types we can always then provide helper functions that
> > handle common cases that implementors can use.
> > 
> > Extending on my namespace idea above, those helpers could then land in
> > e.g. `PVE::Backup::Provider::Common`, `PVE::Backup::Provider::Common::LXC`,
> > etc.
> > 
>
> Could you give an example for such a helper? I rather feel like things
> like libnbd will be that, i.e. for accessing the NBD export, not sure if
> we can create common helpers that would benefit multiple providers, each
> has their own backend they'll need to talk to after all and might have
> quite different needs.

Fair point! I agree with you; disregard this, then. :P



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2024-07-25 15:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23  9:56 [pve-devel] [RFC qemu/storage/qemu-server/container/manager 00/23] backup provider API Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu 01/23] block/reqlist: allow adding overlapping requests Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu 02/23] PVE backup: fixup error handling for fleecing Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu 03/23] PVE backup: factor out setting up snapshot access " Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu 04/23] PVE backup: save device name in device info structure Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu 05/23] PVE backup: include device name in error when setting up snapshot access fails Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu 06/23] PVE backup: add target ID in backup state Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu 07/23] PVE backup: get device info: allow caller to specify filter for which devices use fleecing Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu 08/23] PVE backup: implement backup access setup and teardown API for external providers Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu 09/23] PVE backup: implement bitmap support for external backup access Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC storage 10/23] plugin: introduce new_backup_provider() method Fiona Ebner
2024-07-25  9:48   ` Max Carrara
2024-07-25 13:11     ` Fiona Ebner
2024-07-25 13:25       ` Fiona Ebner
2024-07-25 15:32       ` Max Carrara [this message]
2024-07-26  9:52         ` Fiona Ebner
2024-07-26 12:02           ` Max Carrara
2024-07-26 12:45             ` Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC storage 11/23] extract backup config: delegate to backup provider if there is one Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [POC storage 12/23] add backup provider example Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu-server 13/23] move nbd_stop helper to QMPHelpers module Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu-server 14/23] backup: move cleanup of fleecing images to cleanup method Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu-server 15/23] backup: cleanup: check if VM is running before issuing QMP commands Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu-server 16/23] backup: allow adding fleecing images also for EFI and TPM Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu-server 17/23] backup: implement backup for external providers Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH qemu-server 18/23] restore: die early when there is no size for a device Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC qemu-server 19/23] backup: implement restore for external providers Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC container 20/23] backup: implement backup " Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC container 21/23] backup: implement restore " Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [PATCH manager 22/23] ui: backup: also check for backup subtype to classify archive Fiona Ebner
2024-07-23  9:56 ` [pve-devel] [RFC manager 23/23] backup: implement backup for external providers Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D2YQ94DKZGX2.UTRN4DJU5WYQ@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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