Attempt to use the scalset API and caching
On github, attempt to use the scaleset API to list all runners without pagination. This will avoid missing runners and accidentally removing them. Fall back to paginated API if we can't use the scaleset API. Add ability to retrieve all instances from cache, for an entity. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
5c703f310b
commit
d05df36868
8 changed files with 333 additions and 209 deletions
20
cache/instance_cache.go
vendored
20
cache/instance_cache.go
vendored
|
|
@ -98,6 +98,22 @@ func (i *InstanceCache) GetInstancesForScaleSet(scaleSetID uint) []params.Instan
|
|||
return filteredInstances
|
||||
}
|
||||
|
||||
func (i *InstanceCache) GetEntityInstances(entityID string) []params.Instance {
|
||||
pools := GetEntityPools(entityID)
|
||||
poolsAsMap := map[string]bool{}
|
||||
for _, pool := range pools {
|
||||
poolsAsMap[pool.ID] = true
|
||||
}
|
||||
|
||||
ret := []params.Instance{}
|
||||
for _, val := range i.GetAllInstances() {
|
||||
if _, ok := poolsAsMap[val.PoolID]; ok {
|
||||
ret = append(ret, val)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func SetInstanceCache(instance params.Instance) {
|
||||
instanceCache.SetInstance(instance)
|
||||
}
|
||||
|
|
@ -121,3 +137,7 @@ func GetInstancesForPool(poolID string) []params.Instance {
|
|||
func GetInstancesForScaleSet(scaleSetID uint) []params.Instance {
|
||||
return instanceCache.GetInstancesForScaleSet(scaleSetID)
|
||||
}
|
||||
|
||||
func GetEntityInstances(entityID string) []params.Instance {
|
||||
return instanceCache.GetEntityInstances(entityID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue