action #121444
Updated by mkittler about 2 years ago
## Observation We saw the following error on o3 today: ``` [2022-12-05T10:45:55.571462Z] [error] [JBm0Hyi1i4oq] Can't open file "/var/lib/openqa/testresults/01371/01371619-opensuse-Jump:15.2-DVD-ppc64le-Build39.13-extra_tests_in_textmode@ppc64le/ details-gd.json": No such file or directory at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/JobModules.pm line 95. ``` It seems like the test got deleted because we have this in the access log: ``` [05/Dec/2022:10:45:50 +0000] "GET /tests/1371619 HTTP/1.1" 200 ``` So the test was still there but when loading results it was already deleted, because now it returns a 404. The according code is ``` 93 return {} unless -r (my $file = path($dir, "details-$name.json")); 94 95 my $json_data = $file->slurp; 96 die qq{Malformed JSON file "$file": $@} unless my $json = eval { decode_json($json_data) }; ``` so not an atomic operation. ## Acceptance criteria * **AC1:** A unit test ensures that a not readable test module result file is handled and gracefully returned to the web UI and no error in log * **AC2:** The handling is atomic, not "check if readable and then read" ## Suggestions * Instead of trying to read and then fail we should handle the read attempt as we handle the exception in line 96 and return `{}` in case of error