Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3094

yum package_module fails to get package updates available until something initalizes the yum package cache

    XMLWordPrintable

    Details

      Description

      The yum package_module fails to get package updates available until the yum package cache is initalized.
      yum list-updates-local fails to list packages, and an error indicating that yum was unable to retrieve the repository metadata is emitted.

      [root@hub packages]# time /var/cfengine/modules/packages/yum list-updates-local < /dev/null
      Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
      
      real    0m0.188s
      user    0m0.141s
      sys     0m0.044s
      

      Refreshing the yum cache allows local updates to be listed.

      [root@hub packages]# yum makecache | tail && /var/cfengine/modules/packages/yum list-updates-local < /dev/null | head
      Loaded plugins: fastestmirror
      Determining fastest mirrors
      Metadata Cache Created
      Name=acl
      Version=2.2.49-7.el6_9.1
      Architecture=x86_64
      Name=audit
      Version=2.4.5-6.el6
      Architecture=x86_64
      Name=audit-libs
      Version=2.4.5-6.el6
      Architecture=x86_64
      Name=authconfig
      

      Potential Fixes

      If yum list-updates-local fails when using offline listing, fall back and allow the query to hit the network

      This patch works in my limited testing. At least, for newly provisioned systems where the cache is not present, this improves the case.

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      --- yum 2019-07-08 14:03:05.846194772 +0000
      +++ yum-try-online-if-local-fails       2019-07-08 18:28:19.772723463 +0000
      @@ -123,6 +123,12 @@
           # 0 means no updates
           # 1 means there was an error
           # 100 means that there are available updates
      +    if process.returncode == 1 and not online:
      +        # If we get an error when listing local updates, try again using the online method, so that the cache is generated
      +        online_flag = []
      +        process = subprocess_Popen([yum_cmd] + yum_options + online_flag + ["check-update"], stdout=subprocess.PIPE)
      +        (stdoutdata, _) = process.communicate()
      +
           if process.returncode != 100:
               # either there were no updates or error happened
               # Nothing to do for us here anyway
      

      Instrument the MPF to run yum makecache if no cache is present

      Have cf-agent run list-updates when no package database is present (and it makes one)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel