Haiqing Bai 08b1999b5b downloader: Removed the corrupted downloaded deb file
Sometimes corrupted deb file is kept in download directory
though exception is raised by candidate.fetch_binary() in
the function download(). This corrupted deb file will be
uploaded to the remote binary repository. The below was
one of the cases we once had which caused this issue:
INFO:  trace-cmd_2.9.1-1 is uploaded to deb-local-binary
DEBUG: package usb.ids_2022.05.20-0+deb11u1 needs to be downloaded
DEBUG: Fail to fetch binary usb.ids_2022.05.20-0+deb11u1
DEBUG: The item 'starlingx/binaries/usb.ids_2022.05.20-0+deb11u1_all.deb'
       could not be fetched: 404  Not Found [IP: 10.101.144.137 80]

This commit is to remove the corrupted deb file and prevent
it uploading to the remote repository when exception got.

Test Plan:
Pass:
a. Since this is not a issue that recurs every time, below
   code is added to raise exception to test the exception handling:
   between line "package.candidate = candidate" and
   "ret = package.candidate.fetch_binary(self.dl_dir)":
   "if deb_name == 'usb.ids_2022.05.20-0+deb11u1':
        os.system('touch ' + os.path.join(self.dl_dir, deb_name + '_all.deb'))
        raise Exception("Fake exception to test exception handling")"
b. Make sure that there is not 'usb.ids*' in
   '/import/mirrors/starlingx/binaries' in builder container
c. Run 'repo_manage.py list_pkgs -r deb-local-binary' and check the
   '/localdisk/builder.log' to make sure there is not 'usb.ids*.deb'
   in the remote repository 'deb-local-binary'
d. $downloader -b
e. downloader should print on screen:
   downloader - ERROR: Failed to download packages: 1
   downloader - ERROR: usb.ids_2022.05.20-0+deb11u1
f. Check the log file '/localdisk/builder.log', there should be below
   messages:
   downloader - DEBUG: package usb.ids_2022.05.20-0+deb11u1 needs to be downloaded
   downloader - DEBUG: Fail to fetch binary usb.ids_2022.05.20-0+deb11u1
   downloader - DEBUG: Fake exception to test exception handling
g. Make sure that there is not 'usb.ids_2022.05.20-0+deb11u1_all.deb' in
   '/import/mirrors/starlingx/binaries'.
h. Check that there is not 'usb.ids_2022.05.20-0+deb11u1*.deb' in deb-local-binary:
   $repo_manage.py list_pkgs -r deb-local-binary

Story: 2008846
Task: 47123

Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
Change-Id: I5923d72040abd8dee29be5cb24aa7a7f95a6edac
2023-01-11 12:45:36 +08:00
2022-10-31 16:01:18 +08:00
2019-04-19 19:52:37 +00:00
2018-06-01 07:45:23 -07:00
Description
StarlingX build source tree root
12 MiB
Languages
Python 62%
Shell 36.9%
BitBake 0.6%
Dockerfile 0.5%