diff --git a/runner/pool/pool.go b/runner/pool/pool.go index a66bacf8..3fe1eb3e 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -96,7 +96,7 @@ type urls struct { } func NewEntityPoolManager(ctx context.Context, entity params.GithubEntity, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { - ctx = garmUtil.WithContext(ctx, slog.Any("pool_mgr", entity), slog.Any("pool_type", params.GithubEntityTypeRepository)) + ctx = garmUtil.WithContext(ctx, slog.Any("pool_mgr", entity.String()), slog.Any("pool_type", params.GithubEntityTypeRepository)) ghc, err := garmUtil.GithubClient(ctx, entity, cfgInternal.GithubCredentialsDetails) if err != nil { return nil, errors.Wrap(err, "getting github client") diff --git a/util/util.go b/util/util.go index 27d674ef..a75be33f 100644 --- a/util/util.go +++ b/util/util.go @@ -320,7 +320,7 @@ func (g *githubClient) getOrganizationRunnerGroupIDByName(ctx context.Context, e } opts.Page = ghResp.NextPage } - return 0, runnerErrors.NewNotFoundError("runner group not found") + return 0, runnerErrors.NewNotFoundError("runner group %s not found", rgName) } func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, entity params.GithubEntity, rgName string) (int64, error) { @@ -360,19 +360,21 @@ func (g *githubClient) getEnterpriseRunnerGroupIDByName(ctx context.Context, ent } func (g *githubClient) GetEntityJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) { - var rgID int64 + // If no runner group is set, use the default runner group ID. This is also the default for + // repository level runners. + var rgID int64 = 1 - switch g.entity.EntityType { - case params.GithubEntityTypeRepository: - rgID = 1 - case params.GithubEntityTypeOrganization: - rgID, err = g.getOrganizationRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup) - case params.GithubEntityTypeEnterprise: - rgID, err = g.getEnterpriseRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup) - } + if pool.GitHubRunnerGroup != "" { + switch g.entity.EntityType { + case params.GithubEntityTypeOrganization: + rgID, err = g.getOrganizationRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup) + case params.GithubEntityTypeEnterprise: + rgID, err = g.getEnterpriseRunnerGroupIDByName(ctx, g.entity, pool.GitHubRunnerGroup) + } - if err != nil { - return nil, nil, fmt.Errorf("getting runner group ID: %w", err) + if err != nil { + return nil, nil, fmt.Errorf("getting runner group ID: %w", err) + } } req := github.GenerateJITConfigRequest{