feat: set nodegroup and computezone on agent#200
Conversation
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds optional node metadata flags (--nodegroup, --compute-zone) to enrollment; builds nullable EnrollMetadata, normalizes and conditionally persists node metadata; propagates values into backend NodeUpsert requests and OTLP resource attributes; adds cleanup, validation, tests, and docs. ChangesNode Metadata Enrollment and System Integration
Sequence Diagram(s)sequenceDiagram
participant User as User
participant CLI as enrollCommand
participant EnrollFlow as EnrollWithConfigAndMetadata
participant StateDB as sqliteState (agent state)
participant Inventory as Backend Inventory Sink
participant Exporter as OTLP Exporter
User->>CLI: fleetint enroll --nodegroup=ng1 --compute-zone=us-west
CLI->>CLI: Build EnrollMetadata from flags
CLI->>EnrollFlow: EnrollWithConfigAndMetadata(metadata)
EnrollFlow->>EnrollFlow: Normalize optional fields (trim whitespace)
EnrollFlow->>StateDB: SetNodeGroup("ng1")
EnrollFlow->>StateDB: SetComputeZone("us-west")
StateDB->>StateDB: Persist to gpud_metadata table
Note over Inventory: Later during inventory export
Inventory->>StateDB: GetNodeGroup()
Inventory->>StateDB: GetComputeZone()
StateDB-->>Inventory: ("ng1", true, nil), ("us-west", true, nil)
Inventory->>Inventory: Populate NodeUpsertRequest fields
Inventory->>Inventory: Call UpsertNode with nodeGroup/computeZone
Note over Exporter: During metrics export
Exporter->>StateDB: GetNodeGroup()
Exporter->>StateDB: GetComputeZone()
StateDB-->>Exporter: Retrieved metadata values
Exporter->>Exporter: Populate HealthData fields
Exporter->>Exporter: Add OTLP resource attributes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/usage.md`:
- Line 143: The sentence listing stored metadata uses the human-friendly key
`compute-zone` but the persisted state uses `compute_zone`; update the sentence
to use the persisted key name so readers inspecting the metadata see the exact
key (replace `compute-zone` with `compute_zone` in the metadata list that
mentions `nodegroup`, `compute-zone`).
In `@internal/backendclient/types.go`:
- Around line 39-40: The NodeGroup and ComputeZone fields in the struct should
be changed from plain string to *string with `json:"...,omitempty"` to preserve
tri-state semantics (nil = unset, non-nil empty = explicit clear, non-nil
non-empty = value); update the struct declarations for NodeGroup and ComputeZone
to use *string and add omitempty, and modify the sink/constructors that populate
this type to assign pointers only when a value is actually present (create &str
or nil accordingly) so you don't accidentally overwrite backend metadata.
In `@internal/inventory/sink/backend.go`:
- Around line 105-109: The current code marshals and logs the full upsert
request using json.Marshal(req) and log.Logger.Infow("inventory node upsert
request", ...) which exposes sensitive machine metadata; change this to either
log a redacted version of req (create a shallow copy of req, clear or replace
sensitive fields such as machine ID, system UUID, private/private_ip, MAC
addresses, etc., then marshal that) or lower the log level to Debug (use
log.Logger.Debugw) so full payload is not emitted at info; keep the existing
warn-on-marshal-error behavior and ensure nodeUUID remains in the log for
correlation while the request body is redacted or debug-only.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e8082c7c-9b99-4e51-b014-54e4328b5f74
📒 Files selected for processing (20)
cmd/fleetint/enroll.gocmd/fleetint/enroll_test.gocmd/fleetint/root.gocmd/fleetint/unenroll.gocmd/fleetint/unenroll_test.godocs/usage.mdinternal/agentstate/sqlite.gointernal/agentstate/sqlite_test.gointernal/agentstate/state.gointernal/attestation/backend_test.gointernal/backendclient/types.gointernal/enrollment/enrollment.gointernal/enrollment/enrollment_test.gointernal/exporter/collector/collector.gointernal/exporter/converter/otlp.gointernal/exporter/converter/otlp_test.gointernal/exporter/exporter.gointernal/inventory/sink/backend.gointernal/inventory/sink/backend_test.gointernal/validation/outbound/validator.go
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6fce9fdd4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
mukilsh
left a comment
There was a problem hiding this comment.
LGTM but can we address this one comment? Then will approve
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Description
Checklist
Summary by CodeRabbit