Shutdown the scaleset when runner is deprecated#4404
Open
nikola-jokic wants to merge 1 commit intomasterfrom
Open
Shutdown the scaleset when runner is deprecated#4404nikola-jokic wants to merge 1 commit intomasterfrom
nikola-jokic wants to merge 1 commit intomasterfrom
Conversation
Contributor
|
Hello! Thank you for your contribution. Please review our contribution guidelines to understand the project's testing and code conventions. |
1911774 to
2e58744
Compare
89ac578 to
2a8056e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds “runner deprecation” handling so that when the runner exits with the version-deprecated signal (exit code 7, enabled via ACTIONS_RUNNER_RETURN_VERSION_DEPRECATED_EXIT_CODE=1), the controller marks the involved resources as Outdated and begins tearing down the scale set resources to clean up.
Changes:
- Inject
ACTIONS_RUNNER_RETURN_VERSION_DEPRECATED_EXIT_CODE=1into ephemeral runner pods and treat runner exit code7as “Outdated”. - Introduce
Phasefields and enums forEphemeralRunner,EphemeralRunnerSet, andAutoscalingRunnerSet, and propagate “Outdated” from runner → runnerset → autoscaling runnerset cleanup. - Update controllers/tests/CRDs to use the new status field names (
RunnerID,WorkflowRunID, etc.) and new phase types.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| controllers/actions.github.com/resourcebuilder.go | Adds deprecated-exit-code env var to ephemeral runner container. |
| controllers/actions.github.com/constants.go | Introduces env var constant for deprecated version exit-code behavior. |
| controllers/actions.github.com/ephemeralrunner_controller.go | Detects exit code 7, marks EphemeralRunner as Outdated, and removes it from the service. |
| controllers/actions.github.com/ephemeralrunner_controller_test.go | Updates tests to use EphemeralRunnerPhase and renamed status fields. |
| controllers/actions.github.com/ephemeralrunnerset_controller.go | Tracks Outdated runners, adds runnerset phase, and short-circuits reconciliation when Outdated. |
| controllers/actions.github.com/ephemeralrunnerset_controller_test.go | Updates tests for renamed status fields and new phase types/values. |
| controllers/actions.github.com/autoscalingrunnerset_controller.go | Detects outdated runnerset and triggers full scale set cleanup; adds change-hash annotation. |
| controllers/actions.github.com/autoscalingrunnerset_controller_test.go | Updates expected status to use Phase instead of State and formatting changes. |
| cmd/ghalistener/scaler/scaler.go | Updates patched EphemeralRunner status field names (JobRequestID, WorkflowRunID). |
| apis/actions.github.com/v1alpha1/ephemeralrunner_types.go | Renames status fields (e.g., RunnerID) and introduces EphemeralRunnerPhase including Outdated. |
| apis/actions.github.com/v1alpha1/ephemeralrunnerset_types.go | Adds EphemeralRunnerSetStatus.Phase and phase enum (Running/Outdated). |
| apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go | Replaces status State with Phase, adds phase enum, and adds Hash() helper. |
| config/crd/bases/actions.github.com_ephemeralrunnersets.yaml | Adds .status.phase to the EphemeralRunnerSet CRD schema. |
| config/crd/bases/actions.github.com_autoscalingrunnersets.yaml | Replaces .status.state with .status.phase in the AutoscalingRunnerSet CRD schema. |
| charts/gha-runner-scale-set-controller/crds/actions.github.com_ephemeralrunnersets.yaml | Mirrors EphemeralRunnerSet CRD schema update for Helm chart. |
| charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml | Mirrors AutoscalingRunnerSet CRD schema update for Helm chart. |
| charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_ephemeralrunnersets.yaml | Mirrors EphemeralRunnerSet CRD schema update for experimental chart. |
| charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml | Mirrors AutoscalingRunnerSet CRD schema update for experimental chart. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| case cs.State.Terminated.ExitCode == 7: // outdated | ||
| if err := r.markAsOutdated(ctx, ephemeralRunner, log); err != nil { | ||
| log.Error(err, "Failed to set ephemeral runner to phase Outdated") |
Comment on lines
+344
to
+350
| Phase AutoscalingRunnerSetPhase | ||
| } | ||
|
|
||
| d := &data{ | ||
| Spec: ars.Spec.DeepCopy(), | ||
| Labels: ars.Labels, | ||
| Phase: ars.Status.Phase, |
Comment on lines
+243
to
+246
| case ephemeralRunnerSet.Status.Phase == "": | ||
| phase = v1alpha1.EphemeralRunnerSetPhaseRunning | ||
| case len(state.outdated) > 0: | ||
| phase = v1alpha1.EphemeralRunnerSetPhaseOutdated |
| "finished", len(ephemeralRunnerState.finished), | ||
| "failed", len(ephemeralRunnerState.failed), | ||
| "deleting", len(ephemeralRunnerState.deleting), | ||
| "outdated", ephemeralRunnersByState.outdated, |
| if ephemeralRunnerSet.Status != desiredStatus { | ||
| log.Info("Updating status with current runners count", "count", total) | ||
| ephemeralRunnerSet := ephemeralRunnerSet.DeepCopy() | ||
| ephemeralRunnerSet.Status.CurrentReplicas = -1 // ALWAYS update current replicas |
| return ctrl.Result{}, nil | ||
| case 7: | ||
| if err := r.markAsOutdated(ctx, ephemeralRunner, log); err != nil { | ||
| log.Error(err, "Failed to set ephemeral runner to phase Outdated") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The runner PR exiting with exit code 7 when
ACTIONS_RUNNER_RETURN_VERSION_DEPRECATED_EXIT_CODE=1: actions/runner#4285This should propagate stops to the scaleset and set it to outdated, cleaning up resources.