Fix balancer type validation

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-03-15 07:26:04 +00:00
parent b58555bc10
commit cdfda0321a
6 changed files with 12 additions and 9 deletions

View file

@ -49,9 +49,12 @@ const (
// balancer, the pool manager will attempt to create instances in each pool in turn
// for each job that needs to be serviced. So job1 in pool1, job2 in pool2 and so on.
PoolBalancerTypeRoundRobin PoolBalancerType = "roundrobin"
// PoolBalancerTypeStack will try to create instances in the first pool that matches
// PoolBalancerTypePack will try to create instances in the first pool that matches
// the required labels. If the pool is full, it will move on to the next pool and so on.
PoolBalancerTypeStack PoolBalancerType = "stack"
PoolBalancerTypePack PoolBalancerType = "pack"
// PoolBalancerTypeNone denotes to the default behavior of the pool manager, which is
// to use the round robin balancer.
PoolBalancerTypeNone PoolBalancerType = ""
)
const (

View file

@ -55,7 +55,7 @@ func (c *CreateRepoParams) Validate() error {
}
switch c.PoolBalancerType {
case PoolBalancerTypeRoundRobin, PoolBalancerTypeStack:
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack:
default:
return errors.NewBadRequestError("invalid pool balancer type")
}
@ -83,7 +83,7 @@ func (c *CreateOrgParams) Validate() error {
}
switch c.PoolBalancerType {
case PoolBalancerTypeRoundRobin, PoolBalancerTypeStack:
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack:
default:
return errors.NewBadRequestError("invalid pool balancer type")
}
@ -109,7 +109,7 @@ func (c *CreateEnterpriseParams) Validate() error {
}
switch c.PoolBalancerType {
case PoolBalancerTypeRoundRobin, PoolBalancerTypeStack:
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack:
default:
return errors.NewBadRequestError("invalid pool balancer type")
}

View file

@ -173,7 +173,7 @@ func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, para
}
switch param.PoolBalancerType {
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypeStack, param.PoolBalancerType:
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypePack, params.PoolBalancerTypeNone:
default:
return params.Enterprise{}, runnerErrors.NewBadRequestError("invalid pool balancer type: %s", param.PoolBalancerType)
}

View file

@ -202,7 +202,7 @@ func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param par
}
switch param.PoolBalancerType {
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypeStack, param.PoolBalancerType:
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypePack, params.PoolBalancerTypeNone:
default:
return params.Organization{}, runnerErrors.NewBadRequestError("invalid pool balancer type: %s", param.PoolBalancerType)
}

View file

@ -52,7 +52,7 @@ func (p *poolsForTags) Get(tags []string) (poolCacheStore, bool) {
return nil, false
}
poolCache := v.(*poolRoundRobin)
if p.poolCacheType == params.PoolBalancerTypeStack {
if p.poolCacheType == params.PoolBalancerTypePack {
// When we service a list of jobs, we want to try each pool in turn
// for each job. Pools are sorted by priority so we always start from the
// highest priority pool and move on to the next if the first one is full.

View file

@ -201,7 +201,7 @@ func (r *Runner) UpdateRepository(ctx context.Context, repoID string, param para
}
switch param.PoolBalancerType {
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypeStack, param.PoolBalancerType:
case params.PoolBalancerTypeRoundRobin, params.PoolBalancerTypePack, params.PoolBalancerTypeNone:
default:
return params.Repository{}, runnerErrors.NewBadRequestError("invalid pool balancer type: %s", param.PoolBalancerType)
}