From 85b2b6e5abc4d640d495e2a0073c59c70a92f7fb Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 26 Mar 2020 10:21:39 -0400 Subject: [PATCH] Fix endless loop with log clear attempt in redfish Some redfish implementations endlessly mutate their etag. This makes it impossible to fully establish atomicity. Move the logic as much server side as possible. There is still a window where entries change between fetching the entries and the loginfo, but there is little hope. Change-Id: I9135b96acf82f06bc8622efb4d53d0bc695d1758 --- pyghmi/redfish/command.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 0bb59f16..8c524a34 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1515,18 +1515,19 @@ class Command(object): clearurl = newloginfo.get('Actions', {}).get( '#LogService.ClearLog', {}).get('target', '') while clearurl: - while logtag != newloginfo.get('@odata.etag', None): - logtag = newloginfo.get('@odata.etag', None) - entries = self._do_web_request(entriesurl, cache=False) - newloginfo = self._do_web_request(lurl, cache=False) try: self._do_web_request(clearurl, method='POST', - etag=logtag) + etag=logtag, payload={}) clearurl = False except exc.PyghmiException as e: if 'EtagPreconditionalFailed' not in str(e): raise + # This doesn't guarantee atomicity, but it mitigates + # greatly. Unfortunately some implementations + # mutate the tag endlessly and we have no hope + entries = self._do_web_request(entriesurl, cache=False) newloginfo = self._do_web_request(lurl, cache=False) + logtag = newloginfo.get('@odata.etag', None) for log in entries.get('Members', []): record = {} record['log_id'] = logid