Skip to content
Snippets Groups Projects
Verified Commit aeefd324 authored by Dorian Koch's avatar Dorian Koch
Browse files

Use more resources for CutAndTranscode

parent 2118d34a
No related branches found
No related tags found
No related merge requests found
Pipeline #6481 passed
...@@ -43,6 +43,7 @@ class CutAndTranscode(WrappedJob): ...@@ -43,6 +43,7 @@ class CutAndTranscode(WrappedJob):
def config(self) -> ContainerConfig: def config(self) -> ContainerConfig:
cfg = ContainerConfig(image="registry.git.fsmpi.rwth-aachen.de/videoag_infra/production/dominic_render_video:latest", args=["-C", self.in_dir]) cfg = ContainerConfig(image="registry.git.fsmpi.rwth-aachen.de/videoag_infra/production/dominic_render_video:latest", args=["-C", self.in_dir])
cfg.mount_video_fs("/mnt/video_data") cfg.mount_video_fs("/mnt/video_data")
cfg.resources("8", "12Gi")
return cfg return cfg
def prepare(self, cstate: "ControllerState"): def prepare(self, cstate: "ControllerState"):
......
...@@ -10,10 +10,19 @@ class ContainerConfig: ...@@ -10,10 +10,19 @@ class ContainerConfig:
self.command = command self.command = command
self.args = args self.args = args
self.mount_video_fs_path: str | None = None self.mount_video_fs_path: str | None = None
self.resources_dict: dict | None = None
def mount_video_fs(self, mount_path: str): def mount_video_fs(self, mount_path: str):
self.mount_video_fs_path = mount_path self.mount_video_fs_path = mount_path
def resources(self, cpu: str, memory: str):
self.resources_dict = {
"limits": {
"cpu": cpu,
"memory": memory
}
}
class WrappedJob(Event): class WrappedJob(Event):
......
...@@ -34,15 +34,7 @@ class K8sApi(): ...@@ -34,15 +34,7 @@ class K8sApi():
def list_worker_jobs(self) -> V1JobList: def list_worker_jobs(self) -> V1JobList:
return self.batch_v1.list_namespaced_job(NAMESPACE, label_selector=f"app={WORKER_LABEL}") return self.batch_v1.list_namespaced_job(NAMESPACE, label_selector=f"app={WORKER_LABEL}")
def create_job(self, job: WrappedJob, resources={}): def create_job(self, job: WrappedJob):
default_res = {
"limits": {
"cpu": "1",
"memory": "1Gi"
}
}
resources = {**default_res, **resources}
cfg = job.config() cfg = job.config()
job_manifest = { job_manifest = {
...@@ -76,7 +68,12 @@ class K8sApi(): ...@@ -76,7 +68,12 @@ class K8sApi():
"image": cfg.image, "image": cfg.image,
"args": cfg.args, "args": cfg.args,
"command": cfg.command, "command": cfg.command,
"resources": resources "resources": {
"limits": {
"cpu": "1",
"memory": "1Gi"
}
}
} }
], ],
"priorityClassName": "videoag-worker-priority", "priorityClassName": "videoag-worker-priority",
...@@ -118,6 +115,8 @@ class K8sApi(): ...@@ -118,6 +115,8 @@ class K8sApi():
} }
} }
] ]
if cfg.resources_dict is not None:
job_manifest["spec"]["template"]["spec"]["containers"][0]["resources"] = cfg.resources_dict
# print(f"Creating job with manifest: {json.dumps(job_manifest)}") # print(f"Creating job with manifest: {json.dumps(job_manifest)}")
return self.batch_v1.create_namespaced_job(NAMESPACE, job_manifest) return self.batch_v1.create_namespaced_job(NAMESPACE, job_manifest)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment