gitlab-runner-tart-driver 0.3.7__py3-none-any.whl → 0.3.9__py3-none-any.whl
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.
- gitlab_runner_tart_driver/__init__.py +1 -1
- gitlab_runner_tart_driver/commands/prepare.py +90 -90
- gitlab_runner_tart_driver/commands/run.py +8 -2
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/METADATA +1 -1
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/RECORD +9 -9
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/LICENSE.txt +0 -0
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/WHEEL +0 -0
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/entry_points.txt +0 -0
- {gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.3.
|
1
|
+
__version__ = "0.3.9"
|
@@ -118,7 +118,10 @@ def prepare(
|
|
118
118
|
|
119
119
|
# retrieve the SYSTEM_FAILURE_EXIT_CODE from the environment
|
120
120
|
system_failure_exit_code = os.getenv("SYSTEM_FAILURE_EXIT_CODE", None)
|
121
|
-
if not
|
121
|
+
if system_failure_exit_code is not None:
|
122
|
+
# explicitly convert to int otherwise gitlab will not be able to react on it
|
123
|
+
system_failure_exit_code = int(system_failure_exit_code)
|
124
|
+
else:
|
122
125
|
click.secho("[WARNING] SYSTEM_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
|
123
126
|
system_failure_exit_code = 1
|
124
127
|
|
@@ -171,99 +174,96 @@ def prepare(
|
|
171
174
|
######################################################################
|
172
175
|
# Create VM
|
173
176
|
######################################################################
|
174
|
-
max_retries = 3
|
175
|
-
retry_count = 0
|
176
|
-
while True:
|
177
|
-
try:
|
178
|
-
tart_vm_name = p.vm_name()
|
179
|
-
if tart_vm_name in tart_vm_map:
|
180
|
-
if tart_vm_map[tart_vm_name].running:
|
181
|
-
click.echo(f"[INFO] Found running VM '{tart_vm_name}'. Going to stop it...")
|
182
|
-
tart.stop(tart_vm_name)
|
183
|
-
click.echo(f"[INFO] Found VM '{tart_vm_name}'. Going to delete it...")
|
184
|
-
tart.delete(tart_vm_name)
|
185
|
-
|
186
|
-
# verfiy that the limit of running VMs is not exceeded
|
187
|
-
list_running_vms = []
|
188
|
-
for vm in tart.list():
|
189
|
-
if vm.running:
|
190
|
-
list_running_vms.append(vm)
|
191
|
-
|
192
|
-
if len(list_running_vms) > p.tart_max_vm_count:
|
193
|
-
click.secho(
|
194
|
-
f"[ERROR] The limit of running VMs [{p.tart_max_vm_count}] is exceeded [{len(list_running_vms)}].",
|
195
|
-
fg="red",
|
196
|
-
)
|
197
|
-
sys.exit(system_failure_exit_code)
|
198
177
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
178
|
+
tart_vm_name = p.vm_name()
|
179
|
+
if tart_vm_name in tart_vm_map:
|
180
|
+
if tart_vm_map[tart_vm_name].running:
|
181
|
+
click.echo(f"[INFO] Found running VM '{tart_vm_name}'. Going to stop it...")
|
182
|
+
tart.stop(tart_vm_name)
|
183
|
+
click.echo(f"[INFO] Found VM '{tart_vm_name}'. Going to delete it...")
|
184
|
+
tart.delete(tart_vm_name)
|
185
|
+
|
186
|
+
# verfiy that the limit of running VMs is not exceeded
|
187
|
+
list_running_vms = []
|
188
|
+
for vm in tart.list():
|
189
|
+
if vm.running:
|
190
|
+
list_running_vms.append(vm)
|
191
|
+
|
192
|
+
if len(list_running_vms) > p.tart_max_vm_count:
|
193
|
+
click.secho(
|
194
|
+
f"[ERROR] The limit of running VMs [{p.tart_max_vm_count}] is exceeded [{len(list_running_vms)}].",
|
195
|
+
fg="red",
|
196
|
+
)
|
197
|
+
sys.exit(system_failure_exit_code)
|
205
198
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
elif auto_resources:
|
213
|
-
click.echo("[INFO] Auto resource-disribution enabled.")
|
214
|
-
host_spec = get_host_spec()
|
215
|
-
tart.set(
|
216
|
-
tart_vm_name, cpu=int(host_spec.cpu_count / concurrency), memory=int(host_spec.memory / concurrency)
|
217
|
-
)
|
199
|
+
click.echo(f"[INFO] Cloning VM instance '{tart_vm_name}' from '{p.ci_job_image}'")
|
200
|
+
try:
|
201
|
+
tart.clone(p.ci_job_image, tart_vm_name)
|
202
|
+
except:
|
203
|
+
click.secho(f"[ERROR] failed to clone image f'{p.ci_job_image}'", fg="red")
|
204
|
+
sys.exit(system_failure_exit_code)
|
218
205
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
retry_count += 1
|
256
|
-
click.secho(
|
257
|
-
"[WARNING] VM Coult not be started. Retrying...",
|
258
|
-
fg="yellow",
|
259
|
-
)
|
260
|
-
else:
|
261
|
-
click.secho(f"[ERROR] VM '{tart_vm_name}' could not be started.")
|
262
|
-
sys.exit(system_failure_exit_code)
|
206
|
+
if cpu or memory or p.display:
|
207
|
+
click.echo(f"[INFO] Configuring instance '{tart_vm_name}' from '{p.ci_job_image}'")
|
208
|
+
click.echo(
|
209
|
+
f"[INFO] {tart_vm_name} [cpu={cpu if cpu else 'default'}, memory={memory if memory else 'default'}, display={p.display if p.display else 'default'}]"
|
210
|
+
)
|
211
|
+
tart.set(tart_vm_name, cpu=cpu, memory=memory, display=display)
|
212
|
+
elif auto_resources:
|
213
|
+
click.echo("[INFO] Auto resource-disribution enabled.")
|
214
|
+
host_spec = get_host_spec()
|
215
|
+
tart.set(tart_vm_name, cpu=int(host_spec.cpu_count / concurrency), memory=int(host_spec.memory / concurrency))
|
216
|
+
|
217
|
+
click.echo(f"[INFO] Starting VM instance '{tart_vm_name}'")
|
218
|
+
|
219
|
+
remote_build_dir = "/opt/builds"
|
220
|
+
remote_script_dir = "/opt/temp"
|
221
|
+
remote_cache_dir = "/opt/cache"
|
222
|
+
|
223
|
+
volume_mounts = []
|
224
|
+
if cache_dir:
|
225
|
+
cache_dir = os.path.abspath(os.path.expanduser(cache_dir))
|
226
|
+
os.makedirs(cache_dir, exist_ok=True)
|
227
|
+
click.echo(f"[INFO] Cache directory set to '{cache_dir}'")
|
228
|
+
volume_mounts.append(TartVolume(source=cache_dir, dest=remote_cache_dir, name="cache", ro=False))
|
229
|
+
if builds_dir:
|
230
|
+
# Concurrency compatible builds directory
|
231
|
+
# see https://docs.gitlab.com/runner/executors/shell.html#run-scripts-as-a-privileged-user
|
232
|
+
# <builds_dir>/<short-token>/<concurrent-id>/<namespace>/<project-name>.
|
233
|
+
builds_dir = os.path.join(
|
234
|
+
os.path.abspath(os.path.expanduser(builds_dir)), p.ci_runner_short_token, p.ci_concurrent_project_id
|
235
|
+
)
|
236
|
+
os.makedirs(builds_dir, exist_ok=True)
|
237
|
+
click.echo(f"[INFO] Builds directory set to '{builds_dir}'")
|
238
|
+
volume_mounts.append(TartVolume(source=builds_dir, dest=remote_build_dir, name="builds", ro=False))
|
239
|
+
|
240
|
+
for v in volumes:
|
241
|
+
volume_mounts.append(TartVolume.from_string(v))
|
263
242
|
|
264
|
-
|
265
|
-
|
266
|
-
|
243
|
+
try:
|
244
|
+
_create_vm(
|
245
|
+
tart_client=tart,
|
246
|
+
vm_name=tart_vm_name,
|
247
|
+
volume_mounts=volume_mounts,
|
248
|
+
params=p,
|
249
|
+
)
|
250
|
+
except:
|
251
|
+
click.secho(f"[ERROR] Failed to create VM '{tart_vm_name}'", fg="red")
|
252
|
+
sys.exit(system_failure_exit_code)
|
253
|
+
|
254
|
+
try:
|
255
|
+
_get_vm_ip(tart_client=tart, vm_name=tart_vm_name, params=p)
|
256
|
+
except:
|
257
|
+
click.secho(f"[ERROR] Failed to get IP of VM '{tart_vm_name}'", fg="red")
|
258
|
+
sys.exit(system_failure_exit_code)
|
259
|
+
|
260
|
+
try:
|
261
|
+
ssh_session = _create_ssh_session(
|
262
|
+
tart_client=tart, vm_name=tart_vm_name, params=p, system_failure_exit_code=system_failure_exit_code
|
263
|
+
)
|
264
|
+
except:
|
265
|
+
click.secho(f"[ERROR] Failed to establish a ssh connection with VM '{tart_vm_name}'", fg="red")
|
266
|
+
sys.exit(system_failure_exit_code)
|
267
267
|
|
268
268
|
try:
|
269
269
|
ssh_session.exec_ssh_command(
|
@@ -34,13 +34,19 @@ def run(ssh_timeout, tart_executable, shell, script, stage):
|
|
34
34
|
|
35
35
|
# retrieve the BUILD_FAILURE_EXIT_CODE from the environment
|
36
36
|
build_failure_exit_code = os.getenv("BUILD_FAILURE_EXIT_CODE", None)
|
37
|
-
if not
|
37
|
+
if build_failure_exit_code is not None:
|
38
|
+
# explicitly convert to int otherwise gitlab will not be able to react on it
|
39
|
+
build_failure_exit_code = int(build_failure_exit_code)
|
40
|
+
else:
|
38
41
|
click.secho("[WARNING] BUILD_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
|
39
42
|
build_failure_exit_code = 1
|
40
43
|
|
41
44
|
# retrieve the SYSTEM_FAILURE_EXIT_CODE from the environment
|
42
45
|
system_failure_exit_code = os.getenv("SYSTEM_FAILURE_EXIT_CODE", None)
|
43
|
-
if not
|
46
|
+
if system_failure_exit_code is not None:
|
47
|
+
# explicitly convert to int otherwise gitlab will not be able to react on it
|
48
|
+
system_failure_exit_code = int(system_failure_exit_code)
|
49
|
+
else:
|
44
50
|
click.secho("[WARNING] SYSTEM_FAILURE_EXIT_CODE not set, defaulting to '1'", fg="red")
|
45
51
|
system_failure_exit_code = 1
|
46
52
|
|
{gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/RECORD
RENAMED
@@ -1,20 +1,20 @@
|
|
1
|
-
gitlab_runner_tart_driver/__init__.py,sha256=
|
1
|
+
gitlab_runner_tart_driver/__init__.py,sha256=xmkmdvq15kb61xdtCoa1YARnvHBnUgI-0GWIJYvHNeA,22
|
2
2
|
gitlab_runner_tart_driver/__main__.py,sha256=FiyMv64vDC-R8i3CGEP9QP48djZFHm7utyChwZJWCeY,107
|
3
3
|
gitlab_runner_tart_driver/cli.py,sha256=rCtFzi7i4JUX7VXteBHyII4sEbMzpn8SIpyjyKrQCBI,592
|
4
4
|
gitlab_runner_tart_driver/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
gitlab_runner_tart_driver/commands/cleanup.py,sha256=nFe7TGdxsVSXNR9onm-3iCjmUo6SzujV5LrA_y439fs,1422
|
6
6
|
gitlab_runner_tart_driver/commands/config.py,sha256=cacJ9ms5r3nZGZ_sS2d21Uoz7S-bMjB__lORUmeXZ-4,760
|
7
|
-
gitlab_runner_tart_driver/commands/prepare.py,sha256=
|
8
|
-
gitlab_runner_tart_driver/commands/run.py,sha256=
|
7
|
+
gitlab_runner_tart_driver/commands/prepare.py,sha256=zdIgDPJDHB263tJaD9dcgx9NB-roTa-5w89G1N-F0tI,14336
|
8
|
+
gitlab_runner_tart_driver/commands/run.py,sha256=uGcCXbd1QQIsLh1uPlaQHARCIOye5VvGxZswNG95tVI,3399
|
9
9
|
gitlab_runner_tart_driver/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
gitlab_runner_tart_driver/modules/gitlab_custom_command_config.py,sha256=XvE83QmQUcqtVMYZY3okGOgO86DBX6Y7xhXNenmKxFY,3086
|
11
11
|
gitlab_runner_tart_driver/modules/gitlab_custom_driver_config.py,sha256=ujxlzP1ZbfsZyLIsghID5c_jLPSt-1pDazE2B5CPORY,447
|
12
12
|
gitlab_runner_tart_driver/modules/tart.py,sha256=rD6IPtpz57dwsPGVBWaeKeVoqI1MoBvdtkqozXgmAxA,9914
|
13
13
|
gitlab_runner_tart_driver/modules/utils.py,sha256=7ipKjy_5tC5iW67Na_A9XhF4o2lKcAqO8LRTTSJKNd0,923
|
14
14
|
gitlab_runner_tart_driver/scripts/install-gitlab-runner.sh.j2,sha256=-rBzxZ92w7lMrTCVcjMHhlZgqPIK1RJKVoOc2wjZvck,2533
|
15
|
-
gitlab_runner_tart_driver-0.3.
|
16
|
-
gitlab_runner_tart_driver-0.3.
|
17
|
-
gitlab_runner_tart_driver-0.3.
|
18
|
-
gitlab_runner_tart_driver-0.3.
|
19
|
-
gitlab_runner_tart_driver-0.3.
|
20
|
-
gitlab_runner_tart_driver-0.3.
|
15
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/LICENSE.txt,sha256=TiYXQpEfbzcPBNGb7k1NslUngq_un-5cxGyT4W1S_f4,3303
|
16
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/METADATA,sha256=j7fR-jjPv28zfX3Nr_Qb1l5fwku-FIea6mzN92vhwa4,20705
|
17
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
18
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/entry_points.txt,sha256=xmvpGQf1wvFPy5wqDWXu8k5FD_k9KkCNCkpuworTsr0,82
|
19
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/top_level.txt,sha256=JjRzCs2sr24xG4SV_5tIBPpNC1Tec7I4AbK4IKMDqOc,26
|
20
|
+
gitlab_runner_tart_driver-0.3.9.dist-info/RECORD,,
|
{gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/LICENSE.txt
RENAMED
File without changes
|
{gitlab_runner_tart_driver-0.3.7.dist-info → gitlab_runner_tart_driver-0.3.9.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|