def on_event(data, message, dry_run, treeherder_server_url, acknowledge, **kwargs): if ignored(data): if acknowledge: message.ack() return 0 # SUCCESS # Cleaning mozci caches buildjson.BUILDS_CACHE = {} query_jobs.JOBS_CACHE = {} repo_name = data["project"] action = data["action"] times = data["times"] # Pulse gives us resultset_id, we need to get revision from it. resultset_id = data["resultset_id"] treeherder_client = TreeherderClient(server_url=treeherder_server_url) LOG.info("%s action requested by %s on repo_name %s with resultset_id: %s" % ( data['action'], data["requester"], data["project"], data["resultset_id"]) ) revision = treeherder_client.get_resultsets(repo_name, id=resultset_id)[0]["revision"] status = None if action == "trigger_missing_jobs": mgr = BuildAPIManager() mgr.trigger_missing_jobs_for_revision(repo_name, revision, dry_run=dry_run) if acknowledge: status = 'trigger_missing_jobs request sent' else: status = 'Dry-mode, no request sent' elif action == "trigger_all_talos_jobs": trigger_all_talos_jobs( repo_name=repo_name, revision=revision, times=times, priority=-1, dry_run=dry_run ) if acknowledge: status = 'trigger_all_talos_jobs: {0} times request sent with priority'\ 'lower then normal'.format(times) else: status = 'Dry-mode, no request sent' else: raise Exception( 'We were not aware of the "{}" action. Please address the code.'.format(action) ) LOG.debug(status) if acknowledge: # We need to ack the message to remove it from our queue message.ack() return 0 # SUCCESS
def on_event(data, message, dry_run, treeherder_server_url, **kwargs): if ignored(data): return 0 # SUCCESS # Cleaning mozci caches buildjson.BUILDS_CACHE = {} query_jobs.JOBS_CACHE = {} repo_name = data["project"] action = data["action"] times = data["times"] # Pulse gives us resultset_id, we need to get revision from it. resultset_id = data["resultset_id"] treeherder_client = TreeherderClient(server_url=treeherder_server_url) LOG.info( "%s action requested by %s on repo_name %s with resultset_id: %s" % (data['action'], data["requester"], data["project"], data["resultset_id"])) revision = treeherder_client.get_resultsets(repo_name, id=resultset_id)[0]["revision"] if action == "trigger_missing_jobs": mgr = BuildAPIManager() mgr.trigger_missing_jobs_for_revision(repo_name, revision, dry_run=dry_run) elif action == "trigger_all_talos_jobs": trigger_all_talos_jobs(repo_name=repo_name, revision=revision, times=times, priority=-1, dry_run=dry_run) else: raise Exception( 'We were not aware of the "{}" action. Please address the code.'. format(action)) return 0 # SUCCESS
def main(): options = parse_args() validate_options(options) repo_url = query_repo_url(options.repo_name) if not valid_credentials(): sys.exit(-1) if options.debug: LOG = setup_logging(logging.DEBUG) else: LOG = setup_logging(logging.INFO) # Setting the QUERY_SOURCE global variable in mozci.py set_query_source(options.query_source) if options.buildernames: options.buildernames = sanitize_buildernames(options.buildernames) repo_url = query_repo_url_from_buildername(options.buildernames[0]) if not options.repo_name: options.repo_name = query_repo_name_from_buildername( options.buildernames[0]) if options.rev == 'tip': revision = query_repo_tip(repo_url) LOG.info("The tip of %s is %s", options.repo_name, revision) else: revision = query_full_revision_info(repo_url, options.rev) # Mode 1: Trigger coalesced jobs if options.coalesced: query_api = BuildApi() request_ids = query_api.find_all_jobs_by_status( options.repo_name, revision, COALESCED) if len(request_ids) == 0: LOG.info('We did not find any coalesced job') for request_id in request_ids: make_retrigger_request(repo_name=options.repo_name, request_id=request_id, auth=get_credentials(), dry_run=options.dry_run) return # Mode #2: Fill-in a revision or trigger_test_jobs_only if options.fill_revision or options.trigger_tests_only: BuildAPIManager().trigger_missing_jobs_for_revision( repo_name=options.repo_name, revision=revision, dry_run=options.dry_run, trigger_build_if_missing=not options.trigger_tests_only) return # Mode #3: Trigger jobs based on revision list modifiers for buildername in options.buildernames: revlist = determine_revlist(repo_url=repo_url, buildername=buildername, rev=revision, back_revisions=options.back_revisions, delta=options.delta, from_rev=options.from_rev, backfill=options.backfill, skips=options.skips, max_revisions=options.max_revisions) try: trigger_range( buildername=buildername, revisions=revlist, times=options.times, dry_run=options.dry_run, files=options.files, trigger_build_if_missing=options.trigger_build_if_missing) except Exception, e: LOG.exception(e) exit(1) if revlist: LOG.info('https://treeherder.mozilla.org/#/jobs?%s' % urllib.urlencode({ 'repo': options.repo_name, 'fromchange': revlist[-1], 'tochange': revlist[0], 'filter-searchStr': buildername }))
def on_event(data, message, dry_run, treeherder_server_url, acknowledge, **kwargs): LOG.info('Acknowledge value: {}'.format(acknowledge)) if ignored(data): if acknowledge: LOG.info('Message acknowledged') message.ack() return 0 # SUCCESS # Cleaning mozci caches buildjson.BUILDS_CACHE = {} query_jobs.JOBS_CACHE = {} repo_name = data["project"] action = data["action"] times = data["times"] # Pulse gives us resultset_id, we need to get revision from it. resultset_id = data["resultset_id"] treeherder_client = TreeherderClient(server_url=treeherder_server_url) LOG.info("%s action requested by %s on repo_name %s with resultset_id: %s" % ( data['action'], data["requester"], data["project"], data["resultset_id"]) ) revision = treeherder_client.get_resultsets(repo_name, id=resultset_id)[0]["revision"] status = None if action == "trigger_missing_jobs": mgr = BuildAPIManager() mgr.trigger_missing_jobs_for_revision(repo_name, revision, dry_run=dry_run) if acknowledge: status = 'trigger_missing_jobs request sent' else: status = 'Dry-mode, no request sent' elif action == "trigger_all_talos_jobs": trigger_all_talos_jobs( repo_name=repo_name, revision=revision, times=times, priority=-1, dry_run=dry_run ) if acknowledge: status = 'trigger_all_talos_jobs: {0} times request sent with priority'\ 'lower then normal'.format(times) else: status = 'Dry-mode, no request sent' else: raise Exception( 'We were not aware of the "{}" action. Please address the code.'.format(action) ) LOG.debug(status) if acknowledge: # We need to ack the message to remove it from our queue LOG.info('Message acknowledged') message.ack() return 0 # SUCCESS
def on_resultset_action_event(data, message, dry_run, stage=False): # Cleaning mozci caches buildjson.BUILDS_CACHE = {} query_jobs.JOBS_CACHE = {} repo_name = data["project"] action = data["action"] times = data["times"] # Pulse gives us resultset_id, we need to get revision from it. resultset_id = data["resultset_id"] if stage: treeherder_client = TreeherderClient(host='treeherder.allizom.org') else: treeherder_client = TreeherderClient() # We do not handle 'cancel_all' action right now, so skip it. if action == "cancel_all": if not dry_run: message.ack() return LOG.info("%s action requested by %s on repo_name %s with resultset_id: %s" % ( data['action'], data["requester"], data["project"], data["resultset_id"]) ) revision = treeherder_client.get_resultsets(repo_name, id=resultset_id)[0]["revision"] status = None if action == "trigger_missing_jobs": mgr = BuildAPIManager() mgr.trigger_missing_jobs_for_revision(repo_name, revision, dry_run=dry_run) if not dry_run: status = 'trigger_missing_jobs request sent' else: status = 'Dry-mode, no request sent' elif action == "trigger_all_talos_jobs": trigger_all_talos_jobs( repo_name=repo_name, revision=revision, times=times, priority=-1, dry_run=dry_run ) if not dry_run: status = 'trigger_all_talos_jobs: {0} times request sent with priority'\ 'lower then normal'.format(times) else: status = 'Dry-mode, no request sent' # Send a pulse message showing what we did message_sender = MessageHandler() pulse_message = { 'resultset_id': resultset_id, 'action': action, 'requester': data['requester'], 'status': status} routing_key = '{}.{}'.format(repo_name, action) try: message_sender.publish_message(pulse_message, routing_key) except: LOG.warning("Failed to publish message over pulse stream.") if not dry_run: # We need to ack the message to remove it from our queue message.ack()