Skip to content

TrackedResourceRecord.FirstSeen is reset on every normal update #5

Closed

Description

@fatkobra

The normal OnUpdate path appears to overwrite TrackedResourceRecord.FirstSeen with time.Now() instead of preserving the original first-seen timestamp.

I am not sure that this is consistent with the drift-recovery path in OnAdd, which explicitly preserves the original value with FirstSeen: existing.FirstSeen.

Let me try and explain why this is important
FirstSeen should represent when the resource was first observed, while LastSeen should move forward as updates happen. Resetting FirstSeen on every update makes the metadata inaccurate.

Current behavior
In resourceEventHandler.OnUpdate:
FirstSeen: now, LastSeen: now,

Expected behavior
Let's say the tracked resource already exists, OnUpdate should preserve existing.FirstSeen and only update LastSeen. If no record exists yet, then it can stay to now.

Suggested fix
In OnUpdate, have something like:
firstSeen := now if existing != nil && !existing.FirstSeen.IsZero() { firstSeen = existing.FirstSeen }

and then use FirstSeen: firstSeen in the inserted or updated record.

Activity

  1. fatkobra commented on Apr 20, 2026

    @fatkobra
    ContributorAuthor

    I have a fix for in resource_watcher.go plus a regression test for OnUpdate so FirstSeen is preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions