From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 7140363408
 for <pve-devel@lists.proxmox.com>; Mon, 21 Sep 2020 13:12:27 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 586A124C6A
 for <pve-devel@lists.proxmox.com>; Mon, 21 Sep 2020 13:11:57 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 0AABB24C5D
 for <pve-devel@lists.proxmox.com>; Mon, 21 Sep 2020 13:11:56 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C72524546C
 for <pve-devel@lists.proxmox.com>; Mon, 21 Sep 2020 13:11:55 +0200 (CEST)
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Aaron Lauterer <a.lauterer@proxmox.com>
References: <20200910143242.20898-1-a.lauterer@proxmox.com>
 <20200910143242.20898-4-a.lauterer@proxmox.com>
 <d780fc9a-c735-fb83-5ba4-f4cb1afbaef3@proxmox.com>
 <a3f146e9-5b0e-2949-c9fe-fe62f167900e@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Message-ID: <a87b1c0c-3dd2-2faf-1662-5884d06c1b79@proxmox.com>
Date: Mon, 21 Sep 2020 13:11:54 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101
 Thunderbird/81.0
MIME-Version: 1.0
In-Reply-To: <a3f146e9-5b0e-2949-c9fe-fe62f167900e@proxmox.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.187 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH v3 storage 3/4] add disk reassign feature
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 21 Sep 2020 11:12:27 -0000

On 18.09.20 17:07, Aaron Lauterer wrote:
>=20
>=20
> On 9/18/20 4:24 PM, Thomas Lamprecht wrote:
>> On 9/10/20 4:32 PM, Aaron Lauterer wrote:
>>> Functionality has been added for the following storage types:
>>>
>>> * dir based ones
>>> =C2=A0=C2=A0=C2=A0=C2=A0 * directory
>>> =C2=A0=C2=A0=C2=A0=C2=A0 * NFS
>>> =C2=A0=C2=A0=C2=A0=C2=A0 * CIFS
>>> =C2=A0=C2=A0=C2=A0=C2=A0 * gluster
>>> * ZFS
>>> * (thin) LVM
>>> * Ceph
>>>
>>> A new feature `reassign` has been introduced to mark which storage
>>> plugin supports the feature.
>>>
>>> A new intermediate class for directory based storages has been
>>> introduced. This was necessary to maintain compatibility with third
>>> party storage plugins and to avoid duplicate code in the dir based
>>> plugins.
>>>
>>> The new `BaseDirPlugin.pm` adds the `reassign` feature flag and
>>> containes the implementation for the reassign functionlity.
>>>
>>> In the future all the directory specific code in Plugin.pm should be
>>> moved to the BaseDirPlugin.pm. But this will most likely break
>>> compatibility with third party plugins and should thus be done with
>>> care.
>>
>> how so? why don't you just add it in plugin.pm with either:
>> * a general directory based implementation, and a no-op/die for the ot=
her
>> =C2=A0=C2=A0 ones
>=20
> That was the first approach, but this would mean a die for all other pl=
ugins and if 3rd party plugins would not implement it, the directory base=
d code will be used. But we cannot know if if the directory approach is t=
he right one.

Note that you also can check the APIVERSION of external plugins through
the "api" method, which is required for them and checked on loading.

>=20
>> * a dummy "die implement me in subclass" method if above is not possib=
le
>=20
> If I do it this way, I cannot put the actual code for dir based storage=
 in the Plugin.pm, thus having an intermediate class for dir based storag=
es would still be beneficial IMHO to avoid code duplication. IIRC we have=
 4 dir based storages (dir, CIFS, NFS, Gluster).

code duplication can also be avoided by just having a general method some=
where
which the single plugins just wrap around (call). That just "duplicates"
the calls, which is no actual duplication as it provides concrete informa=
tion
about what which plugin uses they all share the implementation, which is =
the
actual reason for avoiding code duplication.

IMO a saner and more understandable than this approach, plus external plu=
gins
can just call into this if it works for them.