tft-cli 0.0.23__py3-none-any.whl → 0.0.24__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.
- tft/cli/commands.py +62 -6
- tft/cli/commands.py.backup +2211 -0
- {tft_cli-0.0.23.dist-info → tft_cli-0.0.24.dist-info}/METADATA +1 -1
- tft_cli-0.0.24.dist-info/RECORD +11 -0
- tft_cli-0.0.23.dist-info/RECORD +0 -10
- {tft_cli-0.0.23.dist-info → tft_cli-0.0.24.dist-info}/LICENSE +0 -0
- {tft_cli-0.0.23.dist-info → tft_cli-0.0.24.dist-info}/WHEEL +0 -0
- {tft_cli-0.0.23.dist-info → tft_cli-0.0.24.dist-info}/entry_points.txt +0 -0
tft/cli/commands.py
CHANGED
|
@@ -278,6 +278,14 @@ def _option_reservation_duration(panel: str) -> int:
|
|
|
278
278
|
)
|
|
279
279
|
|
|
280
280
|
|
|
281
|
+
def _option_debug_reservation(panel: Optional[str] = None) -> bool:
|
|
282
|
+
return typer.Option(
|
|
283
|
+
False,
|
|
284
|
+
help="Enable debug messages in the reservation code. Useful for testing changes to reservation code.",
|
|
285
|
+
rich_help_panel=panel,
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
|
|
281
289
|
def _generate_tmt_extra_args(step: str) -> Optional[List[str]]:
|
|
282
290
|
return typer.Option(
|
|
283
291
|
None,
|
|
@@ -395,7 +403,13 @@ def _localhost_ingress_rule(session: requests.Session) -> str:
|
|
|
395
403
|
exit_error(f"Got {get_ip.status_code} while checking {settings.PUBLIC_IP_CHECKER_URL}")
|
|
396
404
|
|
|
397
405
|
|
|
398
|
-
def _add_reservation(
|
|
406
|
+
def _add_reservation(
|
|
407
|
+
ssh_public_keys: List[str],
|
|
408
|
+
rules: Dict[str, Any],
|
|
409
|
+
duration: int,
|
|
410
|
+
environment: Dict[str, Any],
|
|
411
|
+
debug_reservation: bool,
|
|
412
|
+
):
|
|
399
413
|
"""
|
|
400
414
|
Add discovery of the reservation test to the given environment.
|
|
401
415
|
"""
|
|
@@ -423,6 +437,9 @@ def _add_reservation(ssh_public_keys: List[str], rules: Dict[str, Any], duration
|
|
|
423
437
|
|
|
424
438
|
environment["variables"].update({"TF_RESERVATION_DURATION": str(duration)})
|
|
425
439
|
|
|
440
|
+
if debug_reservation:
|
|
441
|
+
environment["variables"].update({"TF_RESERVATION_DEBUG": "1"})
|
|
442
|
+
|
|
426
443
|
if "tmt" not in environment or environment["tmt"] is None:
|
|
427
444
|
environment["tmt"] = {"extra_args": {}}
|
|
428
445
|
|
|
@@ -770,6 +787,10 @@ def watch(
|
|
|
770
787
|
_print_summary_table(request_summary, format)
|
|
771
788
|
raise typer.Exit(code=2)
|
|
772
789
|
|
|
790
|
+
elif state in ["canceled", "cancel-requested"]:
|
|
791
|
+
_console_print("⚠️ pipeline cancelled", style="yellow")
|
|
792
|
+
raise typer.Exit(code=3)
|
|
793
|
+
|
|
773
794
|
if no_wait:
|
|
774
795
|
_print_summary_table(request_summary, format, show_details=False)
|
|
775
796
|
raise typer.Exit()
|
|
@@ -877,6 +898,7 @@ def request(
|
|
|
877
898
|
ssh_public_keys: List[str] = _option_ssh_public_keys(REQUEST_PANEL_RESERVE),
|
|
878
899
|
autoconnect: bool = _option_autoconnect(REQUEST_PANEL_RESERVE),
|
|
879
900
|
reservation_duration: int = _option_reservation_duration(REQUEST_PANEL_RESERVE),
|
|
901
|
+
debug_reservation: bool = _option_debug_reservation(REQUEST_PANEL_RESERVE),
|
|
880
902
|
):
|
|
881
903
|
"""
|
|
882
904
|
Request testing from Testing Farm.
|
|
@@ -1066,7 +1088,11 @@ def request(
|
|
|
1066
1088
|
|
|
1067
1089
|
for environment in environments:
|
|
1068
1090
|
_add_reservation(
|
|
1069
|
-
ssh_public_keys=ssh_public_keys,
|
|
1091
|
+
ssh_public_keys=ssh_public_keys,
|
|
1092
|
+
rules=rules,
|
|
1093
|
+
duration=reservation_duration,
|
|
1094
|
+
environment=environment,
|
|
1095
|
+
debug_reservation=debug_reservation,
|
|
1070
1096
|
)
|
|
1071
1097
|
|
|
1072
1098
|
machine_pre = "Machine" if len(environments) == 1 else str(len(environments)) + " machines"
|
|
@@ -1116,7 +1142,7 @@ def request(
|
|
|
1116
1142
|
request["environments"] = environments
|
|
1117
1143
|
request["settings"] = {}
|
|
1118
1144
|
|
|
1119
|
-
if reserve or pipeline_type or parallel_limit:
|
|
1145
|
+
if reserve or pipeline_type or parallel_limit or timeout != DEFAULT_PIPELINE_TIMEOUT:
|
|
1120
1146
|
request["settings"]["pipeline"] = {}
|
|
1121
1147
|
|
|
1122
1148
|
# in case the reservation duration is more than the pipeline timeout, adjust also the pipeline timeout
|
|
@@ -1128,6 +1154,11 @@ def request(
|
|
|
1128
1154
|
request["settings"]["pipeline"] = {"timeout": timeout}
|
|
1129
1155
|
console.print(f"⏳ Maximum reservation time is {timeout} minutes")
|
|
1130
1156
|
|
|
1157
|
+
# forced pipeline timeout
|
|
1158
|
+
elif timeout != DEFAULT_PIPELINE_TIMEOUT:
|
|
1159
|
+
console.print(f"⏳ Pipeline timeout forced to {timeout} minutes")
|
|
1160
|
+
request["settings"]["pipeline"] = {"timeout": timeout}
|
|
1161
|
+
|
|
1131
1162
|
if pipeline_type:
|
|
1132
1163
|
request["settings"]["pipeline"]["type"] = pipeline_type.value
|
|
1133
1164
|
|
|
@@ -1217,6 +1248,7 @@ def restart(
|
|
|
1217
1248
|
ssh_public_keys: List[str] = _option_ssh_public_keys(REQUEST_PANEL_RESERVE),
|
|
1218
1249
|
autoconnect: bool = _option_autoconnect(REQUEST_PANEL_RESERVE),
|
|
1219
1250
|
reservation_duration: int = _option_reservation_duration(REQUEST_PANEL_RESERVE),
|
|
1251
|
+
debug_reservation: bool = _option_debug_reservation(REQUEST_PANEL_RESERVE),
|
|
1220
1252
|
):
|
|
1221
1253
|
"""
|
|
1222
1254
|
Restart a Testing Farm request.
|
|
@@ -1401,7 +1433,11 @@ def restart(
|
|
|
1401
1433
|
|
|
1402
1434
|
for environment in request["environments"]:
|
|
1403
1435
|
_add_reservation(
|
|
1404
|
-
ssh_public_keys=ssh_public_keys,
|
|
1436
|
+
ssh_public_keys=ssh_public_keys,
|
|
1437
|
+
rules=rules,
|
|
1438
|
+
duration=reservation_duration,
|
|
1439
|
+
environment=environment,
|
|
1440
|
+
debug_reservation=debug_reservation,
|
|
1405
1441
|
)
|
|
1406
1442
|
|
|
1407
1443
|
machine_pre = (
|
|
@@ -1560,6 +1596,10 @@ def run(
|
|
|
1560
1596
|
if state in ["complete", "error"]:
|
|
1561
1597
|
break
|
|
1562
1598
|
|
|
1599
|
+
if state in ["canceled", "cancel-requested"]:
|
|
1600
|
+
progress.stop()
|
|
1601
|
+
exit_error("Request canceled.")
|
|
1602
|
+
|
|
1563
1603
|
time.sleep(1)
|
|
1564
1604
|
|
|
1565
1605
|
# workaround TFT-1690
|
|
@@ -1636,6 +1676,7 @@ def reserve(
|
|
|
1636
1676
|
git_ref: Optional[str] = typer.Option(
|
|
1637
1677
|
None, help="Force GIT ref or branch. Useful for testing changes to reservation plan."
|
|
1638
1678
|
),
|
|
1679
|
+
debug_reservation: bool = _option_debug_reservation(),
|
|
1639
1680
|
):
|
|
1640
1681
|
"""
|
|
1641
1682
|
Reserve a system in Testing Farm.
|
|
@@ -1726,7 +1767,14 @@ def reserve(
|
|
|
1726
1767
|
environment["settings"]["provisioning"].update(rules)
|
|
1727
1768
|
|
|
1728
1769
|
console.print(f"🕗 Reserved for [blue]{str(reservation_duration)}[/blue] minutes")
|
|
1729
|
-
|
|
1770
|
+
|
|
1771
|
+
if "variables" not in environment or environment["variables"] is None:
|
|
1772
|
+
environment["variables"] = {}
|
|
1773
|
+
|
|
1774
|
+
environment["variables"]["TF_RESERVATION_DURATION"] = str(reservation_duration)
|
|
1775
|
+
|
|
1776
|
+
if debug_reservation:
|
|
1777
|
+
environment["variables"]["TF_RESERVATION_DEBUG"] = "1"
|
|
1730
1778
|
|
|
1731
1779
|
authorized_keys = read_glob_paths(ssh_public_keys).encode("utf-8")
|
|
1732
1780
|
if not authorized_keys:
|
|
@@ -1826,7 +1874,11 @@ def reserve(
|
|
|
1826
1874
|
current_state = state
|
|
1827
1875
|
|
|
1828
1876
|
if state in ["complete", "error"]:
|
|
1829
|
-
exit_error("Reservation failed, check API request or contact Testing Farm")
|
|
1877
|
+
exit_error("Reservation failed, check the API request or contact Testing Farm.")
|
|
1878
|
+
|
|
1879
|
+
if state in ["canceled", "cancel-requested"]:
|
|
1880
|
+
progress.stop()
|
|
1881
|
+
exit_error("Reservation canceled.")
|
|
1830
1882
|
|
|
1831
1883
|
if not print_only_request_id and task_id is not None:
|
|
1832
1884
|
progress.update(task_id, description=f"Reservation job is [yellow]{current_state}[/yellow]")
|
|
@@ -1881,6 +1933,10 @@ def reserve(
|
|
|
1881
1933
|
)
|
|
1882
1934
|
)
|
|
1883
1935
|
|
|
1936
|
+
if '[testing-farm-request] Cancelling pipeline' in pipeline_log:
|
|
1937
|
+
progress.stop()
|
|
1938
|
+
exit_error('Pipeline was canceled.')
|
|
1939
|
+
|
|
1884
1940
|
if '[pre-artifact-installation]' in pipeline_log:
|
|
1885
1941
|
current_state = "preparing environment"
|
|
1886
1942
|
|