public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Oguz Bektas <o.bektas@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v2 storage 2/2] smartctl: use json parsing
Date: Mon, 10 May 2021 14:35:11 +0200	[thread overview]
Message-ID: <20210510123511.GB9727@gaia.proxmox.com> (raw)
In-Reply-To: <6fbe66e5-0ecb-6f21-57e6-89f9b6828571@proxmox.com>

thanks for reviewing! :)


On Mon, May 10, 2021 at 02:21:12PM +0200, Dominik Csapak wrote:
> some comments inline
> 
> >       }
> > -    my $cmd = [$SMARTCTL, '-H'];
> > -    push @$cmd, '-A', '-f', 'brief' if !$healthonly;
> > +    my $cmd = [$SMARTCTL, '-j', '-H'];
> > +    push @$cmd, '-Afbrief' if !$healthonly;
> 
> any particular reason to change this line? i think
> it makes it harder to read what flags we give
> (-Afbrief vs -A -f brief)

i think my idea was that the cli parameter count for the
disklist_test.pm would be reduced -- but i notice that actually this
doesn't bring anything so i suppose we can leave this part out.

> > +	if ($format eq 'text') {
> > +	    foreach my $key (sort keys %{$nvme_info}) {
> > +		my $value = $nvme_info->{$key};
> > +		# some fields can also be arrays
> > +		# e.g. temperature_sensor
> > +		if (ref($value) eq 'ARRAY') {
> > +		    while (my $index = each(@$value)) {
> > +			$add_key->("${key}_${index}", $value->[$index]);
> > +		    }
> 
> while this is ok, we probably could also do a
> 'pretty-print' json output here in case $value is not a scalar
> 
> that way we would also catch (potential) objects, not only arrays
> (though i do not know if that can happen)

hmm yes, haven't seen any other examples besides that array case, but i will look
into it.


 > +	my @sorted_attributes = sort { $a->{id} <=> $b->{id} } @{$smartdata->{attributes}};
> > +	@{$smartdata->{attributes}} = @sorted_attributes;
> > +    }
> > -    # bit 0 and 1 mark an severe smartctl error
> > -    # all others are for disk status, so ignore them
> > -    # see smartctl(8)
> > -    if ((defined($returncode) && ($returncode & 0b00000011)) || $err) {
> > +    if ($returncode & 0b00000011 || $err) {
> 
> again, any reason to change this? especially the comment about the return
> code ?

the comment was removed by mistake, sorry!

i was also thinking whether it's acceptable to take the exit code from
the json result (although then we might have to handle for potential
errors during parsing, so it might be better to keep it as before)




  reply	other threads:[~2021-05-10 12:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 13:40 [pve-devel] [PATCH storage 1/2] smartctl: remove to-be-replaced disk_tests Oguz Bektas
2021-04-01 13:40 ` [pve-devel] [PATCH storage 2/2] smartctl: use json parsing Oguz Bektas
2021-04-01 14:24 ` [pve-devel] [PATCH v2 " Oguz Bektas
2021-05-10 12:21   ` Dominik Csapak
2021-05-10 12:35     ` Oguz Bektas [this message]
2021-05-10 12:15 ` [pve-devel] [PATCH storage 1/2] smartctl: remove to-be-replaced disk_tests Dominik Csapak
2021-05-10 12:27   ` Oguz Bektas

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=20210510123511.GB9727@gaia.proxmox.com \
    --to=o.bektas@proxmox.com \
    --cc=d.csapak@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