mirror of
https://opendev.org/x/pyghmi
synced 2025-11-12 09:00:39 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user