Skip to content

Commit

Permalink
Add missing commit. Only consider running pods when scaling down. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen committed Aug 20, 2020
1 parent 4c12cfe commit ca7f719
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/githubactionrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (r GithubActionRunnerSpec) GetReconciliationPeriod() time.Duration {

// GithubActionRunnerStatus defines the observed state of GithubActionRunner
type GithubActionRunnerStatus struct {
// the current size of the build pool
CurrentSize int `json:"currentSize"`
}

Expand Down
14 changes: 12 additions & 2 deletions controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,28 @@ func (r *GithubActionRunnerReconciler) Reconcile(req ctrl.Request) (ctrl.Result,
err = r.Client.Delete(context.TODO(), &pod, &client.DeleteOptions{})
if err == nil {
instance.Status.CurrentSize--
err = r.Status().Update(context.TODO(), instance)
r.Recorder.Event(instance, corev1.EventTypeNormal, "Scaling", fmt.Sprintf("Deleted pod %s/%s", pod.Namespace, pod.Name))
}
return result, err
break
}
}

defer r.Status().Update(context.TODO(), instance)
return result, err
}

return result, err
}

func (r *GithubActionRunnerReconciler) SetupWithManager(mgr ctrl.Manager) error {
// create an index for pod status since we filter on it
if err := mgr.GetFieldIndexer().IndexField(context.TODO(), &corev1.Pod{}, "status.phase", func(rawObj runtime.Object) []string {
pod := rawObj.(*corev1.Pod)
return []string{string(pod.Status.Phase)}
}); err != nil {
return err
}

return ctrl.NewControllerManagedBy(mgr).
For(&garov1alpha1.GithubActionRunner{}).
Complete(r)
Expand Down

0 comments on commit ca7f719

Please sign in to comment.