Skip to content

Commit

Permalink
Merge pull request idaholab#232 from Njinx/fix/opensearch-index-size-…
Browse files Browse the repository at this point in the history
…prune-py

Opensearch statistics are now parsed correctly when only a one node is present
  • Loading branch information
mmguero authored Jan 30, 2023
2 parents 1f92590 + b8e190f commit 76c194d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions shared/bin/opensearch_index_size_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,16 @@ def main():
osInfo = osInfoResponse.json()

# normalize allocation statistics' sizes (eg., 100mb) into bytes
if len(osInfo) > 1:
esDiskUsageStats = []
for stat in osInfo:
if ('node' in stat) and (stat['node'] != 'UNASSIGNED'):
esDiskUsageStats.append(
{
key: humanfriendly.parse_size(value)
if re.match(r'^\d+(\.\d+)?\s*[kmgtp]?b$', value, flags=re.IGNORECASE)
else value
for (key, value) in stat.items()
}
)
for stat in osInfo:
if ('node' in stat) and (stat['node'] != 'UNASSIGNED'):
esDiskUsageStats.append(
{
key: humanfriendly.parse_size(value)
if re.match(r'^\d+(\.\d+)?\s*[kmgtp]?b$', value, flags=re.IGNORECASE)
else value
for (key, value) in stat.items()
}
)

if debug:
eprint(json.dumps(esDiskUsageStats))
Expand Down

0 comments on commit 76c194d

Please sign in to comment.