Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-19891

Yum repository configured through script API cache not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: 3.13.0, 3.16.1
    • Fix Version/s: None
    • Component/s: Scripting, Yum
    • Environment:
      docker-nexus; eg sonatype/nexus3:3.16.1
    • Story Points:
      0

      Description

      when creating a yum proxy; according to https://support.sonatype.com/hc/en-us/articles/115010182627-Understanding-Caching-Configuration setting maximum metadata age to 0 should make sure that new versions are always found.

      I have ran the following tests scenario:

      • create a small repository with my.1.rpm
      • create proxy in nexus
      • install using this proxy: works fine
      • now add my.2.rpm in the repository
      • try to update; yum/zypper says no new versions are to be found (not even after forcing refresh,...)

      Note that when I set maximum metadata age to 1 and I wait one minute, then yum/zypper does find the new package. However I would like to set this to 0 in order to never have to wait a minute. Yet that configuration does not seem to work; the nexus cache is never invalidated somehow.

      EDIT

      I have been able to pin down the problem more specifically: I create the proxy in nexus using the script API (a major hassle by the way). The repository seems correctly created but doesn't seem to work perfectly well unless I change something manually. The exact same configuration entered manually in the UI works fine.

      • API configured repo:
        • I use python to do something similar to this: 
        • the exact script that I post (more readable here than with all those escaped quotes):
          • repository.createYumProxy('{name}', '{url}');
          • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'proxy'.'contentMaxAge' = 0;
          • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'proxy'.'metadataMaxAge' = 0;
          • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'negativeCache'.'timeToLive' = 0;
          • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'cleanup' = ['policyName': null];
      • manually configured repo:
        • create yum (proxy)
        • name: test
        • url: http://repository:8080
        • maximum component age: 0
        • maximum metadata age: 0
        • not found cache TTL: 0
        • create repository

      I don't see a single difference between the manually configured repository and the one I configured using the script API. Yet the manually configured repository is correctly functional.

      EDIT2

      using the script API again to fetch the repository attributes I found that a manually configured repository was slightly different from the one configured through the API:

      • API configured repo:
        • httpclient:[connection:[blocked:false, autoBlock:true]],
          proxy:[remoteUrl:http://repository:8080/, contentMaxAge:0, metadataMaxAge:0],
          negativeCache:[enabled:true, timeToLive:0],
          storage:[blobStoreName:default, strictContentTypeValidation:true]
      • manually configured repo:
        • httpclient:[blocked:false, autoBlock:true],
          proxy:[remoteUrl:http://repository:8080/, contentMaxAge:0.0, metadataMaxAge:0.0],
          routingRules:[routingRuleId:null],
          negativeCache:[enabled:true, timeToLive:0.0],
          storage:[blobStoreName:default, strictContentTypeValidation:true],
          cleanup:[policyName:None]
      • so I enhanced my script to create a proxy repository through the API like this:
        • repository.createYumProxy('{name}', '{url}')
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'httpclient' = repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'httpclient'.'connection'
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'routingRules' = ['routingRuleId':'null']
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'proxy'.'contentMaxAge' = 0.0
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'proxy'.'metadataMaxAge' = 0.0
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'negativeCache'.'timeToLive' = 0.0
        • repository.getRepositoryManager().get('{name}').getConfiguration().getAttributes().'cleanup' = ['policyName':'None']
      • now both a manually configured repository give exactly the same response (except for the order of the attributes). Yet still the cache of the repository configured through the API seems never to expire...

      EDIT3:

      *I have attached a complete test scenario to this ticket; running *docker-compose up ** will run the tests. The tests will fail because the newest version of the rpm cannot be installed.
      If you want to inspect and/or run the tests manually; then change the COMMAND in the Dockerfile to sleep; and you can then run the tests manually and inspect the test container.

        Attachments

          Activity

            People

            Assignee:
            mdodgson Mark Dodgson
            Reporter:
            Maes Chris Maes
            Last Updated By:
            Peter Lynch Peter Lynch
            Team:
            NXRM - Cypher
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response:

                tigCommentSecurity.panel-title