Skip to content

Commit

Permalink
Add getProviderBaseParams function in basePoolManager
Browse files Browse the repository at this point in the history
  • Loading branch information
fabi200123 committed Sep 2, 2024
1 parent 7074f01 commit dcff6f9
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions runner/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ type basePoolManager struct {
keyMux *keyMutex
}

func (r *basePoolManager) getProviderBaseParams(pool params.Pool) common.ProviderBaseParams {
r.mux.Lock()
defer r.mux.Unlock()

return common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
}
}

func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
if err := r.ValidateOwner(job); err != nil {
return errors.Wrap(err, "validating owner")
Expand Down Expand Up @@ -591,10 +601,7 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
"pool_id", pool.ID)
listInstancesParams := common.ListInstancesParams{
ListInstancesV011: common.ListInstancesV011Params{
ProviderBaseParams: common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
},
ProviderBaseParams: r.getProviderBaseParams(pool),
},
}
poolInstances, err = provider.ListInstances(r.ctx, pool.ID, listInstancesParams)
Expand Down Expand Up @@ -664,10 +671,7 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)

startParams := common.StartParams{
StartV011: common.StartV011Params{
ProviderBaseParams: common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
},
ProviderBaseParams: r.getProviderBaseParams(pool),
},
}
if err := provider.Start(r.ctx, dbInstance.ProviderID, startParams); err != nil {
Expand Down Expand Up @@ -888,10 +892,7 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error
if instanceIDToDelete != "" {
deleteInstanceParams := common.DeleteInstanceParams{
DeleteInstanceV011: common.DeleteInstanceV011Params{
ProviderBaseParams: common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
},
ProviderBaseParams: r.getProviderBaseParams(pool),
},
}
if err := provider.DeleteInstance(r.ctx, instanceIDToDelete, deleteInstanceParams); err != nil {
Expand All @@ -906,10 +907,7 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error

createInstanceParams := common.CreateInstanceParams{
CreateInstanceV011: common.CreateInstanceV011Params{
ProviderBaseParams: common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
},
ProviderBaseParams: r.getProviderBaseParams(pool),
},
}
providerInstance, err := provider.CreateInstance(r.ctx, bootstrapArgs, createInstanceParams)
Expand Down Expand Up @@ -1350,10 +1348,7 @@ func (r *basePoolManager) deleteInstanceFromProvider(ctx context.Context, instan

deleteInstanceParams := common.DeleteInstanceParams{
DeleteInstanceV011: common.DeleteInstanceV011Params{
ProviderBaseParams: common.ProviderBaseParams{
PoolInfo: pool,
ControllerInfo: r.controllerInfo,
},
ProviderBaseParams: r.getProviderBaseParams(pool),
},
}
if err := provider.DeleteInstance(ctx, identifier, deleteInstanceParams); err != nil {
Expand Down

0 comments on commit dcff6f9

Please sign in to comment.