WIP Add SQS daemon (bug 1288282) draft
authorbyron jones <glob@mozilla.com>
Wed, 27 Sep 2017 15:02:00 +0800
changeset 11718 d16e27b6766c648d9e66764fd6ed01622a552df1
parent 11717 c242cadfee5601cd9ff82f272f6f14e7767f8b5b
child 11719 c9c8686da29e38b558c4f916344b66cf02989f16
push id1805
push userbjones@mozilla.com
push dateWed, 27 Sep 2017 07:33:57 +0000
bugs1288282
WIP Add SQS daemon (bug 1288282) Add a daemon which listens to SQS for messages, associated config, and command line runner. MozReview-Commit-ID: 82d1JxoQm55
ansible/roles/vcs-sync/templates/servo-sync.ini.j2
vcssync/mozvcssync/servo.py
vcssync/setup.py
--- a/ansible/roles/vcs-sync/templates/servo-sync.ini.j2
+++ b/ansible/roles/vcs-sync/templates/servo-sync.ini.j2
@@ -15,8 +15,12 @@ pulse_hgmo_queue = {{ servo_pulse_hgmo_q
 servo_github_name = servo/servo
 servo_fetch_ref = refs/heads/master
 
 hg_converted = {{ servo_linear_hg_url }}
 
 backout_integration_url = {{ backout_integration_url | mandatory }}
 backout_github_name = {{ backout_github_name | mandatory }}
 backout_author = {{ backout_author | mandatory }}
+
+sqs_coland_region = {{ sqs_coland_region | mandatory }}
+sqs_coland_queue = {{ sqs_coland_queue | mandatory }}
+sqs_coland_error_queue = {{ sqs_coland_error_queue | mandatory }}
--- a/vcssync/mozvcssync/servo.py
+++ b/vcssync/mozvcssync/servo.py
@@ -165,16 +165,50 @@ def pulse_daemon():
     parser.add_argument('config', help='Path to config file to load')
 
     args = parser.parse_args()
 
     config = load_config(args.config)
     run_pulse_listener(config)
 
 
+def sqs_daemon():
+    import argparse
+    from . import sqs
+
+    configure_stdout()
+    logging.getLogger('sqs').setLevel(logging.INFO)
+    logging.getLogger('git').setLevel(logging.INFO)
+
+    parser = argparse.ArgumentParser()
+
+    parser.add_argument('config', help='Path to config file to load')
+    parser.add_argument('integration_path',
+                        help='Path to integration repo clone')
+    parser.add_argument('github_path',
+                        help='Path to github repo clone')
+    parser.add_argument('--interval', default=30, type=int,
+                        help='Interval to poll for messages (seconds)')
+    args = parser.parse_args()
+
+    config = load_config(args.config)
+    config['integration_path'] = args.integration_path
+    config['github_path'] = args.github_path
+
+    class SqsHandler(sqs.SqsListener):
+        def handle_message(self, message):
+            raise sqs.SqsFatalException('not implemented')
+
+    listener = SqsHandler(region=config['sqs_coland_region'],
+                          queue=config['sqs_coland_queue'],
+                          error_queue=config['sqs_coland_error_queue'],
+                          interval=args.interval)
+    listener.listen()
+
+
 def tree_is_open(tree):
     """Return if the specified tree is open according to treestatus.m.o"""
     import requests
 
     # Allow tests to set tree status directly.
     if 'TEST_TREESTATUS' in os.environ:
         if os.getenv('TEST_TREESTATUS') == 'error':
             raise Exception('Failed to determine tree status')
--- a/vcssync/setup.py
+++ b/vcssync/setup.py
@@ -3,16 +3,17 @@ from setuptools import setup, find_packa
 
 console_scripts = [
     'linearize-git=mozvcssync.cli:linearize_git',
     'linearize-git-to-hg=mozvcssync.cli:linearize_git_to_hg',
     'overlay-hg-repos=mozvcssync.cli:overlay_hg_repos_cli',
     'servo-backout-pr-cli=mozvcssync.cli:servo_backout_pr_cli',
     'servo-overlay=mozvcssync.servo:overlay_cli',
     'servo-pulse-listen=mozvcssync.servo:pulse_daemon',
+    'servo-sqs-listen=mozvcssync.servo:sqs_daemon',
     'test-apply-changes=mozvcssync.util:test_apply_changes_from_list',
 ]
 
 # These commands are really only useful for testing. So don't expose them by
 # default.
 if 'VCSSYNC_ENABLE_TESTING_COMMANDS' in os.environ:
     console_scripts.extend([
     ])