Project

General

Profile

action #88347

Updated by okurz about 3 years ago

## Observation 
 When the upload_asset() function is called in SUT on files larger than (exactly) 256kiB, they are uploaded into pool/X/assets_public (or pool/X/assets_private) with 0600 permissions (and not 0644 as for smaller files) with _openqa_worker user. This is than unreadable from server side for geekotest user and upload fails with : 
 '...Failed receiving asset: Can't copy file "/var/lib/openqa/pool/1/assets_public/testfile" to "/var/lib/openqa/share/factory/tmp/public/testfile.CHUNKS/testfile": Permission denied at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/Jobs.pm...'  
 in worker log.  
 This problem appears only if LOCAL_UPLOAD (very useful feature otherwise) is set. 

 ## Steps to reproduce 
 * Crosscheck original description when tests upload files larger than 256kiB 

 ## Problem 
 It turns out that this can be fixed by adding  
 'chmod 0644, $file;'  
 line in  
 lib/OpenQA/Worker/Job.pm  
 in either  
 '_upload_asset' sub in 'upload_local.prepare' => sub {' block,  
 or in  
 '_stop_step_4_upload' sub below 'next unless -f $file;' line.  
 This fixes permissions just before the final upload. If fix like this is ok, than the issue can probably be considered resolved. However as it seems that it can be fixed on more places, I am not sure about finding best solution, since I am not at all expert on the client or server upload code. It should probably be fixed already at the moment the file is placed in the pool/X/assets_public directory, or in some even more appropriate places.   


 ## Suggestion 
 * Understand the current code and where it distinguishes different flows based on the file size (likely related to upload chunk size) 
 * Fix in the same way regardless of the file size   

Back