Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1995674ybh; Fri, 17 Jul 2020 06:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1ygty/cL0wDXEHHip7/D1AuVQMccwuEGtHZXo3fJKcn0lluE2uhsGghcivwRtvRcWkUHt X-Received: by 2002:a05:6402:1a42:: with SMTP id bf2mr8983911edb.292.1594994233807; Fri, 17 Jul 2020 06:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594994233; cv=none; d=google.com; s=arc-20160816; b=oer2zEDcBTw6MqqmRrs/6i1lWTO9kMU+oI199fnix2hs76bv98DYWrIgsdrHJAasti U3DJ+DKlKloSOO+MJDzbTkvGAU3GbLWWMS0no03z2hJhc3njnJxPdrtWFwEZXk4eXxEE HIl3DQg1kTbqy8z7Xm/A/IgVN4RWWvL/2su7kpHve/VzY2O7MPQMPqzNyASQ/tlpcDSj ISCSFjYzZbMKi0oiBdmtgtpovOVO1uiQoHqy7+BJDoph/GMEzG2NiD5ugGcmkwVpMX4z kVnKhWdIdpgvWOMBSbUSa03Xj9h0l7uyvg+Nq0HqxLxeMiLtGQ8pRqbx75xyYAjr3RiI QM5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=X02b1vJFGgXMWYspYUu96RuX9CVP5XNPwVehuuuXgN0=; b=ahi1xDY1Jl5apP6zSK1EKRaOVCmMrCAC4fGdYK3NJ9Y2fAGWbxVuUHIeh6kRz9O7j2 GuFHiHwwnjC5f2TE90/JG0q2teH21AEKBYPkEUpV1E35ZW4IDhJABc/vaKducISnnrjm 3gj9iST1C5emVB9baRSG6vvy+Tv4oalo2KG+vVYKLgKkogZXNpbf7hVoCfCsJsqurlQC DQLvtnvuGRIRGRJRukqu3jjNM8Z8nS9Tv2s/fOZVoPDl3oRZ4F5PUAXy+dBCDp42Uu0+ kGitjjaD52yN+JiNoc7iSygz48bLo9f1gTe6FyaR2k3Z4uUx7xbHfsDYk2IO39R8ysy3 AsaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RQtpfXed; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si5185661ejb.374.2020.07.17.06.56.48; Fri, 17 Jul 2020 06:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RQtpfXed; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727915AbgGQNzZ (ORCPT + 99 others); Fri, 17 Jul 2020 09:55:25 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51352 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726891AbgGQNzX (ORCPT ); Fri, 17 Jul 2020 09:55:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594994123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X02b1vJFGgXMWYspYUu96RuX9CVP5XNPwVehuuuXgN0=; b=RQtpfXedRT4T26J2+LIhwV1isytEi29ySep7V6sHqzy0wRW1cLyt9GbkIfmaQGA2n3Td00 ftXJ+R9UlSD9gwXsCIdV+qMXZFh6cIWvEF5GazGBM78a6vkOxVAyMQKMSbNzuQU9QgNfc5 3Jz/Td3R6MxT8irWibunc6SFcagiFZE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-178-MA8x7KJ1ORm6Zxaw3qITvg-1; Fri, 17 Jul 2020 09:55:19 -0400 X-MC-Unique: MA8x7KJ1ORm6Zxaw3qITvg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2B4D107ACCA for ; Fri, 17 Jul 2020 13:55:18 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-113-147.phx2.redhat.com [10.3.113.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D4BD78A45; Fri, 17 Jul 2020 13:55:18 +0000 (UTC) Subject: Re: [PATCH] nfsiostat/mountstats: handle KeyError in compare_iostats() To: Kenneth D'souza , linux-nfs@vger.kernel.org References: <20200708160606.21279-1-kdsouza@redhat.com> From: Steve Dickson Message-ID: <27e519e5-c45f-d4b2-77c4-4b83747772fd@RedHat.com> Date: Fri, 17 Jul 2020 09:55:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200708160606.21279-1-kdsouza@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 , 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 > 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 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'] >