Skip to content

Comments

Update the cache semantics.#39

Merged
kommendorkapten merged 1 commit intomainfrom
cache-upd
Feb 17, 2026
Merged

Update the cache semantics.#39
kommendorkapten merged 1 commit intomainfrom
cache-upd

Conversation

@kommendorkapten
Copy link
Member

The current logic is wrong. If the controller is restarted, deployments that happened before it started will never be deleted. This PR changes the logic to only check for existing entries to prevent duplicate calls, not require an entry to actually trigger a delete operation.

The current logic is wrong. If the controller is restarted, deployments
that happened before it started will never be deleted. This PR changes
the logic to only check for existing entries to prevent duplicate calls,
not require an entry to actually trigger a delete operation.
@kommendorkapten kommendorkapten requested a review from a team as a code owner February 17, 2026 09:52
Copilot AI review requested due to automatic review settings February 17, 2026 09:52
@kommendorkapten kommendorkapten changed the title Update the chace semantics. Update the cache semantics. Feb 17, 2026
Copy link

Copilot AI left a comment

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 fixes a critical bug in the deployment tracking cache logic. Previously, if the controller restarted, deployments that existed before the restart would never be decommissioned because the cache checked if a deployment was present before allowing decommission operations.

Changes:

  • Replace sync.Map with Kubernetes' Expiring cache from k8s.io/apimachinery/pkg/util/cache with a 2-minute TTL
  • Change cache keys to include the event type (CREATED/DELETED) to track create and delete operations separately
  • Invert the StatusDecommissioned logic to only skip if we've already posted a delete (not skip if deployment is not in cache)
  • Move golang.org/x/time and github.com/bradleyfalzon/ghinstallation/v2 from indirect to direct dependencies in go.mod

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/controller/controller.go Fixed cache semantics to allow decommission after controller restart; switched to TTL-based cache with separate keys for create/delete events
go.mod Moved directly-imported dependencies from indirect to direct section
go.sum Updated checksums to remove old version of golang.org/x/time

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@piceri piceri left a comment

Choose a reason for hiding this comment

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

👍

@kommendorkapten kommendorkapten merged commit b0add68 into main Feb 17, 2026
12 checks passed
@kommendorkapten kommendorkapten deleted the cache-upd branch February 17, 2026 15:22
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