Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Bug 1220738 part 2: Make scheduler use temporary credentials. r=garndt
Browse files Browse the repository at this point in the history
Scheduler is currently only used to extend graphs. Instead of using the
worker credentials, use the task temporary credentials for that.
  • Loading branch information
Wander Lairson Costa committed Mar 25, 2016
1 parent b72c083 commit 4d2c02e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
3 changes: 0 additions & 3 deletions bin/worker.js
Expand Up @@ -196,9 +196,6 @@ async function main () {
})
});

config.scheduler =
new taskcluster.Scheduler({ credentials: config.taskcluster });

config.validator = await base.validator();
config.validator.register(require('../schemas/payload'));

Expand Down
6 changes: 4 additions & 2 deletions lib/features/extend_task_graph.js
Expand Up @@ -5,6 +5,7 @@ var debug = require('debug')('docker-worker:middleware:extendTaskGraph');
var waitForEvent = require('../wait_for_event');
var tarStream = require('tar-stream');
var log = require('../log');
var taskcluster = require('taskcluster-client');


async function drain (listener) {
Expand All @@ -28,7 +29,9 @@ export default class ExtendTaskGraph {
var graphId = task.taskGroupId;

var container = taskHandler.dockerProcess.container;
var scheduler = taskHandler.runtime.scheduler;
var scheduler = new taskcluster.Scheduler({
credentials: taskHandler.claim.credentials
});

// Raw tar stream for the content.
var contentStream;
Expand Down Expand Up @@ -84,7 +87,6 @@ export default class ExtendTaskGraph {
'Dumping file. ' + JSON.stringify(entryJSON, null, 2)
);
}

// Extend the graph!
try {
var result = await scheduler.extendTaskGraph(graphId, extension);
Expand Down
37 changes: 32 additions & 5 deletions test/integration/taskgraph_extension_test.js
Expand Up @@ -38,6 +38,9 @@ suite('Extend Task Graph', function() {
source: 'http://mytest/',
owner: 'test@localhost.local'
},
scopes: [
'scheduler:extend-task-graph:' + graphId
],
payload: {
image: 'taskcluster/test-ubuntu',
command: cmd('echo "wooot custom!"'),
Expand All @@ -63,7 +66,8 @@ suite('Extend Task Graph', function() {
source: 'http://xfoobar.com'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
tasks: [{
taskId: primaryTaskId,
Expand All @@ -72,6 +76,10 @@ suite('Extend Task Graph', function() {
metadata: {
owner: 'tests@local.localhost'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
payload: {
image: 'taskcluster/test-ubuntu',
command: cmd(
Expand Down Expand Up @@ -119,7 +127,8 @@ suite('Extend Task Graph', function() {
source: 'http://xfoobar.com'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
tasks: [{
taskId: primaryTaskId,
Expand All @@ -128,6 +137,10 @@ suite('Extend Task Graph', function() {
metadata: {
owner: 'tests@local.localhost'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
payload: {
image: 'taskcluster/test-ubuntu',
command: cmd(
Expand Down Expand Up @@ -197,7 +210,8 @@ suite('Extend Task Graph', function() {
source: 'http://xfoobar.com'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
tasks: [{
taskId: primaryTaskId,
Expand All @@ -206,6 +220,10 @@ suite('Extend Task Graph', function() {
metadata: {
owner: 'tests@local.localhost'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
payload: {
image: 'taskcluster/test-ubuntu',
command: cmd(
Expand Down Expand Up @@ -241,7 +259,11 @@ suite('Extend Task Graph', function() {
provisionerId: worker.provisionerId,
// Because this scope is not included in the scopes the graph has, extending
// the task graph will fail
scopes: ['this-is-a-bad-scope'],
scopes: [
'this-is-a-bad-scope',
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
metadata: {
description: 'testing',
source: 'http://mytest/',
Expand Down Expand Up @@ -272,7 +294,8 @@ suite('Extend Task Graph', function() {
source: 'http://xfoobar.com'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
tasks: [{
taskId: primaryTaskId,
Expand All @@ -281,6 +304,10 @@ suite('Extend Task Graph', function() {
metadata: {
owner: 'tests@local.localhost'
},
scopes: [
'queue:define-task:' + worker.provisionerId + '/' + worker.workerType,
'scheduler:extend-task-graph:' + graphId
],
payload: {
image: 'taskcluster/test-ubuntu',
command: cmd(
Expand Down

0 comments on commit 4d2c02e

Please sign in to comment.