all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH widget-toolkit 2/2] utils: format_size: show negative size as NA
Date: Fri, 2 Jun 2023 12:04:22 +0200	[thread overview]
Message-ID: <6e31eb0a-8564-a11e-ea82-57cf345a7722@proxmox.com> (raw)
In-Reply-To: <c1edc7e6-f600-08b0-4800-465a6e932676@proxmox.com>



On 6/1/23 16:22, Thomas Lamprecht wrote:
> Am 19/04/2023 um 12:34 schrieb Aaron Lauterer:
>> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
>> ---
>>
>> AFAIK we do not have negative sizes anywhere, and if, it is an
>> indication that something is wrong.
> 
> above belongs in the commit message, additionaly some background for why doing
> this now (i.e., did you run into this or what made you make this change?)
> 

good point. It happens with the first patch of the series, when we return '-1' 
to indicate a broken RBD image.


>>
>>   src/Utils.js | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/src/Utils.js b/src/Utils.js
>> index ef72630..8cdbe86 100644
>> --- a/src/Utils.js
>> +++ b/src/Utils.js
>> @@ -688,6 +688,9 @@ utilities: {
>>       },
>>   
>>       format_size: function(size, useSI) {
>> +	if (size < 0) {
>> +	    return gettext("N/A");
> 
> catching this seems OK, but I'd rather just return the value then, as "N/A" (Not
> Applicable) doesn't really makes sense here and just hides a potential underlying
> problem.

Since 'format_size' is used in many places all over the place, what about only 
checking for it in the content view, where we really shouldn't expect a negative 
size?
I think showing N/A instead of '-1 B' is more obvious. Something like this:

diff --git a/www/manager6/storage/ContentView.js 
b/www/manager6/storage/ContentView.js
index 2761b48e..c7b3d5ef 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -182,7 +182,12 @@ Ext.define('PVE.storage.ContentView', {
             'size': {
                 header: gettext('Size'),
                 width: 100,
-               renderer: Proxmox.Utils.format_size,
+               renderer: function(size) {
+                   if (Number(size) === -1) {
+                       return gettext("N/A");
+                   }
+                   return Proxmox.Utils.format_size(size);
+               },
                 dataIndex: 'size',
             },
         };




  reply	other threads:[~2023-06-02 10:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19 10:34 [pve-devel] [PATCH storage 1/2] rbd: improve handling of missing images Aaron Lauterer
2023-04-19 10:34 ` [pve-devel] [PATCH widget-toolkit 2/2] utils: format_size: show negative size as NA Aaron Lauterer
2023-06-01 14:22   ` Thomas Lamprecht
2023-06-02 10:04     ` Aaron Lauterer [this message]
2023-05-26  8:34 ` [pve-devel] [PATCH storage 1/2] rbd: improve handling of missing images Aaron Lauterer

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=6e31eb0a-8564-a11e-ea82-57cf345a7722@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@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