From: Steve Dickson <SteveD@RedHat.com>
To: Kenneth D'souza <kdsouza@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfsiostat/mountstats: handle KeyError in compare_iostats()
Date: Fri, 17 Jul 2020 09:55:18 -0400 [thread overview]
Message-ID: <27e519e5-c45f-d4b2-77c4-4b83747772fd@RedHat.com> (raw)
In-Reply-To: <20200708160606.21279-1-kdsouza@redhat.com>
On 7/8/20 12:06 PM, Kenneth D'souza wrote:
> This will prevent a backtrace like this from occurring if nfsiostat is run
> with <interval> <count>, eg: nfsiostat 1 3
> This issue can occur if old_stats.__rpc_data['ops'] keys are not up to
> date with result.__rpc_data['ops'].
> I belive this issue can also affect mountstats due to similar code,
> hence fix it too.
>
> nfsiostat:217:compare_iostats:KeyError: 'NULL'
>
> Traceback (most recent call last):
> File "/usr/sbin/nfsiostat", line 649, in <module>
> iostat_command(prog)
> File "/usr/sbin/nfsiostat", line 617, in iostat_command
> print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options)
> File "/usr/sbin/nfsiostat", line 468, in print_iostat_summary
> diff_stats[device] = stats[device].compare_iostats(old_stats)
> File "/usr/sbin/nfsiostat", line 217, in compare_iostats
> difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
> KeyError: 'NULL'
>
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
Committed... (tag: nfs-utils-2-5-2-rc2
steved.
> ---
> tools/mountstats/mountstats.py | 5 ++++-
> tools/nfs-iostat/nfs-iostat.py | 7 +++++--
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
> index 014f38a3..1054f698 100755
> --- a/tools/mountstats/mountstats.py
> +++ b/tools/mountstats/mountstats.py
> @@ -560,7 +560,10 @@ class DeviceData:
> # the reference to them. so we build new lists here
> # for the result object.
> for op in result.__rpc_data['ops']:
> - result.__rpc_data[op] = list(map(difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
> + try:
> + result.__rpc_data[op] = list(map(difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
> + except KeyError:
> + continue
>
> # update the remaining keys
> if protocol == 'udp':
> diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
> index b7e98a2a..5556f692 100755
> --- a/tools/nfs-iostat/nfs-iostat.py
> +++ b/tools/nfs-iostat/nfs-iostat.py
> @@ -213,8 +213,11 @@ class DeviceData:
> # the reference to them. so we build new lists here
> # for the result object.
> for op in result.__rpc_data['ops']:
> - result.__rpc_data[op] = list(map(
> - difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
> + try:
> + result.__rpc_data[op] = list(map(
> + difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
> + except KeyError:
> + continue
>
> # update the remaining keys we care about
> result.__rpc_data['rpcsends'] -= old_stats.__rpc_data['rpcsends']
>
prev parent reply other threads:[~2020-07-17 13:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-08 16:06 [PATCH] nfsiostat/mountstats: handle KeyError in compare_iostats() Kenneth D'souza
2020-07-17 13:55 ` Steve Dickson [this message]
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=27e519e5-c45f-d4b2-77c4-4b83747772fd@RedHat.com \
--to=steved@redhat.com \
--cc=kdsouza@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).