#39 Add toddler for mirrorlist servers
Closed 3 years ago by pingou. Opened 3 years ago by adrian.
fedora-infra/ adrian/toddlers mirrorlist  into  master

@@ -0,0 +1,63 @@ 

+ """

+ Plugin to create the mirrorlist-server protobuf cache files.

+ 

+ Authors: Adrian Reber <adrian@lisas.de>

+ 

+ """

+ 

+ import logging

+ import subprocess

+ 

+ from ..base import ToddlerBase

+ 

+ 

+ _log = logging.getLogger(__name__)

+ 

+ 

+ class MirrorListCache(ToddlerBase):

+ 

+     name = "generate_mirrorlist_cache"

+ 

+     amqp_topics = [

+         "org.fedoraproject.*.toddlers.trigger.generate_mirrorlist_cache",

+     ]

+ 

+     def accepts_topic(self, topic):

+         """Returns a boolean whether this toddler is interested in messages

+         from this specific topic.

+         """

+         return topic.startswith("org.fedoraproject.") and topic.endswith(

+             "toddlers.trigger.generate_mirrorlist_cache"

+         )

+ 

+     def process(self, config, message):

+         # Generate MirrorList Cache

+         x = subprocess.run([

+             '/usr/bin/generate-mirrorlist-cache',

+             '-o',

+             '/var/lib/mirrormanager/mirrorlist_cache.proto',

+             '-c',

+             '/etc/mirrorlist/db.env'

+         ], capture_output=True)

+         if x != 0:

+             print("error")

+             print(x)

+ 

+         # Copy cache to proxies

+         x = subprocess.run([

+             '/usr/local/bin/sync_pkl_to_mirrorlists.sh'

+         ], capture_output=True)

+         if x != 0:

+             print("error")

+             print(x)

+ 

+ 

+ def main(args):

+     MirrorListCache().process()

+ 

+ 

+ if __name__ == "__main__":  # pragma: no cover

+     try:

+         main(sys.argv[1:])

+     except KeyboardInterrupt:

+         pass

The mirrorlist servers are using a protobuf based file to know which mirror has which files. This commit moves the protobuf generation to a toddler which can be either triggered by cron or manually if it is necessary.

This change is not tested as I had trouble running it locally.

I am happy to help to set up the environment of the toddler to have all necessary packages, scripts and ssh keys to make this work, but I would need some help to make sure the toddler works as it should.

Build failed.

  • tox : FAILURE in 8m 58s

@adrian I'm going to close this PR as iirc you went a different way to achieve this.

Pull-Request has been closed by pingou

3 years ago