nomadpy 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {nomadpy-0.2.0/src/nomadpy.egg-info → nomadpy-0.3.0}/PKG-INFO +2 -2
- {nomadpy-0.2.0 → nomadpy-0.3.0}/README.md +1 -1
- {nomadpy-0.2.0 → nomadpy-0.3.0}/pyproject.toml +1 -1
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/__init__.py +24 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/api.py +2 -0
- nomadpy-0.3.0/src/nomadpy/batch_job_queue.py +122 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/node_pools.py +2 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0/src/nomadpy.egg-info}/PKG-INFO +2 -2
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy.egg-info/SOURCES.txt +2 -0
- nomadpy-0.3.0/tests/test_batch_job_queue.py +41 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_node_pools.py +56 -1
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_wire.py +19 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/LICENSE +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/setup.cfg +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/acl.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/agent.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/allocations.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/allocations_exec.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/constraint.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/consul.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/csi.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/deployments.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/error_unexpected_response.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/evaluations.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/event_stream.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/fs.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/host_volume_claims.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/host_volumes.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/jobs.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/keyring.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/models.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/namespace.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/node_identity.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/node_meta.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/nodes.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/operator.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/operator_autopilot.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/operator_metrics.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/quota.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/recommendations.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/regions.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/resources.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/scaling.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/search.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/sentinel.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/services.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/status.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/system.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/task_sched.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/tasks.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy/variables.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy.egg-info/dependency_links.txt +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy.egg-info/requires.txt +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/src/nomadpy.egg-info/top_level.txt +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_acl.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_agent.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_allocations.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_api.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_deployments.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_drift.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_enterprise.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_evaluations.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_exec.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_jobs.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_keyring.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_namespace.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_nodes.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_operator.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_regions.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_scaling.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_services.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_status.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_streams.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_tls.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_variables.py +0 -0
- {nomadpy-0.2.0 → nomadpy-0.3.0}/tests/test_volumes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nomadpy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python client for the HashiCorp Nomad HTTP API
|
|
5
5
|
License-Expression: MPL-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/benemon/nomadpy
|
|
@@ -24,7 +24,7 @@ Dynamic: license-file
|
|
|
24
24
|
|
|
25
25
|
# nomadpy
|
|
26
26
|
|
|
27
|
-
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
27
|
+
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/compat.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
28
28
|
|
|
29
29
|
Python client for the HashiCorp Nomad HTTP API, Community and Enterprise.
|
|
30
30
|
A port of the Go `api` package from `github.com/hashicorp/nomad`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nomadpy
|
|
2
2
|
|
|
3
|
-
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
3
|
+
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/compat.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
4
4
|
|
|
5
5
|
Python client for the HashiCorp Nomad HTTP API, Community and Enterprise.
|
|
6
6
|
A port of the Go `api` package from `github.com/hashicorp/nomad`.
|
|
@@ -69,6 +69,19 @@ from .allocations import (
|
|
|
69
69
|
RescheduleEvent,
|
|
70
70
|
RescheduleTracker,
|
|
71
71
|
)
|
|
72
|
+
from .batch_job_queue import (
|
|
73
|
+
AgeConfig,
|
|
74
|
+
BatchJobQueueJobsResponse,
|
|
75
|
+
BatchJobQueueStatusResponse,
|
|
76
|
+
BatchQueueConfig,
|
|
77
|
+
DynamicPriorityTenant,
|
|
78
|
+
DynamicPriorityWorkload,
|
|
79
|
+
DynamicQueueConfig,
|
|
80
|
+
FifoQueueConfig,
|
|
81
|
+
JobSizeConfig,
|
|
82
|
+
TenantFairshareConfig,
|
|
83
|
+
Workload,
|
|
84
|
+
)
|
|
72
85
|
from .constraint import Constraint
|
|
73
86
|
from .consul import (
|
|
74
87
|
Consul,
|
|
@@ -361,6 +374,7 @@ __all__ = [
|
|
|
361
374
|
"ACLTokenRoleLink",
|
|
362
375
|
"Action",
|
|
363
376
|
"Affinity",
|
|
377
|
+
"AgeConfig",
|
|
364
378
|
"AgentHealth",
|
|
365
379
|
"AgentHealthResponse",
|
|
366
380
|
"AgentMember",
|
|
@@ -392,6 +406,9 @@ __all__ = [
|
|
|
392
406
|
"AutopilotUpgrade",
|
|
393
407
|
"AutopilotZone",
|
|
394
408
|
"AutopilotZoneUpgradeVersions",
|
|
409
|
+
"BatchJobQueueJobsResponse",
|
|
410
|
+
"BatchJobQueueStatusResponse",
|
|
411
|
+
"BatchQueueConfig",
|
|
395
412
|
"ChangeScript",
|
|
396
413
|
"CheckRestart",
|
|
397
414
|
"Client",
|
|
@@ -454,6 +471,9 @@ __all__ = [
|
|
|
454
471
|
"DrainSpec",
|
|
455
472
|
"DrainStrategy",
|
|
456
473
|
"DriverInfo",
|
|
474
|
+
"DynamicPriorityTenant",
|
|
475
|
+
"DynamicPriorityWorkload",
|
|
476
|
+
"DynamicQueueConfig",
|
|
457
477
|
"EphemeralDisk",
|
|
458
478
|
"ErrCASConflict",
|
|
459
479
|
"Evaluation",
|
|
@@ -461,6 +481,7 @@ __all__ = [
|
|
|
461
481
|
"Event",
|
|
462
482
|
"Events",
|
|
463
483
|
"FieldDiff",
|
|
484
|
+
"FifoQueueConfig",
|
|
464
485
|
"FuzzyMatch",
|
|
465
486
|
"FuzzySearchResponse",
|
|
466
487
|
"GaugeValue",
|
|
@@ -494,6 +515,7 @@ __all__ = [
|
|
|
494
515
|
"JobUILink",
|
|
495
516
|
"JobValidateResponse",
|
|
496
517
|
"JobVersionTag",
|
|
518
|
+
"JobSizeConfig",
|
|
497
519
|
"KeyringResponse",
|
|
498
520
|
"License",
|
|
499
521
|
"LicenseReply",
|
|
@@ -614,6 +636,7 @@ __all__ = [
|
|
|
614
636
|
"TaskScheduleCron",
|
|
615
637
|
"TaskState",
|
|
616
638
|
"Template",
|
|
639
|
+
"TenantFairshareConfig",
|
|
617
640
|
"TLSConfig",
|
|
618
641
|
"UnexpectedResponseError",
|
|
619
642
|
"UpdateStrategy",
|
|
@@ -626,6 +649,7 @@ __all__ = [
|
|
|
626
649
|
"VolumeMount",
|
|
627
650
|
"VolumeRequest",
|
|
628
651
|
"WaitConfig",
|
|
652
|
+
"Workload",
|
|
629
653
|
"WorkloadIdentity",
|
|
630
654
|
"WriteMeta",
|
|
631
655
|
"WriteOptions",
|
|
@@ -213,6 +213,7 @@ class Client:
|
|
|
213
213
|
self.agent = Agent(self)
|
|
214
214
|
self.alloc_fs = AllocFS(self)
|
|
215
215
|
self.allocations = Allocations(self)
|
|
216
|
+
self.batch_queue = BatchQueue(self)
|
|
216
217
|
self.csi_plugins = CSIPlugins(self)
|
|
217
218
|
self.csi_volumes = CSIVolumes(self)
|
|
218
219
|
self.deployments = Deployments(self)
|
|
@@ -446,6 +447,7 @@ def _decode(raw: bytes) -> Any:
|
|
|
446
447
|
from .agent import Agent # noqa: E402
|
|
447
448
|
from .acl import ACLAuth, ACLAuthMethods, ACLBindingRules, ACLIdentity, ACLPolicies, ACLRoles, ACLTokens # noqa: E402
|
|
448
449
|
from .allocations import Allocations # noqa: E402
|
|
450
|
+
from .batch_job_queue import BatchQueue # noqa: E402
|
|
449
451
|
from .csi import CSIPlugins, CSIVolumes # noqa: E402
|
|
450
452
|
from .deployments import Deployments # noqa: E402
|
|
451
453
|
from .host_volume_claims import TaskGroupHostVolumeClaims # noqa: E402
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
from .models import Model
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from .api import Client, QueryMeta, QueryOptions
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BatchQueue:
|
|
13
|
+
"""BatchQueue queries the experimental batch job queue endpoints."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, client: Client):
|
|
16
|
+
self._client = client
|
|
17
|
+
|
|
18
|
+
def jobs(self, q: QueryOptions | None = None) -> tuple[BatchJobQueueJobsResponse, QueryMeta]:
|
|
19
|
+
resp, qm = self._client.query("/v1/queue/jobs", q)
|
|
20
|
+
return BatchJobQueueJobsResponse.from_json(resp), qm
|
|
21
|
+
|
|
22
|
+
def status(self, q: QueryOptions | None = None) -> tuple[BatchJobQueueStatusResponse, QueryMeta]:
|
|
23
|
+
resp, qm = self._client.query("/v1/queue/status", q)
|
|
24
|
+
return BatchJobQueueStatusResponse.from_json(resp), qm
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# generated from surface.json: file=batch_job_queue.go
|
|
28
|
+
|
|
29
|
+
BATCH_QUEUE_TENANT_METADATA = "metadata"
|
|
30
|
+
BATCH_QUEUE_TENANT_NAMESPACE = "namespace"
|
|
31
|
+
BATCH_QUEUE_TYPE_DYNAMIC = "dynamic_priority"
|
|
32
|
+
BATCH_QUEUE_TYPE_FIFO = "fifo"
|
|
33
|
+
BATCH_QUEUE_TYPE_PASSTHROUGH = "passthrough"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class AgeConfig(Model):
|
|
38
|
+
weight: int = 0
|
|
39
|
+
max: int = 0
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class BatchJobQueueJobsResponse(Model):
|
|
44
|
+
type: str = ""
|
|
45
|
+
workloads: Any = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class BatchJobQueueStatusResponse(Model):
|
|
50
|
+
type: str = ""
|
|
51
|
+
status: Any = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class BatchQueueConfig(Model):
|
|
56
|
+
constraint_timeout: int = 0
|
|
57
|
+
dynamic_priority: DynamicQueueConfig | None = None
|
|
58
|
+
fifo: FifoQueueConfig | None = None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass
|
|
62
|
+
class DynamicPriorityTenant(Model):
|
|
63
|
+
tenant_id: str = field(default="", metadata={'json': 'TenantID'})
|
|
64
|
+
percentage_used: int = 0
|
|
65
|
+
tenant_fairshare: dict[str, float] | None = None
|
|
66
|
+
total_fairshare: dict[str, float] | None = None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@dataclass
|
|
70
|
+
class DynamicPriorityWorkload(Model):
|
|
71
|
+
job_id: str = field(default="", metadata={'json': 'JobID'})
|
|
72
|
+
tenant: str = ""
|
|
73
|
+
status: str = ""
|
|
74
|
+
position: int = 0
|
|
75
|
+
adjusted_priority: int = 0
|
|
76
|
+
base_priority: int = 0
|
|
77
|
+
fairshare_adjustment: int = 0
|
|
78
|
+
age_adjustment: int = 0
|
|
79
|
+
cpu_adjustment: int = 0
|
|
80
|
+
memory_adjustment: int = 0
|
|
81
|
+
created_at: int = 0
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclass
|
|
85
|
+
class FifoQueueConfig(Model):
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@dataclass
|
|
90
|
+
class JobSizeConfig(Model):
|
|
91
|
+
cpu_weight: int = 0
|
|
92
|
+
cpu_max: int = 0
|
|
93
|
+
memory_weight: int = 0
|
|
94
|
+
memory_max: int = 0
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class TenantFairshareConfig(Model):
|
|
99
|
+
tenant_type: str = ""
|
|
100
|
+
metadata_key: str = ""
|
|
101
|
+
cpu_weight: int = 0
|
|
102
|
+
memory_weight: int = 0
|
|
103
|
+
exclude_alloc_statuses: list[str] | None = None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class Workload(Model):
|
|
108
|
+
job_id: str = field(default="", metadata={'json': 'JobID'})
|
|
109
|
+
position: int = 0
|
|
110
|
+
status: str = ""
|
|
111
|
+
created_at: int = 0
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass
|
|
115
|
+
class DynamicQueueConfig(Model):
|
|
116
|
+
calc_interval: int = 0
|
|
117
|
+
tenant_fairshare: TenantFairshareConfig = field(default_factory=TenantFairshareConfig)
|
|
118
|
+
age: AgeConfig = field(default_factory=AgeConfig)
|
|
119
|
+
job_size: JobSizeConfig = field(default_factory=JobSizeConfig)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# end generated
|
|
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
from urllib.parse import quote
|
|
7
7
|
|
|
8
|
+
from .batch_job_queue import BatchQueueConfig
|
|
8
9
|
from .jobs import JobListStub
|
|
9
10
|
from .api import QueryOptions
|
|
10
11
|
from .models import Model
|
|
@@ -32,6 +33,7 @@ class NodePool(Model):
|
|
|
32
33
|
meta: dict[str, str] | None = None
|
|
33
34
|
node_identity_ttl: int = field(default=0, metadata={"json": "NodeIdentityTTL", "duration": "string"})
|
|
34
35
|
scheduler_configuration: NodePoolSchedulerConfiguration | None = None
|
|
36
|
+
batch_queue_config: BatchQueueConfig | None = None
|
|
35
37
|
create_index: int = 0
|
|
36
38
|
modify_index: int = 0
|
|
37
39
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nomadpy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python client for the HashiCorp Nomad HTTP API
|
|
5
5
|
License-Expression: MPL-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/benemon/nomadpy
|
|
@@ -24,7 +24,7 @@ Dynamic: license-file
|
|
|
24
24
|
|
|
25
25
|
# nomadpy
|
|
26
26
|
|
|
27
|
-
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
27
|
+
[](https://github.com/benemon/nomadpy/actions/workflows/ci.yml) [](https://github.com/benemon/nomadpy/actions/workflows/compat.yml) [](https://github.com/benemon/nomadpy/actions/workflows/codeql.yml) [](https://github.com/benemon/nomadpy/actions/workflows/release.yml) [](https://github.com/benemon/nomadpy/actions/workflows/dependabot/dependabot-updates) [](https://scorecard.dev/viewer/?uri=github.com/benemon/nomadpy) [](https://pypi.org/project/nomadpy/)
|
|
28
28
|
|
|
29
29
|
Python client for the HashiCorp Nomad HTTP API, Community and Enterprise.
|
|
30
30
|
A port of the Go `api` package from `github.com/hashicorp/nomad`.
|
|
@@ -7,6 +7,7 @@ src/nomadpy/agent.py
|
|
|
7
7
|
src/nomadpy/allocations.py
|
|
8
8
|
src/nomadpy/allocations_exec.py
|
|
9
9
|
src/nomadpy/api.py
|
|
10
|
+
src/nomadpy/batch_job_queue.py
|
|
10
11
|
src/nomadpy/constraint.py
|
|
11
12
|
src/nomadpy/consul.py
|
|
12
13
|
src/nomadpy/csi.py
|
|
@@ -50,6 +51,7 @@ tests/test_acl.py
|
|
|
50
51
|
tests/test_agent.py
|
|
51
52
|
tests/test_allocations.py
|
|
52
53
|
tests/test_api.py
|
|
54
|
+
tests/test_batch_job_queue.py
|
|
53
55
|
tests/test_deployments.py
|
|
54
56
|
tests/test_drift.py
|
|
55
57
|
tests/test_enterprise.py
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from nomadpy import BatchQueueConfig, FifoQueueConfig, NodePool, QueryOptions
|
|
4
|
+
from nomadpy.batch_job_queue import BATCH_QUEUE_TYPE_FIFO
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.mark.parametrize("config", [
|
|
8
|
+
{"ConstraintTimeout": 15_000_000_000, "DynamicPriority": None, "Fifo": {}},
|
|
9
|
+
{
|
|
10
|
+
"ConstraintTimeout": 15_000_000_000,
|
|
11
|
+
"DynamicPriority": {
|
|
12
|
+
"CalcInterval": 20_000_000_000,
|
|
13
|
+
"TenantFairshare": {
|
|
14
|
+
"TenantType": "namespace",
|
|
15
|
+
"MetadataKey": "",
|
|
16
|
+
"CpuWeight": 1,
|
|
17
|
+
"MemoryWeight": 2,
|
|
18
|
+
"ExcludeAllocStatuses": ["complete"],
|
|
19
|
+
},
|
|
20
|
+
"Age": {"Weight": 3, "Max": 14_400_000_000_000},
|
|
21
|
+
"JobSize": {"CpuWeight": 4, "CpuMax": 5000, "MemoryWeight": 6, "MemoryMax": 7000},
|
|
22
|
+
},
|
|
23
|
+
"Fifo": None,
|
|
24
|
+
},
|
|
25
|
+
])
|
|
26
|
+
def test_node_pool_batch_queue_config_round_trip(config):
|
|
27
|
+
pool = NodePool.from_json({"Name": "p", "BatchQueueConfig": config})
|
|
28
|
+
assert pool.to_json()["BatchQueueConfig"] == config
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_jobs_and_status(client):
|
|
32
|
+
name = "nomadpy-batch-queue-endpoints"
|
|
33
|
+
client.node_pools.register(NodePool(name=name, batch_queue_config=BatchQueueConfig(fifo=FifoQueueConfig())))
|
|
34
|
+
try:
|
|
35
|
+
q = QueryOptions(params={"node_pool": name})
|
|
36
|
+
jobs, jobs_meta = client.batch_queue.jobs(q)
|
|
37
|
+
status, status_meta = client.batch_queue.status(q)
|
|
38
|
+
assert jobs.type == BATCH_QUEUE_TYPE_FIFO and jobs.workloads == [] and jobs_meta.last_index >= 0
|
|
39
|
+
assert status.type == BATCH_QUEUE_TYPE_FIFO and status.status is None and status_meta.last_index >= 0
|
|
40
|
+
finally:
|
|
41
|
+
client.node_pools.delete(name)
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from jobspecs import register_and_wait
|
|
3
3
|
|
|
4
|
-
from nomadpy import
|
|
4
|
+
from nomadpy import (
|
|
5
|
+
AgeConfig,
|
|
6
|
+
BatchQueueConfig,
|
|
7
|
+
DynamicQueueConfig,
|
|
8
|
+
FifoQueueConfig,
|
|
9
|
+
JobSizeConfig,
|
|
10
|
+
NodePool,
|
|
11
|
+
NodePoolSchedulerConfiguration,
|
|
12
|
+
TenantFairshareConfig,
|
|
13
|
+
UnexpectedResponseError,
|
|
14
|
+
)
|
|
5
15
|
from nomadpy.node_pools import NODE_POOL_ALL, NODE_POOL_DEFAULT
|
|
6
16
|
|
|
7
17
|
HOUR = 3_600_000_000_000
|
|
18
|
+
SECOND = 1_000_000_000
|
|
8
19
|
|
|
9
20
|
|
|
10
21
|
def test_builtin_pools(client):
|
|
@@ -66,3 +77,47 @@ def test_scheduler_configuration_on_enterprise(ent_client):
|
|
|
66
77
|
assert got.scheduler_configuration.memory_oversubscription_enabled is True
|
|
67
78
|
finally:
|
|
68
79
|
ent_client.node_pools.delete("nomadpy-pool-sched")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_fifo_batch_queue_config(client):
|
|
83
|
+
name = "nomadpy-pool-fifo"
|
|
84
|
+
client.node_pools.register(NodePool(name=name, batch_queue_config=BatchQueueConfig(fifo=FifoQueueConfig())))
|
|
85
|
+
try:
|
|
86
|
+
got, _ = client.node_pools.info(name)
|
|
87
|
+
assert got.batch_queue_config.fifo == FifoQueueConfig()
|
|
88
|
+
finally:
|
|
89
|
+
client.node_pools.delete(name)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_dynamic_batch_queue_config_survives_reregister(client):
|
|
93
|
+
name = "nomadpy-pool-dynamic"
|
|
94
|
+
config = BatchQueueConfig(
|
|
95
|
+
constraint_timeout=15 * SECOND,
|
|
96
|
+
dynamic_priority=DynamicQueueConfig(
|
|
97
|
+
calc_interval=20 * SECOND,
|
|
98
|
+
tenant_fairshare=TenantFairshareConfig(tenant_type="namespace", cpu_weight=1, memory_weight=2),
|
|
99
|
+
age=AgeConfig(weight=3, max=4 * HOUR),
|
|
100
|
+
job_size=JobSizeConfig(cpu_weight=5, cpu_max=6000, memory_weight=7, memory_max=8000),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
client.node_pools.register(NodePool(name=name, batch_queue_config=config))
|
|
104
|
+
try:
|
|
105
|
+
got, _ = client.node_pools.info(name)
|
|
106
|
+
before = got.batch_queue_config
|
|
107
|
+
assert before == config
|
|
108
|
+
got.description = "updated without changing the queue"
|
|
109
|
+
client.node_pools.register(got)
|
|
110
|
+
updated, _ = client.node_pools.info(name)
|
|
111
|
+
assert updated.batch_queue_config == before
|
|
112
|
+
finally:
|
|
113
|
+
client.node_pools.delete(name)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_node_pool_without_batch_queue_config(client):
|
|
117
|
+
name = "nomadpy-pool-no-queue"
|
|
118
|
+
client.node_pools.register(NodePool(name=name))
|
|
119
|
+
try:
|
|
120
|
+
got, _ = client.node_pools.info(name)
|
|
121
|
+
assert got.batch_queue_config is None
|
|
122
|
+
finally:
|
|
123
|
+
client.node_pools.delete(name)
|
|
@@ -26,17 +26,22 @@ from nomadpy import (
|
|
|
26
26
|
ACLRolePolicyLink,
|
|
27
27
|
ACLToken,
|
|
28
28
|
ACLTokenRoleLink,
|
|
29
|
+
AgeConfig,
|
|
29
30
|
AutopilotConfiguration,
|
|
31
|
+
BatchQueueConfig,
|
|
30
32
|
Client,
|
|
31
33
|
Config,
|
|
32
34
|
CSISnapshot,
|
|
33
35
|
CSIVolume,
|
|
34
36
|
CSIVolumeCapability,
|
|
35
37
|
DrainSpec,
|
|
38
|
+
DynamicQueueConfig,
|
|
39
|
+
FifoQueueConfig,
|
|
36
40
|
HostVolume,
|
|
37
41
|
HostVolumeCapability,
|
|
38
42
|
Job,
|
|
39
43
|
JobACL,
|
|
44
|
+
JobSizeConfig,
|
|
40
45
|
Namespace,
|
|
41
46
|
NamespaceCapabilities,
|
|
42
47
|
NamespaceConsulConfiguration,
|
|
@@ -58,6 +63,7 @@ from nomadpy import (
|
|
|
58
63
|
SchedulerConfiguration,
|
|
59
64
|
SchedulerWorkerPoolArgs,
|
|
60
65
|
SentinelPolicy,
|
|
66
|
+
TenantFairshareConfig,
|
|
61
67
|
UnexpectedResponseError,
|
|
62
68
|
Variable,
|
|
63
69
|
VariableLock,
|
|
@@ -182,12 +188,25 @@ OPS = {
|
|
|
182
188
|
"allocations.get_pause_state": lambda c: c.allocations.get_pause_state("a1", "t"),
|
|
183
189
|
"allocations.services": lambda c: c.allocations.services("a1"),
|
|
184
190
|
|
|
191
|
+
"batch_queue.jobs": lambda c: c.batch_queue.jobs(qopts()),
|
|
192
|
+
"batch_queue.status": lambda c: c.batch_queue.status(qopts()),
|
|
193
|
+
|
|
185
194
|
"node_pools.list": lambda c: c.node_pools.list(),
|
|
186
195
|
"node_pools.prefix_list": lambda c: c.node_pools.prefix_list("pre", qopts()),
|
|
187
196
|
"node_pools.info": lambda c: c.node_pools.info("p 1"),
|
|
188
197
|
"node_pools.register": lambda c: c.node_pools.register(NodePool(
|
|
189
198
|
name="p1", description="d", meta={"k": "v"}, node_identity_ttl=HOUR,
|
|
190
199
|
scheduler_configuration=NodePoolSchedulerConfiguration(scheduler_algorithm="spread", memory_oversubscription_enabled=True)), WRITE_OPTS),
|
|
200
|
+
"node_pools.register_fifo_queue": lambda c: c.node_pools.register(NodePool(
|
|
201
|
+
name="p-fifo", batch_queue_config=BatchQueueConfig(constraint_timeout=15 * SECOND, fifo=FifoQueueConfig()))),
|
|
202
|
+
"node_pools.register_dynamic_queue": lambda c: c.node_pools.register(NodePool(
|
|
203
|
+
name="p-dynamic", batch_queue_config=BatchQueueConfig(
|
|
204
|
+
constraint_timeout=15 * SECOND,
|
|
205
|
+
dynamic_priority=DynamicQueueConfig(
|
|
206
|
+
calc_interval=20 * SECOND,
|
|
207
|
+
tenant_fairshare=TenantFairshareConfig(tenant_type="namespace", cpu_weight=1, memory_weight=2),
|
|
208
|
+
age=AgeConfig(weight=3, max=4 * HOUR),
|
|
209
|
+
job_size=JobSizeConfig(cpu_weight=5, cpu_max=6000, memory_weight=7, memory_max=8000))))),
|
|
191
210
|
"node_pools.register_minimal": lambda c: c.node_pools.register(NodePool(name="p2")),
|
|
192
211
|
"node_pools.delete": lambda c: c.node_pools.delete("p1", WRITE_OPTS),
|
|
193
212
|
"node_pools.list_jobs": lambda c: c.node_pools.list_jobs("p1"),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|