Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
maxDelay: cfg.get('influx:maxDelay'),
maxPendingPoints: cfg.get('influx:maxPendingPoints')
});
// Start monitoring the process
base.stats.startProcessUsageReporting({
drain: influx,
component: cfg.get('treeherder:statsComponent'),
process: 'handlers'
});
// Configure queue and queueEvents
var queue = new taskcluster.Queue({
baseUrl: cfg.get('taskcluster:queueBaseUrl')
});
var queueEvents = new taskcluster.QueueEvents({
exchangePrefix: cfg.get('taskcluster:queueExchangePrefix')
});
// Load Project objects
var projects = [];
_.forIn(JSON.parse(cfg.get('treeherder:projects')), function(project, name) {
projects.push(new Project(name, {
consumerKey: project.consumer_key,
consumerSecret: project.consumer_secret,
baseUrl: cfg.get('treeherder:baseUrl')
}));
});
// Create event handlers
var handlers = new Handlers({
queue: queue,
import _ from 'lodash';
import slugid from 'slugid';
import { Queue, QueueEvents, Scheduler } from 'taskcluster-client';
import Project from 'mozilla-treeherder/project';
import Debug from 'debug';
import parseRoute from '../util/route_parser';
let Joi = require('joi');
let debug = Debug('treeherder:job_handler');
let events = new QueueEvents();
// XXX: Consider making this a configuration options?
const TREEHERDER_INTERVAL = 1000;
// Schema for the task.extra.treeherder field.
const SCHEMA = Joi.object().keys({
// Maps directly to `build_platform`
build: Joi.object().keys({
platform: Joi.string().required().
description('Treeherder platform name'),
os_name: Joi.string().default('-').
description('Operating system name for build (linux)'),
architecture: Joi.string().default('-').
description('Operating system architecture (x64, etc..)')
}).required().rename('os', 'os_name'),
// Create a validator
var validator = null;
var validatorCreated = base.validator({
folder: path.join(__dirname, '..', 'schemas'),
constants: require('../schemas/constants'),
schemaPrefix: 'index/v1/'
}).then(function(validator_) {
validator = validator_;
});
// Configure queue and queueEvents
var queue = new taskcluster.Queue({
baseUrl: cfg.get('taskcluster:queueBaseUrl'),
credentials: cfg.get('taskcluster:credentials')
});
var queueEvents = new taskcluster.QueueEvents({
exchangePrefix: cfg.get('taskcluster:queueExchangePrefix')
});
// When: validator is created, proceed
return validatorCreated.then(function() {
// Create event handlers
var handlers = new Handlers({
IndexedTask: IndexedTask,
Namespace: Namespace,
queue: queue,
queueEvents: queueEvents,
credentials: cfg.get('pulse'),
queueName: cfg.get('index:listenerQueueName'),
routePrefix: cfg.get('index:routePrefix'),
drain: influx,
component: cfg.get('index:statsComponent')
// (see this.createTasks for example)
this.queueClient = new taskcluster.Queue({
rootUrl: this.context.cfg.taskcluster.rootUrl,
});
// Listen for new jobs created via the api webhook endpoint
const GithubEvents = taskcluster.createClient(this.reference);
const githubEvents = new GithubEvents({rootUrl: this.rootUrl});
const jobBindings = [
githubEvents.pullRequest(),
githubEvents.push(),
githubEvents.release(),
];
const schedulerId = this.context.cfg.taskcluster.schedulerId;
const queueEvents = new taskcluster.QueueEvents({rootUrl: this.rootUrl});
const statusBindings = [
queueEvents.taskFailed(`route.${this.context.cfg.app.checkTaskRoute}`),
queueEvents.taskException(`route.${this.context.cfg.app.checkTaskRoute}`),
queueEvents.taskCompleted(`route.${this.context.cfg.app.checkTaskRoute}`),
];
// Listen for state changes to the taskcluster tasks and taskgroups
// We only need to listen for failure and exception events on
// tasks. We wait for the entire group to be resolved before checking
// for success.
const deprecatedResultStatusBindings = [
queueEvents.taskFailed(`route.${this.context.cfg.app.statusTaskRoute}`),
queueEvents.taskException(`route.${this.context.cfg.app.statusTaskRoute}`),
queueEvents.taskGroupResolved({schedulerId}),
];
import * as format from '../../lib/format';
import {Button, Alert} from 'react-bootstrap';
import React from 'react';
import taskcluster from 'taskcluster-client';
/**
* Creation of queue. If credentials are available, we use them at the start of the application
*/
export let queue = localStorage.credentials ?
new taskcluster.Queue({credentials: JSON.parse(localStorage.credentials)}) :
new taskcluster.Queue();
/**
* Creation of queueEvents
*/
export const queueEvents = new taskcluster.QueueEvents();
/**
* Authentication
*/
export const authentication = {
login: credentials => {
queue = new taskcluster.Queue({credentials});
},
};
/**
* WebListener
* Setup bindings and event callbacks
*/
let listener = new taskcluster.WebListener();
module.exports = options => ({
auth: new Auth(options),
github: new Github(options),
hooks: new Hooks(options),
index: new Index(options),
purgeCache: new PurgeCache(options),
queue: new Queue(options),
secrets: new Secrets(options),
queueEvents: new QueueEvents(options),
notify: new Notify(options),
workerManager: new WorkerManager(options),
});
setup: async ({cfg, publisher, schemaset, monitor, docs, validator, pulseClient}) => {
const queueEvents = new taskcluster.QueueEvents({
rootUrl: cfg.taskcluster.rootUrl,
});
const queue = new taskcluster.Queue({
rootUrl: cfg.taskcluster.rootUrl,
});
const prefix = cfg.treeherder.routePrefix;
const handler = new Handler({
cfg,
queue,
queueEvents,
pulseClient,
prefix,
publisher,
validator,
monitor: monitor.monitor('handler'),
import slugid from 'slugid';
import { Queue, QueueEvents } from 'taskcluster-client';
import Project from 'mozilla-treeherder/project';
let events = new QueueEvents();
const EVENT_MAP = {
[events.taskDefined().exchange]: 'defined',
[events.taskPending().exchange]: 'pending',
[events.taskRunning().exchange]: 'running',
[events.taskCompleted().exchange]: 'completed',
[events.taskFailed().exchange]: 'failed',
[events.taskException().exchange]: 'exception'
};
/** Convert Date object or JSON date-time string to UNIX timestamp */
function timestamp(date) {
return Math.floor(new Date(date).getTime() / 1000);
};
function stateFromRun(run) {