Cache full-eviction safeguard: fix every provider, then remove it
Context
SqlCache.mergeAll() (clouddriver/cats/cats-sql/.../SqlCache.kt:145) refuses to evict a type's last cached item unless the owning Provider implements ProviderCacheConfiguration with supportsFullEviction()=true. Investigating a real Kubernetes bug report (a deleted Deployment staying in the cache) found that every provider in this monorepo has this same latent bug — Kubernetes just happened to be the one someone hit and reported. KubernetesProvider (#8059) is the first and only provider that opts in today.
Rather than opt in provider-by-provider forever, the plan is: fix every provider that needs it, confirm each is safe, then delete ProviderCacheConfiguration and the guard entirely — full eviction just always happens, unconditionally, the way it should have from the start.
Each provider fix is a genuine, independent bug fix and will be backported to the active release branches (release-2026.1.x, release-2026.2.x) via @mergifyio backport <branches>. The final "remove the interface and the guard" PR is a main-only structural cleanup that depends on every other PR already being merged — it must never be backported (older release branches won't have every provider fixed yet).
Design decisions
- One provider, one branch, one PR — even for providers needing the identical one-line fix. No bundling.
- Two failure modes, two different fixes:
- Missing opt-in only (most providers):
CacheResultalready always includes every authoritative type's key, even with zero items. Needs only the one-linerimplements ProviderCacheConfiguration { override fun supportsFullEviction() = true }, same asKubernetesProvider.java. - Key can be silently omitted (Google, Yandex, HuaweiCloud):
CacheResult-building code can drop an authoritative type's key entirely when there's no live data that cycle (the original Kubernetes bug, before its backfill fix). These need a real code fix first, mirroringKubernetesCachingAgent.buildCacheResult()'s backfill pattern.
- Missing opt-in only (most providers):
- ECS and Lambda get code deleted, not added: both compute their own eviction diff by hand. Each agent is the sole authoritative writer for its type within its account+region shard, so
SqlCache's implicit per-agent diff (WHERE agent = ?) produces an identical result once the provider opts in — the manual diffing becomes pure redundant code. Delete it. - AWS/EC2 needs two opt-ins, not one:
AwsProviderandAwsInfrastructureProviderare two separate, unrelatedProviderclasses in the same module. Both need the interface. - Lambda depends on AWS/EC2's PR landing (and ideally backporting) first — it shares
AwsProviderbut never touches that file itself, so it's a functional dependency, not a merge-conflict one. - Titus is intentionally excluded —
TitusStreamingUpdateAgentalready computes its own eviction, with a code comment explaining why ("caches regionally so we can't authoritatively evict"). Deliberate architecture, not a bug. - Consul is excluded — no caching agents, not a cache-backed provider.
- DCOS and AliCloud are excluded — both
clouddriver-dcosandclouddriver-alicloudare commented out ofclouddriver/settings.gradle's provider map entirely (not gated behind a flag, just absent as map keys), so neither module compiles, tests, or ships in any current build. Discovered while starting the DCOS fix; dropped both rather than shipping unverifiable changes to dead code.
Roadmap
Priority order: Google → Group A opt-ins → Lambda (last).
- #8059 — Kubernetes (
fixK8sCacheSqlHandling) — opt-in + key backfill + RBAC-error guard — merged - #8061 — Google/GCE (
fixCacheEvictionGoogle) — opt-in + fix 16 call sites to use the existing (since ~2016, underused) safeCacheResultBuilderconstructor — merged - #8062 — Azure (
fixCacheEvictionAzure) — opt-in only — merged - #8063 — Oracle (
fixCacheEvictionOracle) — opt-in only — merged - #8064 — CloudFoundry (
fixCacheEvictionCloudFoundry) — opt-in only — merged - #8065 — AppEngine (
fixCacheEvictionAppengine) — opt-in only — merged - #8066 — CloudRun (
fixCacheEvictionCloudrun) — opt-in only — merged - #8067 — Docker registry (
fixCacheEvictionDockerRegistry) — opt-in only — merged - #8068 — Eureka (
fixCacheEvictionEureka) — opt-in only — merged -
DCOS— out of scope, not built (see above) -
AliCloud— out of scope, not built (see above) - #8069 — AWS/EC2 (
fixCacheEvictionAwsEc2) — opt-in on bothAwsProviderandAwsInfrastructureProvider, plus a small key-safety fix inAmazonInstanceTypeCachingAgent— merged - #8083 — Lambda (
fixCacheEvictionLambda) — depends on AWS/EC2 above (merged) — opt-in is free; deletes redundantcomputeEvictableData() - #8070 — Yandex (
fixCacheEvictionYandex) — opt-in + wire up a deadauthoritativeTypesfield in its sharedCacheResultBuilder— merged - #8071 — HuaweiCloud (
fixCacheEvictionHuaweiCloud) — opt-in + add a missing backfill capability to its sharedCacheResultBuilder— merged - #8072 — ECS (
fixCacheEvictionEcs) — opt-in + delete redundant eviction code across 6 agents.IamRoleCachingAgent's scoping risk resolved: it's instantiated once per account (not per region), so it's a safe sole authoritative writer — included in the cleanup. — merged - Final cleanup (
removeProviderCacheConfigurationGuard, main only, never backported) — deleteProviderCacheConfiguration, remove the guard inSqlCache.mergeAll(), delete every provider's now-pointless opt-in — blocked on #8083 (Lambda) merging
Per-provider fix details
Group A — opt-in only (done: Azure, Oracle, CloudFoundry, AppEngine, CloudRun, Docker registry, Eureka)
Each already builds its CacheResult correctly — every authoritative type's key is present unconditionally, whether or not there's live data that cycle. The fix is the same one-liner KubernetesProvider.java already has:
public class XProvider extends BaseProvider implements ProviderCacheConfiguration {
@Override
public boolean supportsFullEviction() {
return true;
}
}Each PR adds one small test mirroring KubernetesProviderTest.java.
AWS/EC2 (next)
Add the interface to both AwsProvider.groovy and AwsInfrastructureProvider.groovy. Ride along: fix AmazonInstanceTypeCachingAgent.java's early-return that omits its INSTANCE_TYPES.ns key when instanceTypesInfo is empty (low real-world impact, but same file family already being touched).
Lambda (depends on AWS/EC2)
Delete LambdaCachingAgent.computeEvictableData() and its call site in loadData(); drop the evictions arg from the returned DefaultCacheResult. No Provider change needed. Rewrite LambdaCachingAgentTest's shouldReturnEvictions/shouldNotEvictionNewData (they call computeEvictableData directly) to instead prove loadData() alone, through a real SqlProviderCache/SqlCache, evicts a deleted function.
Google/GCE — done in #8061
CacheResultBuilder.groovy has had a safe constructor (CacheResultBuilder(Collection<AgentDataType> dataTypes)) since ~2016 that backfills every authoritative key — only one of 16 call sites used it. 12 were one-line swaps; 4 used Groovy's implicit map-constructor to also set startTime and needed a small (dataTypes, startTime) overload added instead. GoogleInfrastructureProvider now opts in.
Yandex
CacheResultBuilder.java already has an authoritativeTypes field, populated but never read in build() — wire it in. Two agents affected on the main path (YandexServerGroupCachingAgent, YandexNetworkLoadBalancerCachingAgent); the other 5 are already key-safe. Add the interface to YandexInfrastructureProvider.java.
HuaweiCloud
CacheResultBuilder.java has no authoritativeTypes concept at all — add a constructor param, wire it into build(), update 5 call sites. HuaweiCloudInstanceTypeCachingAgent needs bespoke handling beyond the generic fix (it can return null from loadData() entirely, or skip cache-building, under empty-data conditions). Add the interface to HuaweiCloudInfrastructureProvider.java.
ECS
Delete AbstractEcsCachingAgent's computeEvictableData()/addExtraEvictions() default/eviction lines. Five agents don't extend the shared base class and each hand-roll their own separate copy of the same logic (EcsCloudMetricAlarmCachingAgent, ScalableTargetsCachingAgent, ServiceDiscoveryCachingAgent, SecretCachingAgent, IamRoleCachingAgent) — delete in each. TaskHealthCachingAgent overrides addExtraEvictions() to do genuine, non-redundant cross-namespace work — preserve/rework it, don't delete it.
Risk to resolve before merging: IamRoleCachingAgent may not satisfy the "one authoritative writer per agent" assumption — IAM role keys are account-scoped, not region-scoped, but the agent is instantiated per region. Confirm whether sibling regional instances actually write the same account-scoped keys under different agent names before deciding whether to include it in the cleanup or deliberately leave it on manual eviction (same precedent as Titus).
Final cleanup (main only, after everything else, never backported)
Delete ProviderCacheConfiguration, remove the guard in SqlCache.mergeAll(), delete every provider's now-pointless opt-in (including Kubernetes'). Flag explicitly in the PR: this deletes a public clouddriver-api class, a breaking change for any out-of-tree plugin/fork.
Verification
Per-PR: run that module's test suite, plus a new regression test proving the last live item of a type gets evicted. For the real-code-fix PRs (Google, Yandex, HuaweiCloud, ECS, Lambda), prefer a real end-to-end test against SqlProviderCache/SqlCache backed by a MySQL testcontainer, following KubernetesCachingAgentSqlIntegrationTest.java as the template. For the final cleanup PR, run the full clouddriver suite since it touches shared cats-sql/clouddriver-api code every provider depends on.
Tracking issue generated with Claude Code
Source: spinnaker/spinnaker