def handle_notification(r, user): if not user.can_do("notify", r.builder): log.alert("user %s is not allowed to notify:%s" % (user.login, r.builder)) q = B_Queue(path.req_queue_file) q.lock(0) q.read() not_fin = filter(lambda (r): not r.is_done(), q.requests) r.apply_to(q) for r in not_fin: if r.is_done(): util.clean_tmp(path.srpms_dir + '/' + r.id) now = time.time() def leave_it(r): # for ,,done'' set timeout to 4d if r.is_done() and r.time + 4 * 24 * 60 * 60 < now: return False # and for not ,,done'' set it to 20d if r.time + 20 * 24 * 60 * 60 < now: util.clean_tmp(path.srpms_dir + '/' + r.id) return False return True q.requests = filter(leave_it, q.requests) q.write() q.dump(path.queue_stats_file) q.dump_html(path.queue_html_stats_file) q.write_signed(path.req_queue_signed_file) q.unlock()
def main_for(builder): msg = "" init_conf(builder) q = B_Queue(path.queue_file + "-" + config.builder) q.lock(0) q.read() if q.requests == []: q.unlock() return req = pick_request(q) q.unlock() # high priority tasks have priority < 0, normal tasks >= 0 if req.priority >= 0: # allow only one build in given builder at once if not lock.lock("building-rpm-for-%s" % config.builder, non_block=1): return # don't kill server check_load() # not more then job_slots builds at once locked = 0 for slot in range(config.job_slots): if lock.lock("building-rpm-slot-%d" % slot, non_block=1): locked = 1 break if not locked: return # record fact that we got lock for this builder, load balancer # will use it for fair-queuing l = lock.lock("got-lock") f = open(path.got_lock_file, "a") f.write(config.builder + "\n") f.close() l.close() else: msg = "HIGH PRIORITY: " msg += "handling request %s (%d) for %s from %s, priority %s" \ % (req.id, req.no, config.builder, req.requester, req.priority) log.notice(msg) status.push(msg) handle_request(req) status.pop() def otherreqs(r): if r.no == req.no: return False else: return True q = B_Queue(path.queue_file + "-" + config.builder) q.lock(0) q.read() previouslen = len(q.requests) q.requests = filter(otherreqs, q.requests) if len(q.requests) < previouslen: q.write() q.unlock()
def main_for(builder): msg = "" init_conf(builder) q = B_Queue(path.queue_file + "-" + config.builder) q.lock(0) q.read() if q.requests == []: q.unlock() return req = pick_request(q) q.unlock() # high priority tasks have priority < 0, normal tasks >= 0 if req.priority >= 0: # allow only one build in given builder at once if not lock.lock("building-rpm-for-%s" % config.builder, non_block = 1): return # don't kill server check_load() # not more then job_slots builds at once locked = 0 for slot in range(config.job_slots): if lock.lock("building-rpm-slot-%d" % slot, non_block = 1): locked = 1 break if not locked: return # record fact that we got lock for this builder, load balancer # will use it for fair-queuing l = lock.lock("got-lock") f = open(path.got_lock_file, "a") f.write(config.builder + "\n") f.close() l.close() else: msg = "HIGH PRIORITY: " msg += "handling request %s (%d) for %s from %s, priority %s" \ % (req.id, req.no, config.builder, req.requester, req.priority) log.notice(msg) status.push(msg) handle_request(req) status.pop() def otherreqs(r): if r.no==req.no: return False else: return True q = B_Queue(path.queue_file + "-" + config.builder) q.lock(0) q.read() previouslen=len(q.requests) q.requests=filter(otherreqs, q.requests) if len(q.requests)<previouslen: q.write() q.unlock()