Skip to content

Commit c29fa84

Browse files
committed
Optionally set COMMODORE_CATALOG_COMPILE_PROCESSES based on cluster's CPU limit
Users can opt-in to setting each CI job's environment variable `COMMODORE_CATALOG_COMPILE_PROCESSES` based on the cluster's CPU limit by setting the environment variable `COMMODORE_PROCESSES_FROM_CPU_LIMIT` to a non-empty value in their GitLab CI config. For CI configurations that opt-in to this feature, we compute the Commodore process count based on the cluster's CPU limit by rounding down to the next nearest integer, clamped at 1. Currently, the CPU limit parser supports unsuffixed CPU limits and milli-CPU CPU limits and will raise an error for other CPU limit configurations. For CI configurations that don't opt-in to this feature, `COMMODORE_CATALOG_COMPILE_PROCESSES` is set to `0` which allows Commodore to auto-detect the number of worker processes to use, preserving the Commodore v1.33.1 and older behavior. diff --git a/gitlab/bin/step-render-pipeline b/gitlab/bin/step-render-pipeline index 23b40f1..1572c1e 100755 --- a/gitlab/bin/step-render-pipeline +++ b/gitlab/bin/step-render-pipeline @@ -20,5 +20,6 @@ jsonnet \ --ext-str cluster_catalog_urls="${cluster_catalog_urls}" \ --ext-str server_fqdn="${CI_SERVER_FQDN}" \ --ext-str server_ssh_host="${CI_SERVER_SHELL_SSH_HOST}" \ + --ext-str commodore_proc_count="${COMMODORE_PROCESSES_FROM_CPU_LIMIT:-}" \ /opt/commodore-compile.jsonnet \ >generated-commodore-compile.yml diff --git a/gitlab/commodore-compile.jsonnet b/gitlab/commodore-compile.jsonnet index edb7c9b..76a49fd 100644 --- a/gitlab/commodore-compile.jsonnet +++ b/gitlab/commodore-compile.jsonnet @@ -103,6 +103,35 @@ local gitInsteadOf(cluster) = 'git config --add --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@%(gitlab_fqdn)s".insteadOf ssh://git@%(ssh_hostport)s' % gitlab_params, ] + catalogInsteadOf; +local cpu_limit(cluster) = std.get(cpu_limits, cluster, '2'); + +// Compute Commodore process count based on CPU limit for the cluster by +// rounding down to the next nearest integer, clamped at 1. +local proc_count(cluster) = + local parseK8sCPU(cl) = + local val = if std.endsWith(cl, 'm') then + { + isMilli: true, + num: cl[:-1], + } + else { + isMilli: false, + num: cl, + }; + local clnum = std.parseYaml(val.num); + if std.isString(clnum) then + error 'Failed to parse K8s CPU limit %s: the parser currently only supports unsuffixed values and milli-CPU values' % cl + else + if val.isMilli then clnum / 1000 else clnum; + if std.extVar('commodore_proc_count') != '' then ( + local cl = parseK8sCPU(cpu_limit(cluster)); + if cl >= 1 then std.floor(cl) else 1 + ) else + // Commodore auto-selects the number of worker processes when the value of + // the flag/envvar is 0. This matches the behavior of Commodore v1.33.1 + // and older. + 0; + local compile_job(cluster) = { stage: 'build', @@ -114,8 +143,9 @@ local compile_job(cluster) = { KUBERNETES_MEMORY_LIMIT: std.get(memory_limits, cluster, '3Gi'), KUBERNETES_MEMORY_REQUEST: std.get(memory_requests, cluster, '3Gi'), - KUBERNETES_CPU_LIMIT: std.get(cpu_limits, cluster, '2'), + KUBERNETES_CPU_LIMIT: cpu_limit(cluster), KUBERNETES_CPU_REQUEST: std.get(cpu_requests, cluster, '800m'), + COMMODORE_CATALOG_COMPILE_PROCESSES: proc_count(cluster), }, before_script: [ @@ -149,8 +179,9 @@ local deploy_job(cluster) = { KUBERNETES_MEMORY_LIMIT: std.get(memory_limits, cluster, '3Gi'), KUBERNETES_MEMORY_REQUEST: std.get(memory_requests, cluster, '3Gi'), - KUBERNETES_CPU_LIMIT: std.get(cpu_limits, cluster, '2'), + KUBERNETES_CPU_LIMIT: cpu_limit(cluster), KUBERNETES_CPU_REQUEST: std.get(cpu_requests, cluster, '800m'), + COMMODORE_CATALOG_COMPILE_PROCESSES: proc_count(cluster), }, image: { diff --git a/gitlab/tests/golden/custom-ssh-port.yml b/gitlab/tests/golden/custom-ssh-port.yml index f29a0a9..fd98c3c 100644 --- a/gitlab/tests/golden/custom-ssh-port.yml +++ b/gitlab/tests/golden/custom-ssh-port.yml @@ -29,6 +29,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -58,6 +59,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", diff --git a/gitlab/tests/golden/default.yml b/gitlab/tests/golden/default.yml index f29a0a9..fd98c3c 100644 --- a/gitlab/tests/golden/default.yml +++ b/gitlab/tests/golden/default.yml @@ -29,6 +29,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -58,6 +59,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", diff --git a/gitlab/tests/golden/external-catalog.yml b/gitlab/tests/golden/external-catalog.yml index b5c82c8..f7436e9 100644 --- a/gitlab/tests/golden/external-catalog.yml +++ b/gitlab/tests/golden/external-catalog.yml @@ -29,6 +29,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -58,6 +59,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -94,6 +96,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -123,6 +126,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -157,6 +161,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -184,6 +189,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 0, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", diff --git a/gitlab/tests/golden/k8s-resources.yml b/gitlab/tests/golden/k8s-resources.yml index 15fe5c3..0566c3e 100644 --- a/gitlab/tests/golden/k8s-resources.yml +++ b/gitlab/tests/golden/k8s-resources.yml @@ -29,6 +29,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 2, "KUBERNETES_CPU_LIMIT": "2500m", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -58,12 +59,80 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 2, "KUBERNETES_CPU_LIMIT": "2500m", "KUBERNETES_CPU_REQUEST": "800m", "KUBERNETES_MEMORY_LIMIT": "3Gi", "KUBERNETES_MEMORY_REQUEST": "3Gi" } }, + "c-cluster-id-1000_compile": { + "artifacts": { + "expire_in": "1 week", + "paths": [ + "diff.txt" + ] + }, + "before_script": [ + "install --directory --mode=0700 ~/.ssh", + "echo \"$SSH_KNOWN_HOSTS\" >> ~/.ssh/known_hosts", + "echo \"$SSH_CONFIG\" >> ~/.ssh/config" + ], + "image": { + "name": "docker.io/projectsyn/commodore:v1.34.0" + }, + "rules": [ + { + "if": "$CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH" + } + ], + "script": [ + "git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}", + "git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}", + "git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}/cluster-catalogs/c-cluster-id-1000.git", + "git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}/cluster-catalogs/c-cluster-id-1000.git", + "/usr/local/bin/entrypoint.sh commodore catalog compile --tenant-repo-revision-override $CI_COMMIT_SHA c-cluster-id-1000", + "(cd catalog/ && git --no-pager diff --staged --output ../diff.txt)" + ], + "stage": "build", + "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 1, + "KUBERNETES_CPU_LIMIT": "800m", + "KUBERNETES_CPU_REQUEST": "800m", + "KUBERNETES_MEMORY_LIMIT": "3Gi", + "KUBERNETES_MEMORY_REQUEST": "3Gi" + } + }, + "c-cluster-id-1000_deploy": { + "before_script": [ + "install --directory --mode=0700 ~/.ssh", + "echo \"$SSH_KNOWN_HOSTS\" >> ~/.ssh/known_hosts", + "echo \"$SSH_CONFIG\" >> ~/.ssh/config" + ], + "image": { + "name": "docker.io/projectsyn/commodore:v1.34.0" + }, + "rules": [ + { + "if": "$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH" + } + ], + "script": [ + "git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}", + "git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}", + "git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}/cluster-catalogs/c-cluster-id-1000.git", + "git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}/cluster-catalogs/c-cluster-id-1000.git", + "/usr/local/bin/entrypoint.sh commodore catalog compile --push c-cluster-id-1000" + ], + "stage": "deploy", + "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 1, + "KUBERNETES_CPU_LIMIT": "800m", + "KUBERNETES_CPU_REQUEST": "800m", + "KUBERNETES_MEMORY_LIMIT": "3Gi", + "KUBERNETES_MEMORY_REQUEST": "3Gi" + } + }, "c-cluster-id-1234_compile": { "artifacts": { "expire_in": "1 week", @@ -94,7 +163,8 @@ ], "stage": "build", "variables": { - "KUBERNETES_CPU_LIMIT": "2", + "COMMODORE_CATALOG_COMPILE_PROCESSES": 1, + "KUBERNETES_CPU_LIMIT": "1.6", "KUBERNETES_CPU_REQUEST": "1200m", "KUBERNETES_MEMORY_LIMIT": "3Gi", "KUBERNETES_MEMORY_REQUEST": "2Gi" @@ -123,7 +193,8 @@ ], "stage": "deploy", "variables": { - "KUBERNETES_CPU_LIMIT": "2", + "COMMODORE_CATALOG_COMPILE_PROCESSES": 1, + "KUBERNETES_CPU_LIMIT": "1.6", "KUBERNETES_CPU_REQUEST": "1200m", "KUBERNETES_MEMORY_LIMIT": "3Gi", "KUBERNETES_MEMORY_REQUEST": "2Gi" @@ -159,6 +230,7 @@ ], "stage": "build", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 2, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "2", "KUBERNETES_MEMORY_LIMIT": "3Gi", @@ -188,6 +260,7 @@ ], "stage": "deploy", "variables": { + "COMMODORE_CATALOG_COMPILE_PROCESSES": 2, "KUBERNETES_CPU_LIMIT": "2", "KUBERNETES_CPU_REQUEST": "2", "KUBERNETES_MEMORY_LIMIT": "3Gi", diff --git a/gitlab/tests/k8s-resources.env b/gitlab/tests/k8s-resources.env index 6cb7afb..d0cc5c4 100644 --- a/gitlab/tests/k8s-resources.env +++ b/gitlab/tests/k8s-resources.env @@ -1,6 +1,7 @@ -CLUSTERS="c-cluster-id-1234 c-cluster-id-5678 c-cluster-id-0099" -CLUSTER_CATALOG_URLS="c-cluster-id-1234=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1234.git c-cluster-id-5678=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-5678.git c-cluster-id-0099=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-0099.git " +CLUSTERS="c-cluster-id-1234 c-cluster-id-5678 c-cluster-id-0099 c-cluster-id-1000" +CLUSTER_CATALOG_URLS="c-cluster-id-1234=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1234.git c-cluster-id-5678=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-5678.git c-cluster-id-0099=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-0099.git c-cluster-id-1000=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1000.git " MEMORY_LIMITS="c-cluster-id-1234=3Gi" MEMORY_REQUESTS="c-cluster-id-1234=2Gi" CPU_REQUESTS="c-cluster-id-1234=1200m c-cluster-id-5678=2" -CPU_LIMITS="c-cluster-id-0099=2500m" +CPU_LIMITS="c-cluster-id-1234=1.6 c-cluster-id-0099=2500m c-cluster-id-1000=800m" +COMMODORE_PROCESSES_FROM_CPU_LIMIT="true" diff --git a/gitlab/tests/run-instance.sh b/gitlab/tests/run-instance.sh index eaff60f..5176461 100755 --- a/gitlab/tests/run-instance.sh +++ b/gitlab/tests/run-instance.sh @@ -16,4 +16,5 @@ jsonnet --ext-str clusters="$CLUSTERS" \ --ext-str memory_requests="${MEMORY_REQUESTS:-}" \ --ext-str cpu_limits="${CPU_LIMITS:-}" \ --ext-str cpu_requests="${CPU_REQUESTS:-}" \ + --ext-str commodore_proc_count="${COMMODORE_PROCESSES_FROM_CPU_LIMIT:-}" \ commodore-compile.jsonnet
1 parent 1216264 commit c29fa84

