Skip to content

feat: add agent enroll time in inventory loop#188

Merged
ambermingxin merged 5 commits into
mainfrom
feat/add-agent-enroll-time
May 9, 2026
Merged

feat: add agent enroll time in inventory loop#188
ambermingxin merged 5 commits into
mainfrom
feat/add-agent-enroll-time

Conversation

@ambermingxin
Copy link
Copy Markdown
Collaborator

@ambermingxin ambermingxin commented May 6, 2026

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Enrollment timestamp is recorded at enrollment and included in device info sent to the backend.
  • Bug Fixes

    • Unenroll now also removes the stored enrollment timestamp from local state.
    • Enrollment-time retrieval errors no longer block exporting device info.
  • Tests

    • Expanded tests for enrollment-time persistence, propagation, cleanup, and error handling.
  • Chores

    • Bumped Go toolchain/version across CI, builds, and module metadata.

Review Change Stack

Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d6fc7ca3-c71a-4ac2-ba18-e40885cf41bb

📥 Commits

Reviewing files that changed from the base of the PR and between 05e2088 and 04e2d77.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • .golangci.yml
  • Dockerfile
  • Dockerfile.citests
  • docs/development.md
✅ Files skipped from review due to trivial changes (5)
  • .golangci.yml
  • docs/development.md
  • Dockerfile
  • Dockerfile.citests
  • .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

📝 Walkthrough

Walkthrough

Adds enrolled_at metadata support: State API and constant, sqlite persistence and tests, enrollment records UTC timestamp, inventory sink propagates EnrolledAt, unenroll cleans the key, and Go toolchain bumps.

Changes

Enrollment Time Tracking

Layer / File(s) Summary
Data Shape
internal/agentstate/state.go, internal/backendclient/types.go
New MetadataKeyEnrolledAt constant; State interface adds GetEnrollmentTime/SetEnrollmentTime. NodeUpsertRequest gains optional EnrolledAt *time.Time.
State Backend Implementation
internal/agentstate/sqlite.go
GetEnrollmentTime parses RFC3339Nano and returns UTC with presence flag; SetEnrollmentTime validates non-zero and stores RFC3339Nano (adds time import).
SQLite Tests
internal/agentstate/sqlite_test.go
Tests added/updated for round-trip persistence, missing-value behavior, and zero-time validation.
Enrollment Recording
internal/enrollment/enrollment.go, internal/enrollment/enrollment_test.go
EnrollWithConfig creates an enrolledAt UTC timestamp and storeConfigInMetadata now persists it; tests updated to pass timestamp.
Inventory Sink Integration
internal/inventory/sink/backend.go, internal/inventory/sink/backend_test.go
Export builds NodeUpsertRequest, reads enrollment time from state, sets EnrolledAt when present; tests validate propagation and that state errors don't fail Export.
Unenroll Cleanup
cmd/fleetint/unenroll.go
removeEnrollmentMetadata now deletes agentstate.MetadataKeyEnrolledAt.
Test Stubs
internal/attestation/backend_test.go
Test stub stubState implements GetEnrollmentTime/SetEnrollmentTime as no-op/zero responses.
CI / Go Toolchain
.github/workflows/*, go.mod, .golangci.yml, Dockerfile*, docs/development.md
Bump Go version to 1.26.3 in workflows and go.mod; update several indirect golang.org/x/* dependency versions; update golangci and Docker base images; docs updated.

Sequence Diagram

sequenceDiagram
    participant EnrollFlow as Enrollment Flow
    participant State as Agent State
    participant InventorySink as Inventory Sink
    participant Backend as Backend Client

    EnrollFlow->>State: SetEnrollmentTime(enrolledAt)
    State->>State: Store enrolledAt in metadata (RFC3339Nano)

    InventorySink->>State: GetEnrollmentTime()
    State-->>InventorySink: enrolledAt timestamp

    InventorySink->>InventorySink: Build NodeUpsertRequest with EnrolledAt
    InventorySink->>Backend: UpsertNode(request with EnrolledAt)
    Backend-->>InventorySink: Success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 I hopped to mark the moment neat,

when agents joined with pattering feet.
I tucked the time in metadata's keep,
sent it onward, then pruned it deep.
A tidy burrow, no secrets to keep.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add agent enroll time in inventory loop' accurately describes the main feature: adding enrollment time tracking to the agent and including it in the inventory sink's backend requests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-agent-enroll-time

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@ambermingxin ambermingxin requested a review from mukilsh May 6, 2026 16:27
Copy link
Copy Markdown
Contributor

@mukilsh mukilsh left a comment

Choose a reason for hiding this comment

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

LGTM, just take a look at that one comment

Comment thread internal/inventory/sink/backend.go
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
@ambermingxin ambermingxin merged commit 17425be into main May 9, 2026
6 checks passed
@ambermingxin ambermingxin deleted the feat/add-agent-enroll-time branch May 9, 2026 20:05
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