Skip to content

Force refresh should refresh existing CRD schemas, not only missing ones #75

@ndenev

Description

@ndenev

Summary

refresh_tables / force discovery currently refreshes CRD inventory but not existing CRD schemas. Cached schemas for existing (group,version,kind) entries are reused, so schema changes can remain stale indefinitely.

Affected code

  • Force path entry: src/kubernetes/client.rs (refresh_tables, discover_resources_for_context)
  • Force CRD path: src/kubernetes/client.rs (discover_all_crds)
  • Cache split: check_crds usage in force mode
  • Schema cache TTL: src/kubernetes/cache.rs (SCHEMA_CACHE_TTL = None)

Root cause

In force mode, discover_all_crds still does:

  1. check_crds(all_crds)
  2. loads cached_resources
  3. rediscovers only missing_crds

So existing CRDs are not re-parsed from live CRD definitions.

Why this matters

  • CRD schema updates (new/changed custom fields) are not picked up by force refresh unless cache is manually cleared.
  • This violates expected semantics of a force refresh and can cause stale table schemas.

Proposed fix

  1. In force mode, refresh schemas for all CRDs found in the cluster (not only missing ones).
  2. Overwrite cache entries with newly discovered schemas.
  3. Keep non-force path optimized with cache reuse.

Optional enhancement

  • Consider finite SCHEMA_CACHE_TTL for normal mode, but force should still be unconditional schema refresh.

Tests to add

  1. Seed cache with schema A, simulate cluster schema B for same GVK, force refresh -> registry/cache should use B.
  2. Non-force path still uses cache when valid.
  3. Regression test for refresh_tables() reflecting CRD field changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions