Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2143248pxx; Sat, 31 Oct 2020 09:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQLqtagEgc0wBcdbiG8UXe8hwl+4XBzj4BtGHUJWidaSfeww7XnM9AgvcOMhbaohzNbI2q X-Received: by 2002:a17:906:b0d6:: with SMTP id bk22mr7666950ejb.153.1604161488356; Sat, 31 Oct 2020 09:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604161488; cv=none; d=google.com; s=arc-20160816; b=TXhTyowiDi9MmiLmxiGCrSGHXSFN5qEv1OoFpf2lVmuUNANin0eDqjX1V/XRrz09Wk dXvnhTvp0WLFxvSgwWpbyvloptm3qQPk23BqFmFmFF2Oc9C0d2cgalRJiJ8DWZnOEIUL vozrl/hTCs+1UnZeW3Iyh3Y5kn4XzNfhz52FXhtLLHjj/cwEVsoz1u+2hoLawtDpAfmy Lh5eBbxkwevv8uZVA+iNiAfLCtnEDp+6IVFD1X9gT6Q6y+RPvpuUo88g+9wWbLCvid5W o3DhLoacZ0JgB6I0GhaorF18Rb/IfSaD9XhDbuu8v7brlb9Lh+2IXzpOJjJflfHyfg8j W+2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=EdDvgkZ0S9DwIkCEFa3vBakJ7UPa2euYsw+ts9gdC9k=; b=Ijq10N2F//kGuczB7YVEy65TSdF1/j2RQKFU8gogT2s6U/sSyalEXv2bgKTvkOBtHz nTzvfQ18N7RXH4cNsDauXWVtDXTrFWyxe25g7TnML5dRiBwBh+yyVSzOr4Hq9BKuHgTi kpVdAOBjQJqELUwnga0VpJiSjo0jjnp2I/msAOTL8vd24mpfJ/fNo6JTp/HfUwJG1BjG E2uHs39vofd4oNquKViRjP31QLNBOHz6Kx5Vkzl3AJ5POpwHkONFHkf2WHyVSaK6Yv1f Od9eYZ4ZP8Kmx6cm17I8Dgegx5tKoK+luQL0xoTxMsB6Hc1p2nTtiMPr3x2ccyuq6g5R pXTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VJCLZgQ7; 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 f11si6953038edt.426.2020.10.31.09.24.10; Sat, 31 Oct 2020 09:24:48 -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=VJCLZgQ7; 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 S1726647AbgJaQQr (ORCPT + 99 others); Sat, 31 Oct 2020 12:16:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46366 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgJaQQq (ORCPT ); Sat, 31 Oct 2020 12:16:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604161004; 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=EdDvgkZ0S9DwIkCEFa3vBakJ7UPa2euYsw+ts9gdC9k=; b=VJCLZgQ7LHKlajY3NZasMpZ+1yiyuqvPySDV1pk70KWIe7Scfvsg9CulD0/ZCpFI+PICx1 nr5rbpA9IWYaO8JEDDUOoGl1312nCEMU4yghSageitdj+WALf5s5tV8A7aH/SBfIF2MQNM fueNeqrO5zylaWjR/3ph44k/r99Ujww= 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-568-Rx5xM9--NFe-d3fyETaupg-1; Sat, 31 Oct 2020 12:16:40 -0400 X-MC-Unique: Rx5xM9--NFe-d3fyETaupg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE6708030B9 for ; Sat, 31 Oct 2020 16:16:39 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-113-8.phx2.redhat.com [10.3.113.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6368C5578C; Sat, 31 Oct 2020 16:16:39 +0000 (UTC) Subject: Re: [PATCH v1] mountstats: handle KeyError in display_raw_stats To: Rohan Sable , linux-nfs@vger.kernel.org References: <20201028125911.GA140323@fedora.rsable.com> From: Steve Dickson Message-ID: Date: Sat, 31 Oct 2020 12:16:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201028125911.GA140323@fedora.rsable.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.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 10/28/20 8:59 AM, Rohan Sable wrote: > While printing Nfsv4ops from older /proc/self/mountstats > e.g. in 2.6.32-754.el6.x86_64 from RHEL 6.10, > it will not have all the Keys present leading to a KeyError > like below : > > Traceback (most recent call last): > File "nfs-utils/tools/mountstats/mountstats.py", line 1131, in > res = main() > File "nfs-utils/tools/mountstats/mountstats.py", line 1120, in main > return args.func(args) > File "nfs-utils/tools/mountstats/mountstats.py", line 860, in mountstats_command > print_mountstats(stats, args.nfs_only, args.rpc_only, args.raw, args.xprt_only) > File "nfs-utils/tools/mountstats/mountstats.py", line 813, in print_mountstats > stats.display_raw_stats() > File "nfs-utils/tools/mountstats/mountstats.py", line 381, in display_raw_stats > print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) > KeyError: 'FSID_PRESENT' > > Signed-off-by: Rohan Sable I was not able to reproduce this on a RHEL6.10 box but it didn't make either. ;-) Committed... steved. > --- > tools/mountstats/mountstats.py | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py > index 25e92a19..23876fc4 100755 > --- a/tools/mountstats/mountstats.py > +++ b/tools/mountstats/mountstats.py > @@ -378,7 +378,10 @@ class DeviceData: > print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) > elif vers == '4': > for op in Nfsv4ops: > - print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) > + try: > + print('\t%12s: %s' % (op, " ".join(str(x) for x in self.__rpc_data[op]))) > + except KeyError: > + continue > else: > print('\tnot implemented for version %d' % vers) > print() >