Skip to content

Commit e482c1f

Browse files
authored
Merge pull request #992 from snyk/feat/configure-workers-compression
[RUN-2038] feat: allow configuring skopeo compression and image scan worker count
2 parents 1c29e6f + 3061ef9 commit e482c1f

File tree

8 files changed

+22
-6
lines changed

8 files changed

+22
-6
lines changed

config.default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"MAX_SIZE": 10000,
1212
"MAX_AGE_MS": 60000
1313
},
14-
"WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT": 10,
14+
"WORKERS_COUNT": 10,
1515
"REQUEST_QUEUE_LENGTH": 2,
1616
"QUEUE_LENGTH_LOG_FREQUENCY_MINUTES": 15,
1717
"INTEGRATION_ID": "",

snyk-monitor/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ spec:
128128
value: {{ .Values.log_level }}
129129
- name: SKIP_K8S_JOBS
130130
value: {{ quote .Values.skip_k8s_jobs }}
131+
- name: SNYK_SKOPEO_COMPRESSION_LEVEL
132+
value: {{ quote .Values.skopeo.compression.level }}
133+
- name: SNYK_WORKERS_COUNT
134+
value: {{ quote .Values.workers.count }}
131135
{{- with .Values.envs }}
132136
{{- toYaml . | trim | nindent 10 -}}
133137
{{- end }}

snyk-monitor/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,10 @@ tolerations: []
136136
volumes:
137137
projected:
138138
serviceAccountToken: false
139+
140+
skopeo:
141+
compression:
142+
level: 6
143+
144+
workers:
145+
count: 10

src/common/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ config.CLUSTER_NAME = getClusterName();
4242
config.IMAGE_STORAGE_ROOT = '/var/tmp';
4343
config.POLICIES_STORAGE_ROOT = '/tmp/policies';
4444
config.EXCLUDED_NAMESPACES = loadExcludedNamespaces();
45-
config.WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT =
46-
Number(config.WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT) || 10;
45+
config.WORKERS_COUNT = Number(config.WORKERS_COUNT) || 10;
46+
config.SKOPEO_COMPRESSION_LEVEL = Number(config.SKOPEO_COMPRESSION_LEVEL) || 6;
4747

4848
/**
4949
* Important: we delete the following env vars because we don't want to proxy requests to the Kubernetes API server.

src/scanner/images/skopeo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export async function pull(
4444

4545
const args: Array<processWrapper.IProcessArgument> = [];
4646
args.push({ body: 'copy', sanitise: false });
47+
args.push({ body: '--dest-compress-level', sanitise: false });
48+
args.push({ body: `${config.SKOPEO_COMPRESSION_LEVEL}`, sanitise: false });
4749
args.push(...credentialsParameters);
4850
args.push(...certificatesParameters);
4951
args.push({

src/supervisor/watchers/handlers/pod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function queueWorkerWorkloadScan(
6161

6262
const workloadsToScanQueue = async.queue<ImagesToScanQueueData>(
6363
queueWorkerWorkloadScan,
64-
config.WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT,
64+
config.WORKERS_COUNT,
6565
);
6666

6767
workloadsToScanQueue.error(function (err, task) {

test/common/config.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('extractNamespaceName()', () => {
7171
expect(config.HTTP_PROXY).toBeUndefined();
7272
expect(config.NO_PROXY).toBeUndefined();
7373
expect(config.SKIP_K8S_JOBS).toEqual(false);
74-
expect(config.WORKLOADS_TO_SCAN_QUEUE_WORKER_COUNT).toEqual(10);
74+
expect(config.WORKERS_COUNT).toEqual(10);
75+
expect(config.SKOPEO_COMPRESSION_LEVEL).toEqual(6);
7576
});
7677
});

test/setup/deployers/helm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ async function deployKubernetesMonitor(
3737
'--set log_level="INFO" ' +
3838
'--set rbac.serviceAccount.annotations."foo"="bar" ' +
3939
'--set volumes.projected.serviceAccountToken=true ' +
40-
'--set securityContext.fsGroup=65534 ',
40+
'--set securityContext.fsGroup=65534 ' +
41+
'--set skopeo.compression.level=1 ' +
42+
'--set workers.count=5 ',
4143
);
4244
console.log(
4345
`Deployed ${imageOptions.nameAndTag} with pull policy ${imageOptions.pullPolicy}`,

0 commit comments

Comments
 (0)