screwdriver-queue-service 5.0.1 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/server +1 -1
- package/config/custom-environment-variables.yaml +1 -0
- package/config/default.yaml +2 -0
- package/lib/server.js +1 -1
- package/package.json +1 -1
- package/plugins/queue/index.js +2 -2
- package/plugins/queue/put.js +6 -1
- package/plugins/queue/scheduler.js +60 -39
package/bin/server
CHANGED
|
@@ -239,6 +239,7 @@ queue:
|
|
|
239
239
|
prefix: REDIS_QUEUE_PREFIX
|
|
240
240
|
# whether or not to retrieve from redis that the data needed to start periodic builds
|
|
241
241
|
periodicBuildTableEnabled: PERIODIC_BUILD_TABLE_ENABLED
|
|
242
|
+
queueMaxPayloadSize: QUEUE_MAX_PAYLOAD_SIZE
|
|
242
243
|
|
|
243
244
|
plugins:
|
|
244
245
|
blockedBy:
|
package/config/default.yaml
CHANGED
|
@@ -167,6 +167,8 @@ queue:
|
|
|
167
167
|
prefix: ""
|
|
168
168
|
# whether or not to retrieve from redis that the data needed to start periodic builds
|
|
169
169
|
periodicBuildTableEnabled: true
|
|
170
|
+
# max payload size in bytes, default to 10MB
|
|
171
|
+
queueMaxPayloadSize: 10485760
|
|
170
172
|
|
|
171
173
|
plugins:
|
|
172
174
|
blockedBy:
|
package/lib/server.js
CHANGED
package/package.json
CHANGED
package/plugins/queue/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const scheduler = require('./scheduler');
|
|
|
7
7
|
|
|
8
8
|
const queuePlugin = {
|
|
9
9
|
name: 'queue',
|
|
10
|
-
async register(server) {
|
|
10
|
+
async register(server, options) {
|
|
11
11
|
/**
|
|
12
12
|
* Exposes an init function to begin the scheduler process
|
|
13
13
|
* @method init
|
|
@@ -28,7 +28,7 @@ const queuePlugin = {
|
|
|
28
28
|
return scheduler.cleanUp(executor);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
server.route([putRoute(), deleteRoute(), statsRoute()]);
|
|
31
|
+
server.route([putRoute(options), deleteRoute(), statsRoute()]);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
package/plugins/queue/put.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const logger = require('screwdriver-logger');
|
|
4
4
|
const scheduler = require('./scheduler');
|
|
5
5
|
|
|
6
|
-
module.exports =
|
|
6
|
+
module.exports = options => ({
|
|
7
7
|
method: 'POST',
|
|
8
8
|
path: '/queue/message',
|
|
9
9
|
config: {
|
|
@@ -14,6 +14,11 @@ module.exports = () => ({
|
|
|
14
14
|
strategies: ['token'],
|
|
15
15
|
scope: ['sdapi']
|
|
16
16
|
},
|
|
17
|
+
payload: {
|
|
18
|
+
maxBytes: parseInt(options.queueMaxPayloadSize, 10) || 5242880, // 5MB default
|
|
19
|
+
parse: true,
|
|
20
|
+
output: 'data'
|
|
21
|
+
},
|
|
17
22
|
handler: async (request, h) => {
|
|
18
23
|
try {
|
|
19
24
|
const executor = request.server.app.executorQueue;
|
|
@@ -422,51 +422,14 @@ async function start(executor, config) {
|
|
|
422
422
|
throw value.error;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
let buildUpdatePayload;
|
|
426
|
-
|
|
427
425
|
if (isVirtualJob(annotations)) {
|
|
428
426
|
// Bypass execution of the build if the job is virtual
|
|
429
|
-
buildUpdatePayload = {
|
|
427
|
+
const buildUpdatePayload = {
|
|
430
428
|
status: 'SUCCESS',
|
|
431
429
|
statusMessage: 'Skipped execution of the virtual job',
|
|
432
430
|
statusMessageType: 'INFO'
|
|
433
431
|
};
|
|
434
|
-
} else {
|
|
435
|
-
const token = executor.tokenGen(
|
|
436
|
-
Object.assign(tokenConfig, { scope: ['temporal'] }),
|
|
437
|
-
TEMPORAL_TOKEN_TIMEOUT
|
|
438
|
-
);
|
|
439
432
|
|
|
440
|
-
// set the start time in the queue
|
|
441
|
-
Object.assign(config, { token });
|
|
442
|
-
// Store the config in redis
|
|
443
|
-
await executor.redisBreaker.runCommand('hset', executor.buildConfigTable, buildId, JSON.stringify(config));
|
|
444
|
-
|
|
445
|
-
const blockedBySameJob = reach(config, 'annotations>screwdriver.cd/blockedBySameJob', {
|
|
446
|
-
separator: '>',
|
|
447
|
-
default: true
|
|
448
|
-
});
|
|
449
|
-
const blockedBySameJobWaitTime = reach(config, 'annotations>screwdriver.cd/blockedBySameJobWaitTime', {
|
|
450
|
-
separator: '>',
|
|
451
|
-
default: BLOCKED_BY_SAME_JOB_WAIT_TIME
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
// Note: arguments to enqueue are [queue name, job name, array of args]
|
|
455
|
-
enq = await executor.queueBreaker.runCommand('enqueue', executor.buildQueue, 'start', [
|
|
456
|
-
{
|
|
457
|
-
buildId,
|
|
458
|
-
jobId,
|
|
459
|
-
blockedBy: blockedBy.toString(),
|
|
460
|
-
blockedBySameJob,
|
|
461
|
-
blockedBySameJobWaitTime
|
|
462
|
-
}
|
|
463
|
-
]);
|
|
464
|
-
if (buildStats) {
|
|
465
|
-
buildUpdatePayload = { stats: build.stats, status: 'QUEUED' };
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
if (buildUpdatePayload) {
|
|
470
433
|
await helper
|
|
471
434
|
.updateBuild(
|
|
472
435
|
{
|
|
@@ -478,10 +441,68 @@ async function start(executor, config) {
|
|
|
478
441
|
helper.requestRetryStrategy
|
|
479
442
|
)
|
|
480
443
|
.catch(err => {
|
|
481
|
-
logger.error(`Failed to update build status for build ${buildId}: ${err}`);
|
|
444
|
+
logger.error(`Failed to update virtual build status for build ${buildId}: ${err}`);
|
|
482
445
|
|
|
483
446
|
throw err;
|
|
484
447
|
});
|
|
448
|
+
} else {
|
|
449
|
+
if (buildStats) {
|
|
450
|
+
await helper
|
|
451
|
+
.updateBuild(
|
|
452
|
+
{
|
|
453
|
+
buildId,
|
|
454
|
+
token: buildToken,
|
|
455
|
+
apiUri,
|
|
456
|
+
payload: { stats: build.stats, status: 'QUEUED' }
|
|
457
|
+
},
|
|
458
|
+
helper.requestRetryStrategy
|
|
459
|
+
)
|
|
460
|
+
.catch(err => {
|
|
461
|
+
logger.error(`Failed to update build status to QUEUED for build ${buildId}: ${err}`);
|
|
462
|
+
throw err;
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
try {
|
|
467
|
+
const token = executor.tokenGen(
|
|
468
|
+
Object.assign(tokenConfig, { scope: ['temporal'] }),
|
|
469
|
+
TEMPORAL_TOKEN_TIMEOUT
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
// set the start time in the queue
|
|
473
|
+
Object.assign(config, { token });
|
|
474
|
+
// Store the config in redis
|
|
475
|
+
await executor.redisBreaker.runCommand(
|
|
476
|
+
'hset',
|
|
477
|
+
executor.buildConfigTable,
|
|
478
|
+
buildId,
|
|
479
|
+
JSON.stringify(config)
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
const blockedBySameJob = reach(config, 'annotations>screwdriver.cd/blockedBySameJob', {
|
|
483
|
+
separator: '>',
|
|
484
|
+
default: true
|
|
485
|
+
});
|
|
486
|
+
const blockedBySameJobWaitTime = reach(config, 'annotations>screwdriver.cd/blockedBySameJobWaitTime', {
|
|
487
|
+
separator: '>',
|
|
488
|
+
default: BLOCKED_BY_SAME_JOB_WAIT_TIME
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// Note: arguments to enqueue are [queue name, job name, array of args]
|
|
492
|
+
enq = await executor.queueBreaker.runCommand('enqueue', executor.buildQueue, 'start', [
|
|
493
|
+
{
|
|
494
|
+
buildId,
|
|
495
|
+
jobId,
|
|
496
|
+
blockedBy: blockedBy.toString(),
|
|
497
|
+
blockedBySameJob,
|
|
498
|
+
blockedBySameJobWaitTime
|
|
499
|
+
}
|
|
500
|
+
]);
|
|
501
|
+
} catch (err) {
|
|
502
|
+
logger.error(`Redis enqueue failed for build ${buildId}: ${err}`);
|
|
503
|
+
|
|
504
|
+
throw err;
|
|
505
|
+
}
|
|
485
506
|
}
|
|
486
507
|
}
|
|
487
508
|
|