8 files changed

Lines changed: 124 additions & 7 deletions

File tree

gitlab/bin/step-render-pipeline

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ jsonnet \
2020
--ext-str cluster_catalog_urls="${cluster_catalog_urls}" \
2121
--ext-str server_fqdn="${CI_SERVER_FQDN}" \
2222
--ext-str server_ssh_host="${CI_SERVER_SHELL_SSH_HOST}" \
23+
--ext-str commodore_proc_count="${COMMODORE_PROCESSES_FROM_CPU_LIMIT:-}" \
2324
/opt/commodore-compile.jsonnet \
2425
>generated-commodore-compile.yml

gitlab/commodore-compile.jsonnet

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,35 @@ local gitInsteadOf(cluster) =
103103
'git config --add --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@%(gitlab_fqdn)s".insteadOf ssh://git@%(ssh_hostport)s' % gitlab_params,
104104
] + catalogInsteadOf;
105105

106+
local cpu_limit(cluster) = std.get(cpu_limits, cluster, '2');
107+
108+
// Compute Commodore process count based on CPU limit for the cluster by
109+
// rounding down to the next nearest integer, clamped at 1.
110+
local proc_count(cluster) =
111+
local parseK8sCPU(cl) =
112+
local val = if std.endsWith(cl, 'm') then
113+
{
114+
isMilli: true,
115+
num: cl[:-1],
116+
}
117+
else {
118+
isMilli: false,
119+
num: cl,
120+
};
121+
local clnum = std.parseYaml(val.num);
122+
if std.isString(clnum) then
123+
error 'Failed to parse K8s CPU limit %s: the parser currently only supports unsuffixed values and milli-CPU values' % cl
124+
else
125+
if val.isMilli then clnum / 1000 else clnum;
126+
if std.extVar('commodore_proc_count') != '' then (
127+
local cl = parseK8sCPU(cpu_limit(cluster));
128+
if cl >= 1 then std.floor(cl) else 1
129+
) else
130+
// Commodore auto-selects the number of worker processes when the value of
131+
// the flag/envvar is 0. This matches the behavior of Commodore v1.33.1
132+
// and older.
133+
0;
134+
106135
local compile_job(cluster) =
107136
{
108137
stage: 'build',
@@ -114,8 +143,9 @@ local compile_job(cluster) =
114143
{
115144
KUBERNETES_MEMORY_LIMIT: std.get(memory_limits, cluster, '3Gi'),
116145
KUBERNETES_MEMORY_REQUEST: std.get(memory_requests, cluster, '3Gi'),
117-
KUBERNETES_CPU_LIMIT: std.get(cpu_limits, cluster, '2'),
146+
KUBERNETES_CPU_LIMIT: cpu_limit(cluster),
118147
KUBERNETES_CPU_REQUEST: std.get(cpu_requests, cluster, '800m'),
148+
COMMODORE_CATALOG_COMPILE_PROCESSES: proc_count(cluster),
119149
},
120150
before_script:
121151
[
@@ -149,8 +179,9 @@ local deploy_job(cluster) =
149179
{
150180
KUBERNETES_MEMORY_LIMIT: std.get(memory_limits, cluster, '3Gi'),
151181
KUBERNETES_MEMORY_REQUEST: std.get(memory_requests, cluster, '3Gi'),
152-
KUBERNETES_CPU_LIMIT: std.get(cpu_limits, cluster, '2'),
182+
KUBERNETES_CPU_LIMIT: cpu_limit(cluster),
153183
KUBERNETES_CPU_REQUEST: std.get(cpu_requests, cluster, '800m'),
184+
COMMODORE_CATALOG_COMPILE_PROCESSES: proc_count(cluster),
154185
},
155186
image:
156187
{

gitlab/tests/golden/custom-ssh-port.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"stage": "build",
3131
"variables": {
32+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
3233
"KUBERNETES_CPU_LIMIT": "2",
3334
"KUBERNETES_CPU_REQUEST": "800m",
3435
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -58,6 +59,7 @@
5859
],
5960
"stage": "deploy",
6061
"variables": {
62+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
6163
"KUBERNETES_CPU_LIMIT": "2",
6264
"KUBERNETES_CPU_REQUEST": "800m",
6365
"KUBERNETES_MEMORY_LIMIT": "3Gi",

gitlab/tests/golden/default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"stage": "build",
3131
"variables": {
32+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
3233
"KUBERNETES_CPU_LIMIT": "2",
3334
"KUBERNETES_CPU_REQUEST": "800m",
3435
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -58,6 +59,7 @@
5859
],
5960
"stage": "deploy",
6061
"variables": {
62+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
6163
"KUBERNETES_CPU_LIMIT": "2",
6264
"KUBERNETES_CPU_REQUEST": "800m",
6365
"KUBERNETES_MEMORY_LIMIT": "3Gi",

gitlab/tests/golden/external-catalog.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"stage": "build",
3131
"variables": {
32+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
3233
"KUBERNETES_CPU_LIMIT": "2",
3334
"KUBERNETES_CPU_REQUEST": "800m",
3435
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -58,6 +59,7 @@
5859
],
5960
"stage": "deploy",
6061
"variables": {
62+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
6163
"KUBERNETES_CPU_LIMIT": "2",
6264
"KUBERNETES_CPU_REQUEST": "800m",
6365
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -94,6 +96,7 @@
9496
],
9597
"stage": "build",
9698
"variables": {
99+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
97100
"KUBERNETES_CPU_LIMIT": "2",
98101
"KUBERNETES_CPU_REQUEST": "800m",
99102
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -123,6 +126,7 @@
123126
],
124127
"stage": "deploy",
125128
"variables": {
129+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
126130
"KUBERNETES_CPU_LIMIT": "2",
127131
"KUBERNETES_CPU_REQUEST": "800m",
128132
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -157,6 +161,7 @@
157161
],
158162
"stage": "build",
159163
"variables": {
164+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
160165
"KUBERNETES_CPU_LIMIT": "2",
161166
"KUBERNETES_CPU_REQUEST": "800m",
162167
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -184,6 +189,7 @@
184189
],
185190
"stage": "deploy",
186191
"variables": {
192+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 0,
187193
"KUBERNETES_CPU_LIMIT": "2",
188194
"KUBERNETES_CPU_REQUEST": "800m",
189195
"KUBERNETES_MEMORY_LIMIT": "3Gi",

gitlab/tests/golden/k8s-resources.yml

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"stage": "build",
3131
"variables": {
32+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 2,
3233
"KUBERNETES_CPU_LIMIT": "2500m",
3334
"KUBERNETES_CPU_REQUEST": "800m",
3435
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -58,12 +59,80 @@
5859
],
5960
"stage": "deploy",
6061
"variables": {
62+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 2,
6163
"KUBERNETES_CPU_LIMIT": "2500m",
6264
"KUBERNETES_CPU_REQUEST": "800m",
6365
"KUBERNETES_MEMORY_LIMIT": "3Gi",
6466
"KUBERNETES_MEMORY_REQUEST": "3Gi"
6567
}
6668
},
69+
"c-cluster-id-1000_compile": {
70+
"artifacts": {
71+
"expire_in": "1 week",
72+
"paths": [
73+
"diff.txt"
74+
]
75+
},
76+
"before_script": [
77+
"install --directory --mode=0700 ~/.ssh",
78+
"echo \"$SSH_KNOWN_HOSTS\" >> ~/.ssh/known_hosts",
79+
"echo \"$SSH_CONFIG\" >> ~/.ssh/config"
80+
],
81+
"image": {
82+
"name": "docker.io/projectsyn/commodore:v1.34.0"
83+
},
84+
"rules": [
85+
{
86+
"if": "$CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH"
87+
}
88+
],
89+
"script": [
90+
"git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}",
91+
"git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}",
92+
"git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}/cluster-catalogs/c-cluster-id-1000.git",
93+
"git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}/cluster-catalogs/c-cluster-id-1000.git",
94+
"/usr/local/bin/entrypoint.sh commodore catalog compile --tenant-repo-revision-override $CI_COMMIT_SHA c-cluster-id-1000",
95+
"(cd catalog/ && git --no-pager diff --staged --output ../diff.txt)"
96+
],
97+
"stage": "build",
98+
"variables": {
99+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 1,
100+
"KUBERNETES_CPU_LIMIT": "800m",
101+
"KUBERNETES_CPU_REQUEST": "800m",
102+
"KUBERNETES_MEMORY_LIMIT": "3Gi",
103+
"KUBERNETES_MEMORY_REQUEST": "3Gi"
104+
}
105+
},
106+
"c-cluster-id-1000_deploy": {
107+
"before_script": [
108+
"install --directory --mode=0700 ~/.ssh",
109+
"echo \"$SSH_KNOWN_HOSTS\" >> ~/.ssh/known_hosts",
110+
"echo \"$SSH_CONFIG\" >> ~/.ssh/config"
111+
],
112+
"image": {
113+
"name": "docker.io/projectsyn/commodore:v1.34.0"
114+
},
115+
"rules": [
116+
{
117+
"if": "$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH"
118+
}
119+
],
120+
"script": [
121+
"git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}",
122+
"git config --add --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}",
123+
"git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}/cluster-catalogs/c-cluster-id-1000.git",
124+
"git config --add --global url.\"https://gitlab-ci-token:${ACCESS_TOKEN_c_cluster_id_1000}@git.vshn.net:80/cluster-catalogs/c-cluster-id-1000.git\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}${CI_SERVER_SHELL_SSH_PORT:+:${CI_SERVER_SHELL_SSH_PORT}}/cluster-catalogs/c-cluster-id-1000.git",
125+
"/usr/local/bin/entrypoint.sh commodore catalog compile --push c-cluster-id-1000"
126+
],
127+
"stage": "deploy",
128+
"variables": {
129+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 1,
130+
"KUBERNETES_CPU_LIMIT": "800m",
131+
"KUBERNETES_CPU_REQUEST": "800m",
132+
"KUBERNETES_MEMORY_LIMIT": "3Gi",
133+
"KUBERNETES_MEMORY_REQUEST": "3Gi"
134+
}
135+
},
67136
"c-cluster-id-1234_compile": {
68137
"artifacts": {
69138
"expire_in": "1 week",
@@ -94,7 +163,8 @@
94163
],
95164
"stage": "build",
96165
"variables": {
97-
"KUBERNETES_CPU_LIMIT": "2",
166+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 1,
167+
"KUBERNETES_CPU_LIMIT": "1.6",
98168
"KUBERNETES_CPU_REQUEST": "1200m",
99169
"KUBERNETES_MEMORY_LIMIT": "3Gi",
100170
"KUBERNETES_MEMORY_REQUEST": "2Gi"
@@ -123,7 +193,8 @@
123193
],
124194
"stage": "deploy",
125195
"variables": {
126-
"KUBERNETES_CPU_LIMIT": "2",
196+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 1,
197+
"KUBERNETES_CPU_LIMIT": "1.6",
127198
"KUBERNETES_CPU_REQUEST": "1200m",
128199
"KUBERNETES_MEMORY_LIMIT": "3Gi",
129200
"KUBERNETES_MEMORY_REQUEST": "2Gi"
@@ -159,6 +230,7 @@
159230
],
160231
"stage": "build",
161232
"variables": {
233+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 2,
162234
"KUBERNETES_CPU_LIMIT": "2",
163235
"KUBERNETES_CPU_REQUEST": "2",
164236
"KUBERNETES_MEMORY_LIMIT": "3Gi",
@@ -188,6 +260,7 @@
188260
],
189261
"stage": "deploy",
190262
"variables": {
263+
"COMMODORE_CATALOG_COMPILE_PROCESSES": 2,
191264
"KUBERNETES_CPU_LIMIT": "2",
192265
"KUBERNETES_CPU_REQUEST": "2",
193266
"KUBERNETES_MEMORY_LIMIT": "3Gi",

gitlab/tests/k8s-resources.env

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
CLUSTERS="c-cluster-id-1234 c-cluster-id-5678 c-cluster-id-0099"
2-
CLUSTER_CATALOG_URLS="c-cluster-id-1234=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1234.git c-cluster-id-5678=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-5678.git c-cluster-id-0099=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-0099.git "
1+
CLUSTERS="c-cluster-id-1234 c-cluster-id-5678 c-cluster-id-0099 c-cluster-id-1000"
2+
CLUSTER_CATALOG_URLS="c-cluster-id-1234=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1234.git c-cluster-id-5678=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-5678.git c-cluster-id-0099=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-0099.git c-cluster-id-1000=ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1000.git "
33
MEMORY_LIMITS="c-cluster-id-1234=3Gi"
44
MEMORY_REQUESTS="c-cluster-id-1234=2Gi"
55
CPU_REQUESTS="c-cluster-id-1234=1200m c-cluster-id-5678=2"
6-
CPU_LIMITS="c-cluster-id-0099=2500m"
6+
CPU_LIMITS="c-cluster-id-1234=1.6 c-cluster-id-0099=2500m c-cluster-id-1000=800m"
7+
COMMODORE_PROCESSES_FROM_CPU_LIMIT="true"

gitlab/tests/run-instance.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ jsonnet --ext-str clusters="$CLUSTERS" \
1616
--ext-str memory_requests="${MEMORY_REQUESTS:-}" \
1717
--ext-str cpu_limits="${CPU_LIMITS:-}" \
1818
--ext-str cpu_requests="${CPU_REQUESTS:-}" \
19+
--ext-str commodore_proc_count="${COMMODORE_PROCESSES_FROM_CPU_LIMIT:-}" \
1920
commodore-compile.jsonnet

0 commit comments

Comments
 (0)