From 1942262dbfcfb278be6498cfb0524bb603faf03f Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Tue, 23 Nov 2021 11:10:43 +0000 Subject: [PATCH] recon: only query each host once for disk usage `swift-recon -d` asks each server:port pair about its disks, which means if you have servers_per_port enabled it will multiply-count the disks on any servers that have more than one port enabled. We only want to query each host once, and don't care which of the available ports we use, so filter the hosts set to ensure each host only appears in it once. Closes-Bug: 1947852 Change-Id: Idd517e97beab7813fc782b60cc01bcc20cd54c24 --- swift/cli/recon.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/swift/cli/recon.py b/swift/cli/recon.py index cd09528750..dbf0edba4a 100644 --- a/swift/cli/recon.py +++ b/swift/cli/recon.py @@ -897,9 +897,15 @@ class SwiftRecon(object): low_percents = [(None, 100)] * lowest recon = Scout("diskusage", self.verbose, self.suppress_errors, self.timeout) + # We want to only query each host once, but we don't care + # which of the available ports we use. So we filter hosts by + # constructing a host->port dictionary, since the dict + # constructor ensures each key is unique, thus each host + # appears only once in filtered_hosts. + filtered_hosts = set(dict(hosts).items()) print("[%s] Checking disk usage now" % self._ptime()) for url, response, status, ts_start, ts_end in self.pool.imap( - recon.scout, hosts): + recon.scout, filtered_hosts): if status == 200: hostusage = [] for entry in response: