Use lazy copy to patch resources to ensure multiple modifications are applied to the base resource#4580
Open
nikola-jokic wants to merge 32 commits into
Open
Use lazy copy to patch resources to ensure multiple modifications are applied to the base resource#4580nikola-jokic wants to merge 32 commits into
nikola-jokic wants to merge 32 commits into
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…hemeralRunnerSet and AutoscalingRunnerSet
…hemeralRunnerSet and AutoscalingRunnerSet
Contributor
|
Hello! Thank you for your contribution. Please review our contribution guidelines to understand the project's testing and code conventions. |
nikola-jokic
force-pushed
the
nikola-jokic/lazy-copy
branch
from
July 23, 2026 15:30
f43f84b to
ab1c70d
Compare
nikola-jokic
marked this pull request as ready for review
July 23, 2026 19:44
nikola-jokic
requested review from
mumoshu,
rentziass and
toast-gear
as code owners
July 23, 2026 19:44
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes how the controllers detect/propagate desired-state changes and how they compute patches, replacing integrity-hash annotations with explicit revision/generation tracking and adding a shared in-memory resource cache to avoid rebuilding identical desired objects.
Changes:
- Introduces a
ResourceCacheused byResourceBuilderto reuse desired objects based on a main-object key plus dependency refs. - Replaces integrity-hash–based update detection with
ActionableRevision/AppliedActionableRevisionforEphemeralRunnerSetandObservedGenerationforAutoscalingRunnerSet(and updates CRDs accordingly). - Refactors patch flows to use a lazy DeepCopy helper (
once) so multiple in-place mutations can be safely applied beforeclient.MergeFrom(...).
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| main.go | Instantiates and wires a shared ResourceCache into ResourceBuilder. |
| controllers/actions.github.com/utils.go | Adds once lazy-copy helper used to build correct MergeFrom patches. |
| controllers/actions.github.com/utils_test.go | Moves test-only random string helper into tests. |
| controllers/actions.github.com/resourcecache.go | Adds typed resource cache with dependency-key tracking and eviction by owner UID. |
| controllers/actions.github.com/resourcecache_test.go | Adds unit tests for cache semantics (dependency ordering, deletion, invalid inputs). |
| controllers/actions.github.com/resourcebuilder.go | Uses cache for desired-object reuse; removes integrity-hash annotations; refactors label/annotation merging. |
| controllers/actions.github.com/resourcebuilder_test.go | Updates tests for removed integrity-hash annotation; adds merge-map tests and cache expectations. |
| controllers/actions.github.com/helpers.go | Adds helper predicates for actionable revision and pod recreation decisions. |
| controllers/actions.github.com/ephemeralrunnerset_controller.go | Switches to actionable revision + status patching with conflict retries; refactors patching with lazy copies. |
| controllers/actions.github.com/ephemeralrunnerset_controller_test.go | Updates/extends integration tests for cache cleanup and actionable revision behavior. |
| controllers/actions.github.com/ephemeralrunner_controller.go | Refactors finalizer patching to use lazy-copy pattern; deletes cached entries on deletion. |
| controllers/actions.github.com/ephemeralrunner_controller_test.go | Extends tests to assert cache cleanup on runner deletion. |
| controllers/actions.github.com/autoscalingrunnerset_controller.go | Uses observed generation for Pending detection; switches spec-change handling to actionable revision; refactors patch logic. |
| controllers/actions.github.com/autoscalingrunnerset_controller_test.go | Updates tests to assert observed generation and actionable revision behavior; adds cache assertions. |
| controllers/actions.github.com/autoscalinglistener_controller.go | Refactors patching of dependent resources using lazy copies; updates pod recreation decision logic. |
| controllers/actions.github.com/autoscalinglistener_controller_test.go | Extends tests to assert resources are cached and evicted appropriately. |
| config/crd/bases/actions.github.com_ephemeralrunnersets.yaml | Adds actionableRevision, appliedActionableRevision, finishedRunnerCleanupPatchID schema fields. |
| config/crd/bases/actions.github.com_autoscalingrunnersets.yaml | Adds observedGeneration to status schema. |
| charts/gha-runner-scale-set-controller/crds/actions.github.com_ephemeralrunnersets.yaml | Mirrors ERS CRD schema additions into chart CRDs. |
| charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml | Mirrors ARS CRD schema additions into chart CRDs. |
| charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_ephemeralrunnersets.yaml | Mirrors ERS CRD schema additions into experimental chart CRDs. |
| charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml | Mirrors ARS CRD schema additions into experimental chart CRDs. |
| apis/actions.github.com/v1alpha1/version.go | Minor condition reordering in version allowance check. |
| apis/actions.github.com/v1alpha1/ephemeralrunnerset_types.go | Adds ActionableRevision spec field and applied/cleanup status fields. |
| apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go | Adds ObservedGeneration to status. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Based on #4575