upload/koji: always upload in the overwriting mode

We sometimes see the following error in the logs:
Fault(1000): upload path exists: /mnt/koji/work/osbuild-cg/osbuild-composer-koji-082e1c88/Fedora-IoT-38.raw.xz.

I think this happens when we retry the upload call of the first chunk due to
random network issues. The solution is to always upload in the overwriting
mode, which ignores the already existing file.
See https://pagure.io/koji/blob/175ecb5e8f3d45a1d244b227eb889321e5dd0a29/f/kojihub/kojihub.py#_15522

This is safe because:
1) We use UUIDs in the filename, which means that there should never be a real
   conflict.
2) The overwriting mode is actually the default mode in koji, see
   https://pagure.io/koji/blob/175ecb5e8f3d45a1d244b227eb889321e5dd0a29/f/koji/__init__.py#_3342

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2023-04-19 14:51:18 +02:00 committed by Tomáš Hozza
parent fdc4f54be8
commit bd7f0741b2

View file

@ -326,6 +326,7 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
q.Add("filename", filename)
q.Add("offset", fmt.Sprintf("%v", offset))
q.Add("fileverify", "adler32")
q.Add("overwrite", "true")
u.RawQuery = q.Encode()
client := createCustomRetryableClient()