all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: Aaron Lauterer <a.lauterer@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH installer 1/3] low-level: add zfs module for retrieving importable zpool info
Date: Mon, 8 Jul 2024 17:13:54 +0200	[thread overview]
Message-ID: <p7nud6whbsrfotshbo5c6pmfuj34lf6qntkdsoulxajptk2kdt@vlac7nd3cll2> (raw)
In-Reply-To: <a22c4aa2-7509-4c9d-87e4-99a35686df82@proxmox.com>

Thanks for the review!

On Mon, Jul 08, 2024 at 04:24:16PM GMT, Aaron Lauterer wrote:
> On  2024-05-16  12:28, Christoph Heiss wrote:
> > [..]
> > diff --git a/Proxmox/Sys/ZFS.pm b/Proxmox/Sys/ZFS.pm
> > new file mode 100644
> > index 0000000..4c732ca
> > --- /dev/null
> > +++ b/Proxmox/Sys/ZFS.pm
> > @@ -0,0 +1,43 @@
> > +package Proxmox::Sys::ZFS;
> > +
> > +use strict;
> > +use warnings;
> > +
> > +use Proxmox::Sys::Command qw(run_command);
> > +
> > +use base qw(Exporter);
> > +our @EXPORT_OK = qw(get_exported_pools);
> > +
>
> Some of the flow in this function is difficult to understand without having
> a sample of the text it is parsing. Could we have a small example, maybe
> added as comment?
> That could help people to see what is it trying to parse, even if they are
> not too familiar with the expected output

Makes sense, will do that!

I'll also add some tests using verbatim outputs of `zfs import`, such
that these can always be run. Probably easier than creating test pools
and calling `zfs import` at test run time.

>
> > +my sub parse_pool_list {
> > +    my ($fh) = @_;
> > +
> > +    my @pools;
> > +    my $pool = {}; # last found pool in output
> > +
> > +    while (my $line = <$fh>) {
> > +	if ($line =~ /^\s+pool: (.+)$/) {
> > +	    push @pools, $pool if %$pool;
> > +	    $pool = { name => $1 };
> > +	    next;
> > +	}
> > +
> > +	next if !%$pool;
> > +
> > +	if ($line =~ /^\s*(id|state|status|action): (.+)$/) {
> > +	    chomp($pool->{$1} = $2);
> > +	    next;
> > +	}
> > +    }
> > +
> > +    push @pools, $pool if %$pool;
> > +    return \@pools;
>
> not too sure, but we usually tend to use anonymous arrays, $pools = [];
> then we could just return $pools
> The downside is of course that we need to dereference it in all the other
> places, AFAICT all the `push` lines:
> push @$pools ...
>
> But IME this is more in line with how usually handle such code.

Sure, I'll rewrite it in that style for v2.


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


  reply	other threads:[~2024-07-08 15:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 10:28 [pve-devel] [PATCH installer 0/3] add check/rename for already-existing ZFS rpool Christoph Heiss
2024-05-16 10:28 ` [pve-devel] [PATCH installer 1/3] low-level: add zfs module for retrieving importable zpool info Christoph Heiss
2024-07-08 14:24   ` Aaron Lauterer
2024-07-08 15:13     ` Christoph Heiss [this message]
2024-05-16 10:28 ` [pve-devel] [PATCH installer 2/3] low-level: install: split out random disk uid generation Christoph Heiss
2024-05-16 10:28 ` [pve-devel] [PATCH installer 3/3] low-level: install: check for already-existing `rpool` on install Christoph Heiss
2024-07-08 14:16   ` Aaron Lauterer
2024-07-08 15:16     ` Christoph Heiss
2024-07-08 11:27 ` [pve-devel] [PATCH installer 0/3] add check/rename for already-existing ZFS rpool Christoph Heiss
2024-07-11 12:00 ` Christoph Heiss

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=p7nud6whbsrfotshbo5c6pmfuj34lf6qntkdsoulxajptk2kdt@vlac7nd3cll2 \
    --to=c.heiss@proxmox.com \
    --cc=a.lauterer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal