Documentation
¶
Index ¶
- Constants
- Variables
- func CloneAndAddLabel(labels map[string]string, labelKey, labelValue string) map[string]string
- func CloneSelectorAndAddLabel(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector
- func ComputeHash(template interface{}) string
- func MatchSchedule(now time.Time, startTime, endTime time.Time, recurrenceRule RecurrenceRule) (*Period, *Period, error)
- type HorizontalRunnerAutoscalerGitHubWebhook
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) Handle(w http.ResponseWriter, r *http.Request)
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchCheckRunEvent(event *github.CheckRunEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchPullRequestEvent(event *github.PullRequestEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchPushEvent(event *github.PushEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) Reconcile(_ context.Context, request reconcile.Request) (reconcile.Result, error)
- func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) SetupWithManager(mgr ctrl.Manager) error
- type HorizontalRunnerAutoscalerReconciler
- type MultiGitHubClient
- func (c *MultiGitHubClient) DeinitForHRA(hra *v1alpha1.HorizontalRunnerAutoscaler)
- func (c *MultiGitHubClient) DeinitForRunner(r *v1alpha1.Runner)
- func (c *MultiGitHubClient) DeinitForRunnerPod(p *corev1.Pod)
- func (c *MultiGitHubClient) DeinitForRunnerSet(rs *v1alpha1.RunnerSet)
- func (c *MultiGitHubClient) InitForHRA(ctx context.Context, hra *v1alpha1.HorizontalRunnerAutoscaler) (*github.Client, error)
- func (c *MultiGitHubClient) InitForRunner(ctx context.Context, r *v1alpha1.Runner) (*github.Client, error)
- func (c *MultiGitHubClient) InitForRunnerPod(ctx context.Context, pod *corev1.Pod) (*github.Client, error)
- func (c *MultiGitHubClient) InitForRunnerSet(ctx context.Context, rs *v1alpha1.RunnerSet) (*github.Client, error)
- type Override
- type Period
- type PodRunnerTokenInjector
- type RecurrenceRule
- type RunnerDeploymentReconciler
- type RunnerPersistentVolumeClaimReconciler
- type RunnerPersistentVolumeReconciler
- type RunnerPodReconciler
- type RunnerReconciler
- type RunnerReplicaSetReconciler
- type RunnerSetReconciler
- type ScaleTarget
Constants ¶
const ( LabelKeyRunnerSetName = "runnerset-name" LabelKeyRunner = "actions-runner" )
const ( AnnotationKeyLastRegistrationCheckTime = "actions-runner-controller/last-registration-check-time" // AnnotationKeyUnregistrationFailureMessage is the annotation that is added onto the pod once it failed to be unregistered from GitHub due to e.g. 422 error AnnotationKeyUnregistrationFailureMessage = annotationKeyPrefix + "unregistration-failure-message" // AnnotationKeyUnregistrationCompleteTimestamp is the annotation that is added onto the pod once the previously started unregistration process has been completed. AnnotationKeyUnregistrationCompleteTimestamp = annotationKeyPrefix + "unregistration-complete-timestamp" // AnnotationKeyRunnerCompletionWaitStartTimestamp is the annotation that is added onto the pod when // ARC decided to wait until the pod to complete by itself, without the need for ARC to unregister the corresponding runner. AnnotationKeyRunnerCompletionWaitStartTimestamp = annotationKeyPrefix + "runner-completion-wait-start-timestamp" // unregistarionStartTimestamp is the annotation that contains the time that the requested unregistration process has been started AnnotationKeyUnregistrationStartTimestamp = annotationKeyPrefix + "unregistration-start-timestamp" // AnnotationKeyUnregistrationRequestTimestamp is the annotation that contains the time that the unregistration has been requested. // This doesn't immediately start the unregistration. Instead, ARC will first check if the runner has already been registered. // If not, ARC will hold on until the registration to complete first, and only after that it starts the unregistration process. // This is crucial to avoid a race between ARC marking the runner pod for deletion while the actions-runner registers itself to GitHub, leaving the assigned job // hang like forever. AnnotationKeyUnregistrationRequestTimestamp = annotationKeyPrefix + "unregistration-request-timestamp" AnnotationKeyRunnerID = annotationKeyPrefix + "id" // This can be any value but a larger value can make an unregistration timeout longer than configured in practice. DefaultUnregistrationRetryDelay = time.Minute // RetryDelayOnCreateRegistrationError is the delay between retry attempts for runner registration token creation. // Usually, a retry in this case happens when e.g. your PAT has no access to certain scope of runners, like you're using repository admin's token // for creating a broader scoped runner token, like organizationa or enterprise runner token. // Such permission issue will never fixed automatically, so we don't need to retry so often, hence this value. RetryDelayOnCreateRegistrationError = 3 * time.Minute // DefaultRunnerPodRecreationDelayAfterWebhookScale is the delay until syncing the runners with the desired replicas // after a webhook-based scale up. // This is used to prevent ARC from recreating completed runner pods that are deleted soon without being used at all. // In other words, this is used as a timer to wait for the completed runner to emit the next `workflow_job` webhook event to decrease the desired replicas. // So if we set 30 seconds for this, you are basically saying that you would assume GitHub and your installation of ARC to // emit and propagate a workflow_job completion event down to the RunnerSet or RunnerReplicaSet, vha ARC's github webhook server and HRA, in approximately 30 seconds. // In case it actually took more than DefaultRunnerPodRecreationDelayAfterWebhookScale for the workflow_job completion event to arrive, // ARC will recreate the completed runner(s), assuming something went wrong in either GitHub, your K8s cluster, or ARC, so ARC needs to resync anyway. // // See https://github.com/actions-runner-controller/actions-runner-controller/pull/1180 DefaultRunnerPodRecreationDelayAfterWebhookScale = 10 * time.Minute EnvVarRunnerName = "RUNNER_NAME" EnvVarRunnerToken = "RUNNER_TOKEN" )
const ( LabelKeyPodTemplateHash = "pod-template-hash" EnvVarOrg = "RUNNER_ORG" EnvVarRepo = "RUNNER_REPO" EnvVarGroup = "RUNNER_GROUP" EnvVarLabels = "RUNNER_LABELS" EnvVarEnterprise = "RUNNER_ENTERPRISE" EnvVarEphemeral = "RUNNER_EPHEMERAL" EnvVarTrue = "true" )
const ( LabelKeyRunnerTemplateHash = "runner-template-hash" LabelKeyRunnerDeploymentName = "runner-deployment-name" )
const (
AnnotationKeyTokenExpirationDate = "actions-runner-controller/token-expires-at"
)
const (
DefaultQueueLimit = 100
)
const (
DefaultScaleDownDelay = 10 * time.Minute
)
const (
SyncTimeAnnotationKey = "sync-time"
)
Variables ¶
var LabelKeyPodMutation = "actions-runner-controller/inject-registration-token"
var LabelValuePodMutation = "true"
Functions ¶
func CloneAndAddLabel ¶
Clones the given map and returns a new map with the given key and value added. Returns the given map, if labelKey is empty.
Proudly copied from k8s.io/kubernetes/pkg/util/labels.CloneAndAddLabel
func CloneSelectorAndAddLabel ¶
func CloneSelectorAndAddLabel(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector
Clones the given selector and returns a new selector with the given key and value added. Returns the given selector, if labelKey is empty.
Proudly copied from k8s.io/kubernetes/pkg/util/labels.CloneSelectorAndAddLabel
func ComputeHash ¶
func ComputeHash(template interface{}) string
ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.
Proudly modified and adopted from k8s.io/kubernetes/pkg/util/hash.DeepHashObject and k8s.io/kubernetes/pkg/controller.ComputeHash.
func MatchSchedule ¶
Types ¶
type HorizontalRunnerAutoscalerGitHubWebhook ¶
type HorizontalRunnerAutoscalerGitHubWebhook struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme // SecretKeyBytes is the byte representation of the Webhook secret token // the administrator is generated and specified in GitHub Web UI. SecretKeyBytes []byte // GitHub Client to discover runner groups assigned to a repository GitHubClient *github.Client // Namespace is the namespace to watch for HorizontalRunnerAutoscaler's to be // scaled on Webhook. // Set to empty for letting it watch for all namespaces. Namespace string Name string // QueueLimit is the maximum length of the bounded queue of scale targets and their associated operations // A scale target is enqueued on each retrieval of each eligible webhook event, so that it is processed asynchronously. QueueLimit int // contains filtered or unexported fields }
HorizontalRunnerAutoscalerGitHubWebhook autoscales a HorizontalRunnerAutoscaler and the RunnerDeployment on each GitHub Webhook received
func (*HorizontalRunnerAutoscalerGitHubWebhook) Handle ¶
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) Handle(w http.ResponseWriter, r *http.Request)
func (*HorizontalRunnerAutoscalerGitHubWebhook) MatchCheckRunEvent ¶
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchCheckRunEvent(event *github.CheckRunEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
func (*HorizontalRunnerAutoscalerGitHubWebhook) MatchPullRequestEvent ¶
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchPullRequestEvent(event *github.PullRequestEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
func (*HorizontalRunnerAutoscalerGitHubWebhook) MatchPushEvent ¶
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) MatchPushEvent(event *github.PushEvent) func(scaleUpTrigger v1alpha1.ScaleUpTrigger) bool
func (*HorizontalRunnerAutoscalerGitHubWebhook) SetupWithManager ¶
func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) SetupWithManager(mgr ctrl.Manager) error
type HorizontalRunnerAutoscalerReconciler ¶
type HorizontalRunnerAutoscalerReconciler struct { client.Client GitHubClient *MultiGitHubClient Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme DefaultScaleDownDelay time.Duration Name string }
HorizontalRunnerAutoscalerReconciler reconciles a HorizontalRunnerAutoscaler object
func (*HorizontalRunnerAutoscalerReconciler) SetupWithManager ¶
func (r *HorizontalRunnerAutoscalerReconciler) SetupWithManager(mgr ctrl.Manager) error
type MultiGitHubClient ¶ added in v0.26.0
type MultiGitHubClient struct {
// contains filtered or unexported fields
}
func NewMultiGitHubClient ¶ added in v0.26.0
func NewMultiGitHubClient(client resourceReader, githubClient *github.Client) *MultiGitHubClient
func (*MultiGitHubClient) DeinitForHRA ¶ added in v0.26.0
func (c *MultiGitHubClient) DeinitForHRA(hra *v1alpha1.HorizontalRunnerAutoscaler)
func (*MultiGitHubClient) DeinitForRunner ¶ added in v0.26.0
func (c *MultiGitHubClient) DeinitForRunner(r *v1alpha1.Runner)
func (*MultiGitHubClient) DeinitForRunnerPod ¶ added in v0.26.0
func (c *MultiGitHubClient) DeinitForRunnerPod(p *corev1.Pod)
func (*MultiGitHubClient) DeinitForRunnerSet ¶ added in v0.26.0
func (c *MultiGitHubClient) DeinitForRunnerSet(rs *v1alpha1.RunnerSet)
func (*MultiGitHubClient) InitForHRA ¶ added in v0.26.0
func (c *MultiGitHubClient) InitForHRA(ctx context.Context, hra *v1alpha1.HorizontalRunnerAutoscaler) (*github.Client, error)
Init sets up and return the *github.Client for the object. In case the object (like RunnerDeployment) does not request a custom client, it returns the default client.
func (*MultiGitHubClient) InitForRunner ¶ added in v0.26.0
func (c *MultiGitHubClient) InitForRunner(ctx context.Context, r *v1alpha1.Runner) (*github.Client, error)
Init sets up and return the *github.Client for the object. In case the object (like RunnerDeployment) does not request a custom client, it returns the default client.
func (*MultiGitHubClient) InitForRunnerPod ¶ added in v0.26.0
func (c *MultiGitHubClient) InitForRunnerPod(ctx context.Context, pod *corev1.Pod) (*github.Client, error)
Init sets up and return the *github.Client for the object. In case the object (like RunnerDeployment) does not request a custom client, it returns the default client.
func (*MultiGitHubClient) InitForRunnerSet ¶ added in v0.26.0
func (c *MultiGitHubClient) InitForRunnerSet(ctx context.Context, rs *v1alpha1.RunnerSet) (*github.Client, error)
Init sets up and return the *github.Client for the object. In case the object (like RunnerDeployment) does not request a custom client, it returns the default client.
type Override ¶
type Override struct { ScheduledOverride v1alpha1.ScheduledOverride Period Period }
type PodRunnerTokenInjector ¶
type PodRunnerTokenInjector struct { client.Client Name string Log logr.Logger Recorder record.EventRecorder GitHubClient *MultiGitHubClient // contains filtered or unexported fields }
func (*PodRunnerTokenInjector) InjectDecoder ¶
func (t *PodRunnerTokenInjector) InjectDecoder(d *admission.Decoder) error
func (*PodRunnerTokenInjector) SetupWithManager ¶
func (r *PodRunnerTokenInjector) SetupWithManager(mgr ctrl.Manager) error
type RecurrenceRule ¶
type RunnerDeploymentReconciler ¶
type RunnerDeploymentReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme CommonRunnerLabels []string Name string }
RunnerDeploymentReconciler reconciles a Runner object
func (*RunnerDeploymentReconciler) SetupWithManager ¶
func (r *RunnerDeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerPersistentVolumeClaimReconciler ¶ added in v0.24.0
type RunnerPersistentVolumeClaimReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme Name string }
RunnerPersistentVolumeClaimReconciler reconciles a PersistentVolume object
func (*RunnerPersistentVolumeClaimReconciler) SetupWithManager ¶ added in v0.24.0
func (r *RunnerPersistentVolumeClaimReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerPersistentVolumeReconciler ¶ added in v0.24.0
type RunnerPersistentVolumeReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme Name string }
RunnerPersistentVolumeReconciler reconciles a PersistentVolume object
func (*RunnerPersistentVolumeReconciler) SetupWithManager ¶ added in v0.24.0
func (r *RunnerPersistentVolumeReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerPodReconciler ¶
type RunnerPodReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme GitHubClient *MultiGitHubClient Name string RegistrationRecheckInterval time.Duration RegistrationRecheckJitter time.Duration UnregistrationRetryDelay time.Duration }
RunnerPodReconciler reconciles a Runner object
func (*RunnerPodReconciler) SetupWithManager ¶
func (r *RunnerPodReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerReconciler ¶
type RunnerReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme GitHubClient *MultiGitHubClient RunnerImage string RunnerImagePullSecrets []string DockerImage string DockerRegistryMirror string Name string RegistrationRecheckInterval time.Duration RegistrationRecheckJitter time.Duration UseRunnerStatusUpdateHook bool UnregistrationRetryDelay time.Duration }
RunnerReconciler reconciles a Runner object
func (*RunnerReconciler) SetupWithManager ¶
func (r *RunnerReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerReplicaSetReconciler ¶
type RunnerReplicaSetReconciler struct { client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme Name string }
RunnerReplicaSetReconciler reconciles a Runner object
func (*RunnerReplicaSetReconciler) SetupWithManager ¶
func (r *RunnerReplicaSetReconciler) SetupWithManager(mgr ctrl.Manager) error
type RunnerSetReconciler ¶
type RunnerSetReconciler struct { Name string client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme CommonRunnerLabels []string GitHubClient *MultiGitHubClient RunnerImage string RunnerImagePullSecrets []string DockerImage string DockerRegistryMirror string UseRunnerStatusUpdateHook bool }
RunnerSetReconciler reconciles a Runner object
func (*RunnerSetReconciler) SetupWithManager ¶
func (r *RunnerSetReconciler) SetupWithManager(mgr ctrl.Manager) error
type ScaleTarget ¶
type ScaleTarget struct { v1alpha1.HorizontalRunnerAutoscaler v1alpha1.ScaleUpTrigger // contains filtered or unexported fields }
Source Files
¶
- autoscaling.go
- constants.go
- horizontal_runner_autoscaler_batch_scale.go
- horizontal_runner_autoscaler_webhook.go
- horizontal_runner_autoscaler_webhook_on_check_run.go
- horizontal_runner_autoscaler_webhook_on_pull_request.go
- horizontal_runner_autoscaler_webhook_on_push.go
- horizontal_runner_autoscaler_webhook_worker.go
- horizontalrunnerautoscaler_controller.go
- multi_githubclient.go
- persistent_volume_claim_controller.go
- persistent_volume_controller.go
- pod_runner_token_injector.go
- runner_controller.go
- runner_graceful_stop.go
- runner_pod.go
- runner_pod_controller.go
- runner_pod_owner.go
- runnerdeployment_controller.go
- runnerreplicaset_controller.go
- runnerset_controller.go
- schedule.go
- sync_volumes.go
- testresourcereader.go
- utils.go