From 65f7ee92a63ecfa3d2cc08efd4d65ee051790d1e Mon Sep 17 00:00:00 2001 From: Callum Tait <15716903+toast-gear@users.noreply.github.com> Date: Mon, 16 May 2022 03:23:39 +0100 Subject: [PATCH] refactor: remove registration runner dead code (#1260) We had some dead code left over from the removal of registration runners. Registration runners were removed in #859 #1207 Co-authored-by: Yusuke Kuoka --- controllers/new_runner_pod_test.go | 2 +- controllers/runner_controller.go | 17 ++--------------- controllers/runnerreplicaset_controller.go | 4 ---- controllers/runnerset_controller.go | 2 +- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/controllers/new_runner_pod_test.go b/controllers/new_runner_pod_test.go index e70ac509..e98f11a5 100644 --- a/controllers/new_runner_pod_test.go +++ b/controllers/new_runner_pod_test.go @@ -404,7 +404,7 @@ func TestNewRunnerPod(t *testing.T) { for i := range testcases { tc := testcases[i] t.Run(tc.description, func(t *testing.T) { - got, err := newRunnerPod("runner", tc.template, tc.config, defaultRunnerImage, defaultRunnerImagePullSecrets, defaultDockerImage, defaultDockerRegistryMirror, githubBaseURL, false) + got, err := newRunnerPod("runner", tc.template, tc.config, defaultRunnerImage, defaultRunnerImagePullSecrets, defaultDockerImage, defaultDockerRegistryMirror, githubBaseURL) require.NoError(t, err) require.Equal(t, tc.want, got) }) diff --git a/controllers/runner_controller.go b/controllers/runner_controller.go index 9c2c466c..440811a6 100644 --- a/controllers/runner_controller.go +++ b/controllers/runner_controller.go @@ -47,9 +47,6 @@ const ( retryDelayOnGitHubAPIRateLimitError = 30 * time.Second - // This is an annotation internal to actions-runner-controller and can change in backward-incompatible ways - annotationKeyRegistrationOnly = "actions-runner-controller/registration-only" - EnvVarOrg = "RUNNER_ORG" EnvVarRepo = "RUNNER_REPO" EnvVarEnterprise = "RUNNER_ENTERPRISE" @@ -415,9 +412,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) { template.Spec.SecurityContext = runner.Spec.SecurityContext template.Spec.EnableServiceLinks = runner.Spec.EnableServiceLinks - registrationOnly := metav1.HasAnnotation(runner.ObjectMeta, annotationKeyRegistrationOnly) - - pod, err := newRunnerPod(runner.Name, template, runner.Spec.RunnerConfig, r.RunnerImage, r.RunnerImagePullSecrets, r.DockerImage, r.DockerRegistryMirror, r.GitHubClient.GithubBaseURL, registrationOnly) + pod, err := newRunnerPod(runner.Name, template, runner.Spec.RunnerConfig, r.RunnerImage, r.RunnerImagePullSecrets, r.DockerImage, r.DockerRegistryMirror, r.GitHubClient.GithubBaseURL) if err != nil { return pod, err } @@ -531,7 +526,7 @@ func mutatePod(pod *corev1.Pod, token string) *corev1.Pod { return updated } -func newRunnerPod(runnerName string, template corev1.Pod, runnerSpec v1alpha1.RunnerConfig, defaultRunnerImage string, defaultRunnerImagePullSecrets []string, defaultDockerImage, defaultDockerRegistryMirror string, githubBaseURL string, registrationOnly bool) (corev1.Pod, error) { +func newRunnerPod(runnerName string, template corev1.Pod, runnerSpec v1alpha1.RunnerConfig, defaultRunnerImage string, defaultRunnerImagePullSecrets []string, defaultDockerImage, defaultDockerRegistryMirror string, githubBaseURL string) (corev1.Pod, error) { var ( privileged bool = true dockerdInRunner bool = runnerSpec.DockerdWithinRunnerContainer != nil && *runnerSpec.DockerdWithinRunnerContainer @@ -603,14 +598,6 @@ func newRunnerPod(runnerName string, template corev1.Pod, runnerSpec v1alpha1.Ru }, } - if registrationOnly { - env = append(env, corev1.EnvVar{ - Name: "RUNNER_REGISTRATION_ONLY", - Value: "true", - }, - ) - } - var seLinuxOptions *corev1.SELinuxOptions if template.Spec.SecurityContext != nil { seLinuxOptions = template.Spec.SecurityContext.SELinuxOptions diff --git a/controllers/runnerreplicaset_controller.go b/controllers/runnerreplicaset_controller.go index 6ceb559b..1a3d838b 100644 --- a/controllers/runnerreplicaset_controller.go +++ b/controllers/runnerreplicaset_controller.go @@ -205,7 +205,3 @@ func (r *RunnerReplicaSetReconciler) SetupWithManager(mgr ctrl.Manager) error { Named(name). Complete(r) } - -func registrationOnlyRunnerNameFor(rsName string) string { - return rsName + "-registration-only" -} diff --git a/controllers/runnerset_controller.go b/controllers/runnerset_controller.go index 01d37c2c..2cb64c46 100644 --- a/controllers/runnerset_controller.go +++ b/controllers/runnerset_controller.go @@ -197,7 +197,7 @@ func (r *RunnerSetReconciler) newStatefulSet(runnerSet *v1alpha1.RunnerSet) (*ap Spec: runnerSetWithOverrides.StatefulSetSpec.Template.Spec, } - pod, err := newRunnerPod(runnerSet.Name, template, runnerSet.Spec.RunnerConfig, r.RunnerImage, r.RunnerImagePullSecrets, r.DockerImage, r.DockerRegistryMirror, r.GitHubBaseURL, false) + pod, err := newRunnerPod(runnerSet.Name, template, runnerSet.Spec.RunnerConfig, r.RunnerImage, r.RunnerImagePullSecrets, r.DockerImage, r.DockerRegistryMirror, r.GitHubBaseURL) if err != nil { return nil, err }