Skip to content

Commit

Permalink
fix scaling bug. Fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen committed May 6, 2020
1 parent feab621 commit 6f1d0d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,14 @@ func (r *ReconcileGithubActionRunner) Reconcile(request reconcile.Request) (reco
}

func (r *ReconcileGithubActionRunner) scaleUp(amount int, instance *garov1alpha1.GithubActionRunner, reqLogger logr.Logger) (reconcile.Result, error) {
// Define a new Pod object
pod := newPodForCR(instance)
for i := 0; i < amount; i++ {
pod := newPodForCR(instance)

// Set GithubActionRunner instance as the owner and controller
if err := controllerutil.SetControllerReference(instance, pod, r.scheme); err != nil {
return reconcile.Result{}, err
}
if err := controllerutil.SetControllerReference(instance, pod, r.scheme); err != nil {
return reconcile.Result{}, err
}

reqLogger.Info("Creating a new Pod", "Pod.Namespace", pod.Namespace, "Pod.Name", pod.Name)
for i := 0; i < amount; i++ {
reqLogger.Info("Creating a new Pod", "Pod.Namespace", pod.Namespace, "Pod.Name", pod.Name)
err := r.client.Create(context.TODO(), pod)
if err != nil {
return reconcile.Result{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestGithubactionRunnerController(t *testing.T) {
},
Spec: v1alpha1.GithubActionRunnerSpec{
Organization: "someOrg",
MinRunners: 1,
MaxRunners: 1,
MinRunners: 2,
MaxRunners: 2,
PodSpec: v1.PodSpec{},
TokenRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Expand Down

0 comments on commit 6f1d0d3

Please sign in to comment.