]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Show when jobs time out
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 13:38:15 +0000 (13:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 13:38:15 +0000 (13:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py
src/templates/jobs/modules/list.html

index 954279856a2268a92a46bfa09fd2e9e49eef8a2a..b0299d51735c570a0c0c8db99b4fb65b81d27f26 100644 (file)
@@ -593,6 +593,28 @@ class Job(base.DataObject):
                """
                return self.data.finished_at
 
+       @property
+       def timeout(self):
+               """
+                       The timeout for this jobs
+               """
+               return self.data.timeout
+
+       @property
+       def times_out_in(self):
+               """
+                       The remaining time until the timeout ends
+               """
+               if not self.is_running():
+                       return
+
+               # Return nothing if no timeout is configured
+               if not self.timeout:
+                       return
+
+               # Return the remaining time
+               return self.timeout - self.duration
+
        def assign(self, builder):
                """
                        Assigns this job to a builder
index 279fb99fa38a88e75572af9a545d2a6caacd7c8e..bb69b8082bcfefd491b706502117ce22c0e801c7 100644 (file)
@@ -1,3 +1,5 @@
+{% import datetime %}
+
 {% for job in sorted(jobs) %}
        {% set build = job.build %}
 
                                                <div class="level-left">
                                                        <div class="level-item">
                                                                {{ format_time(job.duration) }}
+
+                                                               {# If the job is approaching its timeout, we will show a warning #}
+                                                               {% if job.times_out_in and job.times_out_in <= datetime.timedelta(hours=1) %}
+                                                                       / {{ format_time(job.timeout) }}
+                                                               {% end %}
                                                        </div>
                                                </div>