[Notes] [Git][BuildGrid/buildgrid][finn/one-lease-per-worker] 2 commits: One lease per bot session.



Title: GitLab

finn pushed to branch finn/one-lease-per-worker at BuildGrid / buildgrid

Commits:

3 changed files:

Changes:

  • buildgrid/server/bots/instance.py
    ... ... @@ -66,7 +66,9 @@ class BotsInterface:
    66 66
             self._bot_sessions[name] = bot_session
    
    67 67
             self.logger.info("Created bot session name=[{}] with bot_id=[{}]".format(name, bot_id))
    
    68 68
     
    
    69
    -        for lease in self._scheduler.create_leases():
    
    69
    +        # For now, one lease at a time.
    
    70
    +        lease = self._scheduler.create_lease()
    
    71
    +        if lease:
    
    70 72
                 bot_session.leases.extend([lease])
    
    71 73
     
    
    72 74
             return bot_session
    
    ... ... @@ -83,8 +85,11 @@ class BotsInterface:
    83 85
             del bot_session.leases[:]
    
    84 86
             bot_session.leases.extend(leases)
    
    85 87
     
    
    86
    -        for lease in self._scheduler.create_leases():
    
    87
    -            bot_session.leases.extend([lease])
    
    88
    +        # For now, one lease at a time
    
    89
    +        if not bot_session.leases:
    
    90
    +            lease = self._scheduler.create_lease()
    
    91
    +            if lease:
    
    92
    +                bot_session.leases.extend([lease])
    
    88 93
     
    
    89 94
             self._bot_sessions[name] = bot_session
    
    90 95
             return bot_session
    

  • buildgrid/server/scheduler.py
    ... ... @@ -108,10 +108,11 @@ class Scheduler:
    108 108
             if state in (LeaseState.PENDING.value, LeaseState.ACTIVE.value):
    
    109 109
                 self.retry_job(name)
    
    110 110
     
    
    111
    -    def create_leases(self):
    
    112
    -        while self.queue:
    
    111
    +    def create_lease(self):
    
    112
    +        if self.queue:
    
    113 113
                 job = self.queue.popleft()
    
    114 114
                 job.update_execute_stage(ExecuteStage.EXECUTING)
    
    115 115
                 job.create_lease()
    
    116 116
                 job.lease.state = LeaseState.PENDING.value
    
    117
    -            yield job.lease
    117
    +            return job.lease
    
    118
    +        return None

  • tests/integration/bots_service.py
    ... ... @@ -129,7 +129,7 @@ def test_number_of_leases(number_of_jobs, bot_session, context, instance):
    129 129
         request = bots_pb2.CreateBotSessionRequest(bot_session=bot_session)
    
    130 130
         response = instance.CreateBotSession(request, context)
    
    131 131
     
    
    132
    -    assert len(response.leases) == number_of_jobs
    
    132
    +    assert len(response.leases) == min(number_of_jobs, 1)
    
    133 133
     
    
    134 134
     
    
    135 135
     def test_update_leases_with_work(bot_session, context, instance):
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]