Skip to content

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
masterfrom
nikola-jokic/lazy-copy
Open

Use lazy copy to patch resources to ensure multiple modifications are applied to the base resource#4580
nikola-jokic wants to merge 32 commits into
masterfrom
nikola-jokic/lazy-copy

Conversation

@nikola-jokic

@nikola-jokic nikola-jokic commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Based on #4575

@github-actions

Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution.

Please review our contribution guidelines to understand the project's testing and code conventions.

@nikola-jokic
nikola-jokic force-pushed the nikola-jokic/lazy-copy branch from f43f84b to ab1c70d Compare July 23, 2026 15:30
@nikola-jokic
nikola-jokic marked this pull request as ready for review July 23, 2026 19:44
Copilot AI review requested due to automatic review settings July 23, 2026 19:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ResourceCache used by ResourceBuilder to reuse desired objects based on a main-object key plus dependency refs.
  • Replaces integrity-hash–based update detection with ActionableRevision/AppliedActionableRevision for EphemeralRunnerSet and ObservedGeneration for AutoscalingRunnerSet (and updates CRDs accordingly).
  • Refactors patch flows to use a lazy DeepCopy helper (once) so multiple in-place mutations can be safely applied before client.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.

Comment thread controllers/actions.github.com/autoscalingrunnerset_controller.go Outdated
Comment thread controllers/actions.github.com/autoscalinglistener_controller.go Outdated
Comment thread controllers/actions.github.com/utils.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants