CentOS / container-pipeline-service

Code, infrastructure and deployment backend for the CentOS Container Pipeline backing up build system for registry.centos.org
https://registry.centos.org
GNU General Public License v3.0
49 stars 27 forks source link

Pipeline scanner (yum-update scanner) should show logs even when no package updates are required #564

Closed dharmit closed 6 years ago

dharmit commented 6 years ago

pipeline-scanner (or the yum-update scanner) doesn't show any logs when there are not RPM updates available for the container image. For example - https://registry.centos.org/pipeline-logs/ZTBkMjNhMDVkZj/pipeline_scanner_results.json

But for the same image, misc-package-updates scanner shows logs even when there are no updates available or it fails to run due to lack of binary in the image - https://registry.centos.org/pipeline-logs/ZTBkMjNhMDVkZj/misc_package_updates_scanner_results.json

Similar to misc-package-updates scanner, we should show logs in pipeline-scanner as well.

navidshaikh commented 6 years ago

This is because of this block

        if json_data["Scan Results"]["Package Updates"]:
            data["logs"] = json_data
            data["msg"] = "RPM updates available for the image."
        else:
            data["logs"] = {}
            data["msg"] = "No updates required."
        return data

Fixed in #558 here.

navidshaikh commented 6 years ago

Sample output after fix

{
    "image_under_test": "172.29.33.29:5000/projectatomic/cri-o:YjQ1MWM5OWQ3NG", 
    "logs": {
        "CVE Feed Last Updated": "NA", 
        "Finished Time": "2018-04-11-17-55-34-934202", 
        "Scan Results": {
            "OS Release": "CentOS Linux 7 (Core)", 
            "Package Updates": []
        }, 
        "Scan Type": "Image Scan", 
        "Scanner": "pipeline-scanner", 
        "Start Time": "2018-04-11-17-55-34-697317", 
        "Successful": false, 
        "Summary": "Error occured while processing yum updates. Cannot open logfile /scanin/_52337bc0e3a9ce349f3ee0efb74b3afc201f1265ebd895a6d8fb73202180ce48/var/log/yum.log\novl: Error while doing RPMdb copy-up:\n[Errno 30] Read-only file system: '/scanin/_52337bc0e3a9ce349f3ee0efb74b3afc201f1265ebd895a6d8fb73202180ce48/var/lib/rpm/.dbenv.lock'\nCould not create lock at /scanin/_52337bc0e3a9ce349f3ee0efb74b3afc201f1265ebd895a6d8fb73202180ce48/var/run/yum.pid: [Errno 30] Read-only file system: '/scanin/_52337bc0e3a9ce349f3ee0efb74b3afc201f1265ebd895a6d8fb73202180ce48/var/run/yum.pid' \n\n\nCan't create lock file; exiting\n", 
        "UUID": "52337bc0e3a9ce349f3ee0efb74b3afc201f1265ebd895a6d8fb73202180ce48"
    }, 
    "msg": "No updates required.", 
    "scanner": "pipeline-scanner"
}