buildgrid 0.2.52__py3-none-any.whl → 0.2.53__py3-none-any.whl

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.
@@ -1949,7 +1949,9 @@ class Scheduler:
1949
1949
  )
1950
1950
 
1951
1951
  @timed(METRIC.SCHEDULER.ASSIGNMENT_DURATION)
1952
- def _fetch_job_for_bot(self, session: Session, bot: BotEntry, log_tags: Tags) -> JobEntry | None:
1952
+ def _fetch_job_for_bot(
1953
+ self, session: Session, bot: BotEntry, usage_diffs: InstanceQuotaUsageDiffs, log_tags: Tags
1954
+ ) -> JobEntry | None:
1953
1955
  # Attempt to fetch a new job for a bot to work on.
1954
1956
  # This can help if there are usually more jobs available than bots.
1955
1957
 
@@ -1959,15 +1961,22 @@ class Scheduler:
1959
1961
  if bot.instance_name != "*":
1960
1962
  job_statement = job_statement.where(self._job_in_instance_pool())
1961
1963
 
1962
- # Prioritize instance where usage <= max_quota - bot.capacity
1963
- # `- bot.capacity` to avoid over-assigning jobs to bots when nearing quota limits
1964
- instances_query = select(InstanceQuota.instance_name).where(
1965
- InstanceQuota.bot_cohort == bot.cohort,
1966
- InstanceQuota.current_usage <= InstanceQuota.max_quota - bot.capacity,
1967
- )
1968
- instances = session.execute(instances_query).scalars().all()
1969
- if instances:
1970
- job_statement = job_statement.where(JobEntry.instance_name.in_(instances))
1964
+ if bot.cohort:
1965
+ # Prioritize instance where usage <= max_quota - bot.capacity
1966
+ # `- bot.capacity` to avoid over-assigning jobs to bots when nearing quota limits
1967
+ instances_query = select(InstanceQuota.instance_name).where(
1968
+ InstanceQuota.bot_cohort == bot.cohort,
1969
+ InstanceQuota.current_usage <= InstanceQuota.max_quota - bot.capacity,
1970
+ )
1971
+ instances: set[str] = set()
1972
+ instances.update(session.execute(instances_query).scalars().all())
1973
+ # Always allow scheduling more jobs of an instance if we're returning usage
1974
+ instances.update(
1975
+ {instance for (cohort, instance), diff in usage_diffs.items() if cohort == bot.cohort and diff < 0}
1976
+ )
1977
+
1978
+ if instances:
1979
+ job_statement = job_statement.where(JobEntry.instance_name.in_(instances))
1971
1980
 
1972
1981
  if next_job := session.execute(job_statement).scalar_one_or_none():
1973
1982
  log_tags["db.next_job_name"] = next_job.name
@@ -2321,7 +2330,7 @@ class Scheduler:
2321
2330
 
2322
2331
  for _ in range(fetch_limit):
2323
2332
  # Try to fill up the newly free capacity with new jobs.
2324
- if new_job := self._fetch_job_for_bot(session, bot, log_tags):
2333
+ if new_job := self._fetch_job_for_bot(session, bot, usage_diffs, log_tags):
2325
2334
  if bot.cohort:
2326
2335
  usage_diffs[(bot.cohort, new_job.instance_name)] += 1
2327
2336
  synchronized_leases.append(new_job.to_lease_proto())
@@ -13,4 +13,4 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- __version__ = "0.2.52"
16
+ __version__ = "0.2.53"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildgrid
3
- Version: 0.2.52
3
+ Version: 0.2.53
4
4
  Summary: A remote execution service
5
5
  License: Apache License, Version 2.0
6
6
  Project-URL: Homepage, https://buildgrid.build
@@ -208,7 +208,7 @@ buildgrid/server/servicer.py,sha256=oqU9MaSxxHTDmSxobFTo9YmJctaUCklE2Dj-vfYWKkc,
208
208
  buildgrid/server/settings.py,sha256=Iy4eS9Putr5GroIVqYNeTcRY7gbvq29wgQoMDQgPJtA,5604
209
209
  buildgrid/server/threading.py,sha256=4QKQYev2KoO2Q-S_OyaoR9qpWyDTVzGMWVe9o2a1yIU,4743
210
210
  buildgrid/server/types.py,sha256=xG3bx64pbWMuEwXLuI0o8c2unt2rU2C4zsmUfmMT12c,1323
211
- buildgrid/server/version.py,sha256=n2RBFSFcPdtiRMdJG5gZUeScD96hl-zdswg8rwRhQmU,604
211
+ buildgrid/server/version.py,sha256=zv7pfyNMnfQiih7uFjY-_UFi2yhATpDRA43o8Nz28fo,604
212
212
  buildgrid/server/actioncache/__init__.py,sha256=g9lb8Sn7NY5KOjkMr9GQoJovCVDEg_Fxz_EhdDbhP1I,579
213
213
  buildgrid/server/actioncache/instance.py,sha256=UCR7ZGkv4fJOXjeIILMAdTSFWcGgBSYlBg8fMaPJpaI,3139
214
214
  buildgrid/server/actioncache/service.py,sha256=WcikJAzFYOYX-tgiOfGGcOnPoubrCd4yP-EhKCHEW0c,2021
@@ -334,7 +334,7 @@ buildgrid/server/scheduler/__init__.py,sha256=arCg8LWFATeX1tj-s0keVYP8p3wwrrUlCV
334
334
  buildgrid/server/scheduler/assigner.py,sha256=wHPAhyiQxYABZJXaUc2g5yFzM78Z0U5nvGV3X9h5pCM,10512
335
335
  buildgrid/server/scheduler/cohorts.py,sha256=L_5YZRiVOwPPGStfqnnQXknO5Ja-SC0vq0xjw4XgP-I,1426
336
336
  buildgrid/server/scheduler/events.py,sha256=cM7Z7Htr2pYKhltJxfg1YRo0q524yZaGm8yXvRehivk,1453
337
- buildgrid/server/scheduler/impl.py,sha256=q8U92yEbdFqzOYNrIGn9d4J8bCBCCIGPy4ZGg5YpOvM,137141
337
+ buildgrid/server/scheduler/impl.py,sha256=MR3Hp0hxuYTpFu0hnriin2GcY1xgri_HAok4EaeToow,137584
338
338
  buildgrid/server/scheduler/notifier.py,sha256=uypoIXZowpAIsDQ728VCuFJ4MN2zJld1npnanCWHTrw,8854
339
339
  buildgrid/server/scheduler/properties.py,sha256=2GydX8KUy9MFv1_JznIkGfWE_wOS0m_XapSv6Gp4pCM,11260
340
340
  buildgrid/server/sql/__init__.py,sha256=zbeeRP9BEeDzR-Mx2Ip6SUr49J8eeXsuREgljJTrHkk,579
@@ -368,9 +368,9 @@ buildgrid/server/utils/async_lru_cache.py,sha256=iLKeRPoZtZb1wC5AtcyQm8Wt0Bx-KZm
368
368
  buildgrid/server/utils/bots.py,sha256=c8hn7tbCecru-m2wicRmtKU5v5rSZPGlk97Yc6eUHgQ,1729
369
369
  buildgrid/server/utils/cancellation.py,sha256=pNETzKNoXg0AsXOXKCcLWlFl7SVKdkKinlqWl7MesRA,1703
370
370
  buildgrid/server/utils/digests.py,sha256=YNrWeHdbNp7OVTcsInjs30C33z_t9GQ_noMd14bpqPQ,2424
371
- buildgrid-0.2.52.dist-info/licenses/LICENSE,sha256=swa3Vs7GgALaG9p-e05M-WLkhd_U9QknacNkyVZ85xA,11338
372
- buildgrid-0.2.52.dist-info/METADATA,sha256=w-UPonoGIo3xi-h7rqGWp-4focQ-2iax4Q6H18iXIEs,7040
373
- buildgrid-0.2.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
374
- buildgrid-0.2.52.dist-info/entry_points.txt,sha256=uyFAXiR9d6EDfSA5vWT8xskz6xalt4PdTuRruT6Q8rk,49
375
- buildgrid-0.2.52.dist-info/top_level.txt,sha256=T6TYhI_k6NTm2871tIxGCyBIqzlKxylgF9KDLU0Hi7o,10
376
- buildgrid-0.2.52.dist-info/RECORD,,
371
+ buildgrid-0.2.53.dist-info/licenses/LICENSE,sha256=swa3Vs7GgALaG9p-e05M-WLkhd_U9QknacNkyVZ85xA,11338
372
+ buildgrid-0.2.53.dist-info/METADATA,sha256=U9a7b52eyU6pWfE8PIMYE-Rl4TvhbC9d_Po0MEHnXG4,7040
373
+ buildgrid-0.2.53.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
374
+ buildgrid-0.2.53.dist-info/entry_points.txt,sha256=uyFAXiR9d6EDfSA5vWT8xskz6xalt4PdTuRruT6Q8rk,49
375
+ buildgrid-0.2.53.dist-info/top_level.txt,sha256=T6TYhI_k6NTm2871tIxGCyBIqzlKxylgF9KDLU0Hi7o,10
376
+ buildgrid-0.2.53.dist-info/RECORD,,