Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from screwdriver-cd/turbo
Browse files Browse the repository at this point in the history
fix: add turbo cpu/ram config
  • Loading branch information
minzcmu authored Sep 25, 2018
2 parents a1931a8 + 08b3ed5 commit 6d6a5dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ The class provides a couple options that are configurable in the instantiation o
| config.prefix | String | '' |Prefix to container names ("") |
| config.jobsNamespace | String | 'default' | Kubernetes namespace where builds are running on |
| config.baseImage | String | '' | Base image used to start the VM |
| config.kubernetes.resources.memory.turbo | Number | 16 | Value for TURBO memory (in GB) |
| config.kubernetes.resources.memory.high | Number | 12 | Value for HIGH memory (in GB) |
| config.kubernetes.resources.memory.low | Number | 2 | Value for LOW memory (in GB) |
| config.kubernetes.resources.memory.micro | Number | 1 | Value for MICRO memory (in GB) |
| config.kubernetes.resources.cpu.turbo | Number | 12 | Value for TURBO CPU (in cores) |
| config.kubernetes.resources.cpu.high | Number | 6 | Value for HIGH CPU (in cores) |
| config.kubernetes.resources.cpu.low | Number | 2 | Value for LOW CPU (in cores) |
| config.kubernetes.resources.cpu.micro | Number | 1 | Value for MICRO CPU (in cores) |
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ class K8sVMExecutor extends Executor {
* @param {String} [options.kubernetes.baseImage] Base image for the pod
* @param {Number} [options.kubernetes.buildTimeout=90] Number of minutes to allow a build to run before considering it is timed out
* @param {Number} [options.kubernetes.maxBuildTimeout=120] Max timeout user can configure up to (in minutes)
* @param {String} [options.kubernetes.resources.cpu.turbo=12] Value for TURBO CPU (in cores)
* @param {String} [options.kubernetes.resources.cpu.high=6] Value for HIGH CPU (in cores)
* @param {Number} [options.kubernetes.resources.cpu.low=2] Value for LOW CPU (in cores)
* @param {Number} [options.kubernetes.resources.cpu.micro=1] Value for MICRO CPU (in cores)
* @param {Number} [options.kubernetes.resources.memory.turbo=16]Value for TURBO memory (in GB)
* @param {Number} [options.kubernetes.resources.memory.high=12] Value for HIGH memory (in GB)
* @param {Number} [options.kubernetes.resources.memory.low=2] Value for LOW memory (in GB)
* @param {Number} [options.kubernetes.resources.memory.micro=1] Value for MICRO memory (in GB)
Expand Down Expand Up @@ -150,9 +152,12 @@ class K8sVMExecutor extends Executor {
this.maxBuildTimeout = this.kubernetes.maxBuildTimeout || MAX_BUILD_TIMEOUT;
this.podsUrl = `https://${this.host}/api/v1/namespaces/${this.jobsNamespace}/pods`;
this.breaker = new Fusebox(requestretry, options.fusebox);
this.turboCpu = hoek.reach(options, 'kubernetes.resources.cpu.turbo', { default: 12 });
this.highCpu = hoek.reach(options, 'kubernetes.resources.cpu.high', { default: 6 });
this.lowCpu = hoek.reach(options, 'kubernetes.resources.cpu.low', { default: 2 });
this.microCpu = hoek.reach(options, 'kubernetes.resources.cpu.micro', { default: 1 });
this.turboMemory = hoek.reach(options,
'kubernetes.resources.memory.turbo', { default: 16 });
this.highMemory = hoek.reach(options, 'kubernetes.resources.memory.high', { default: 12 });
this.lowMemory = hoek.reach(options, 'kubernetes.resources.memory.low', { default: 2 });
this.microMemory = hoek.reach(options, 'kubernetes.resources.memory.micro', { default: 1 });
Expand Down Expand Up @@ -208,13 +213,15 @@ class K8sVMExecutor extends Executor {
hoek.reach(config, 'annotations', { default: {} }));
const cpuConfig = annotations[CPU_RESOURCE];
const cpuValues = {
TURBO: this.turboCpu,
HIGH: this.highCpu,
LOW: this.lowCpu,
MICRO: this.microCpu
};
const CPU = (cpuConfig in cpuValues) ? cpuValues[cpuConfig] : cpuValues.LOW;

const memValues = {
TURBO: this.turboMemory,
HIGH: this.highMemory,
LOW: this.lowMemory,
MICRO: this.microMemory
Expand Down
4 changes: 4 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ describe('index', () => {
baseImage: 'hyperctl',
resources: {
cpu: {
turbo: 10,
high: 8,
low: 2,
micro: 1
},
memory: {
turbo: 20,
high: 5,
low: 2,
micro: 1
Expand All @@ -240,9 +242,11 @@ describe('index', () => {
assert.equal(executor.host, 'kubernetes2');
assert.equal(executor.launchVersion, 'v1.2.3');
assert.equal(executor.jobsNamespace, 'baz');
assert.equal(executor.turboCpu, 10);
assert.equal(executor.highCpu, 8);
assert.equal(executor.lowCpu, 2);
assert.equal(executor.microCpu, 1);
assert.equal(executor.turboMemory, 20);
assert.equal(executor.highMemory, 5);
assert.equal(executor.lowMemory, 2);
assert.equal(executor.microMemory, 1);
Expand Down

0 comments on commit 6d6a5dc

Please sign in to comment.