Cache jobs in pool manager
This change caches jobs meant for an entity in the pool manager. This allows us to avoid querying the db as much and allows us to better determine when we should scale down. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
0093393bc3
commit
a36d01afd5
13 changed files with 331 additions and 73 deletions
|
|
@ -183,25 +183,22 @@ func WithEntityJobFilter(ghEntity params.ForgeEntity) dbCommon.PayloadFilterFunc
|
|||
|
||||
switch ghEntity.EntityType {
|
||||
case params.ForgeEntityTypeRepository:
|
||||
if job.RepoID != nil && job.RepoID.String() != ghEntity.ID {
|
||||
return false
|
||||
if job.RepoID != nil && job.RepoID.String() == ghEntity.ID {
|
||||
return true
|
||||
}
|
||||
case params.ForgeEntityTypeOrganization:
|
||||
if job.OrgID != nil && job.OrgID.String() != ghEntity.ID {
|
||||
return false
|
||||
if job.OrgID != nil && job.OrgID.String() == ghEntity.ID {
|
||||
return true
|
||||
}
|
||||
case params.ForgeEntityTypeEnterprise:
|
||||
if job.EnterpriseID != nil && job.EnterpriseID.String() != ghEntity.ID {
|
||||
return false
|
||||
if job.EnterpriseID != nil && job.EnterpriseID.String() == ghEntity.ID {
|
||||
return true
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ func (s *WatcherStoreTestSuite) TestInstanceWatcher() {
|
|||
|
||||
createPoolParams := params.CreatePoolParams{
|
||||
ProviderName: "test-provider",
|
||||
MaxRunners: 5,
|
||||
Image: "test-image",
|
||||
Flavor: "test-flavor",
|
||||
OSType: commonParams.Linux,
|
||||
|
|
@ -393,6 +394,7 @@ func (s *WatcherStoreTestSuite) TestPoolWatcher() {
|
|||
|
||||
createPoolParams := params.CreatePoolParams{
|
||||
ProviderName: "test-provider",
|
||||
MaxRunners: 5,
|
||||
Image: "test-image",
|
||||
Flavor: "test-flavor",
|
||||
OSType: commonParams.Linux,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue