Skip to content

APIGOV-31191 validate cache#1015

Open
alrosca wants to merge 3 commits intomainfrom
APIGOV-31191
Open

APIGOV-31191 validate cache#1015
alrosca wants to merge 3 commits intomainfrom
APIGOV-31191

Conversation

@alrosca
Copy link
Collaborator

@alrosca alrosca commented Mar 10, 2026

Cache validation on start up and reconnect

jcollins-axway
jcollins-axway previously approved these changes Mar 11, 2026
Copy link
Collaborator

@jcollins-axway jcollins-axway left a comment

Choose a reason for hiding this comment

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

Looks good from a high level, needs pounded testing wise

@jcollins-axway
Copy link
Collaborator

copilots review

Code Review: APIGOV-31191 vs main

Summary

  • Scope: reviewed 8 files (314 insertions, 4 deletions), focused on new cache validation flow, reconnect hooks, and cache manager interfaces.
  • Verdict: request changes
  • Severity: medium (2), low (0), high (0), blocker (0)

Findings

  • Medium — Cache validation uses non-unique key (name) and can collide across scoped resources

  • Medium — Cache validator hard-codes API version to v1alpha1, which can skip/incorrectly query some filters

    • Where: pkg/agent/cachevalidationjob.go, pkg/agent/cachevalidationjob.go
    • Description: validation URL is built from a synthetic ResourceInstance with fixed APIVersion: "v1alpha1". For filters whose resource version differs, GetKindLink() may produce the wrong endpoint or empty link, and validation is skipped (return true).
    • Possible impacts to the codebase: out-of-sync persisted cache may pass validation and remain in use after startup/reconnect for affected resource kinds.

Positives

  • Cache validation logic is cleanly encapsulated (cacheValidator) and integrated into both startup and reconnect paths.
  • Reconnect hooks were added consistently to poll and stream clients with minimal API surface change (WithOnReconnect options).
  • Logging around validation failures includes useful operational context (resource counts, resource names, timestamps).

Recommendations

  • Use a stable unique key for comparisons (for example selfLink or a composite of group/kind/scope/name) instead of name alone.
  • Derive API version from filter/resource metadata or from server-discovered GVK mappings rather than hard-coding "v1alpha1".
  • Add targeted unit tests for: duplicate names across scopes, non-v1alpha1 resources, and reconnect-triggered validation behavior.

@alrosca alrosca closed this Mar 12, 2026
@alrosca alrosca reopened this Mar 12, 2026
@alrosca
Copy link
Collaborator Author

alrosca commented Mar 12, 2026

Not a bad review at all

// deleting state with success status - should NOT be cached
err := handler.Handle(NewEventContext(proto.Event_CREATED, nil, ri.Kind, ri.Name), nil, ri)
assert.Nil(t, err)
assert.Equal(t, []string{}, cm.GetAccessRequestCacheKeys())
Copy link
Collaborator

Choose a reason for hiding this comment

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

as we spoke of we prefer test cases over single tests

jcollins-axway
jcollins-axway previously approved these changes Mar 12, 2026
@jcollins-axway
Copy link
Collaborator

caching changes require an extra amount of testing as its usually to blame for our duplicate service issues

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