meta/lib/oe/sstatesig.py: do not error out if sstate files fail on os.stat()

There's an ongoing issue with the autobuilder NFS:
https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/6463/steps/14/logs/stdio

The file entry exists, but os.stat returns a 'file not found; error. It's not
clear how and why such entries appear, but they do produce printdiff test failures
and should not be relevant in context of the printdiff.

[RP: Move wrapping to get_time() function to cover all cases and add comment]
(From OE-Core rev: b7e702752b6a2dfc8493639a8529cf1a16793f03)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexander Kanavin
2024-02-27 12:16:11 +01:00
committed by Richard Purdie
parent 0cf0991cb2
commit 6200a0260b

View File

@@ -399,7 +399,13 @@ def find_siginfo(pn, taskname, taskhashlist, d):
return siginfo.rpartition('.')[2]
def get_time(fullpath):
return os.stat(fullpath).st_mtime
# NFS can end up in a weird state where the file exists but has no stat info.
# If that happens, we assume it doesn't acutally exist and show a warning
try:
return os.stat(fullpath).st_mtime
except FileNotFoundError:
bb.warn("Could not obtain mtime for {}".format(fullpath))
return None
# First search in stamps dir
localdata = d.createCopy()
@@ -422,13 +428,17 @@ def find_siginfo(pn, taskname, taskhashlist, d):
if taskhashlist:
for taskhash in taskhashlist:
if fullpath.endswith('.%s' % taskhash):
hashfiles[taskhash] = {'path':fullpath, 'sstate':False, 'time':get_time(fullpath)}
mtime = get_time(fullpath)
if mtime:
hashfiles[taskhash] = {'path':fullpath, 'sstate':False, 'time':mtime}
if len(hashfiles) == len(taskhashlist):
foundall = True
break
else:
hashval = get_hashval(fullpath)
hashfiles[hashval] = {'path':fullpath, 'sstate':False, 'time':get_time(fullpath)}
mtime = get_time(fullpath)
if mtime:
hashfiles[hashval] = {'path':fullpath, 'sstate':False, 'time':mtime}
if not taskhashlist or (len(hashfiles) < 2 and not foundall):
# That didn't work, look in sstate-cache
@@ -459,7 +469,9 @@ def find_siginfo(pn, taskname, taskhashlist, d):
actual_hashval = get_hashval(fullpath)
if actual_hashval in hashfiles:
continue
hashfiles[actual_hashval] = {'path':fullpath, 'sstate':True, 'time':get_time(fullpath)}
mtime = get_time(fullpath)
if mtime:
hashfiles[actual_hashval] = {'path':fullpath, 'sstate':True, 'time':mtime}
return hashfiles