Skip to content

fix: allow user to only set one field for ng or cz#211

Merged
jingxiang-z merged 3 commits into
mainfrom
feat/auto-assign-ng-cz
May 28, 2026
Merged

fix: allow user to only set one field for ng or cz#211
jingxiang-z merged 3 commits into
mainfrom
feat/auto-assign-ng-cz

Conversation

@ambermingxin
Copy link
Copy Markdown
Collaborator

@ambermingxin ambermingxin commented May 28, 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 now lets node group and compute zone be set, cleared, or omitted independently via CLI flags and Helm values.
    • Helm chart exposes optional enrollment fields for node group and compute zone with clear/omit semantics.
  • Bug Fixes

    • Messaging and persisted metadata naming for node group were standardized for consistent storage and logs.

Review Change Stack

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

coderabbitai Bot commented May 28, 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: 3e4fb8d7-7281-410b-bbda-a5c006444dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba94bf and eea1aba.

📒 Files selected for processing (1)
  • deployments/helm/fleet-intelligence-agent/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • deployments/helm/fleet-intelligence-agent/values.yaml

📝 Walkthrough

Walkthrough

The PR removes the constraint that --node-group and --compute-zone must be provided together, exposes both as optional Helm enroll values, renames the persisted metadata key to node_group (and updates messages/logs), and updates tests to verify independent flag behavior and DB persistence.

Changes

Remove reserved pair validation for enrollment flags

Layer / File(s) Summary
Remove paired validation logic from enrollCommand
cmd/fleetint/enroll.go
Removed the call and helper validateReservedPairMetadata, allowing --node-group and --compute-zone to be resolved independently when building enrollment.EnrollMetadata.
Update tests for independent flag behavior
cmd/fleetint/enroll_test.go
Added TestValidatedOptionalMetadataFlagValueSupportsIndependentReservedUpdates, a table-driven test that asserts independent nil/empty/non-empty handling for node-group and compute-zone; removed old reserved-pair tests.
Add Helm values for optional enrollment metadata
deployments/helm/fleet-intelligence-agent/values.yaml
Added enroll.nodeGroup and enroll.computeZone keys (default empty) so these fields can be set/cleared via Helm.
Normalize metadata key and update tests/logs/messages
internal/agentstate/state.go, internal/agentstate/sqlite_test.go, internal/enrollment/enrollment.go, internal/exporter/exporter.go, internal/inventory/sink/backend.go
Changed metadata key constant to node_group, updated related error/debug/warning strings, and extended SQLite test to read node_group from the DB.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jingxiang-z
  • mukilsh

Poem

🐰 Flags untangled, hopping free,
Node and zone now choose their plea.
Helm and tests sing soft and bright,
DB keys tuned to read aright.
A rabbit cheers the gentle spree.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references abbreviations 'ng' and 'cz' that are not immediately clear without context, and could be confusing to someone scanning PR history unfamiliar with internal project terminology. Consider using the full names 'node-group' and 'compute-zone' instead of abbreviations for better clarity and discoverability in PR history.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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/auto-assign-ng-cz

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5819fff0b

ℹ️ 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".

Comment thread deployments/helm/fleet-intelligence-agent/values.yaml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/fleetint/enroll_test.go (1)

343-418: ⚡ Quick win

Consider adding a test case for both flags cleared.

The test comprehensively covers independent updates, but could include a case where both flags are explicitly set to empty strings to demonstrate that clearing both fields independently is supported.

📝 Suggested additional test case
 		{
 			name:              "clear node-group and omit compute-zone",
 			nodeGroupArg:      strPtr(""),
 			computeZoneArg:    nil,
 			expectNodeGroup:   strPtr(""),
 			expectComputeZone: nil,
 		},
+		{
+			name:              "clear both node-group and compute-zone",
+			nodeGroupArg:      strPtr(""),
+			computeZoneArg:    strPtr(""),
+			expectNodeGroup:   strPtr(""),
+			expectComputeZone: strPtr(""),
+		},
 	}
🤖 Prompt for 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.

In `@cmd/fleetint/enroll_test.go` around lines 343 - 418, Add a test variant to
TestValidatedOptionalMetadataFlagValueSupportsIndependentReservedUpdates that
covers the scenario where both "node-group" and "compute-zone" flags are
explicitly set to empty strings; in the test setup for this case call
flagSet.Set("node-group", "") and flagSet.Set("compute-zone", ""), then assert
that validatedOptionalMetadataFlagValue(cliContext, "node-group", "Node group")
and validatedOptionalMetadataFlagValue(cliContext, "compute-zone", "Compute
zone") both return pointers to empty strings (expectNodeGroup and
expectComputeZone should be strPtr("")). Ensure the new case is added to the
tests slice alongside the other cases so it runs with the existing t.Run loop.
🤖 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.

Nitpick comments:
In `@cmd/fleetint/enroll_test.go`:
- Around line 343-418: Add a test variant to
TestValidatedOptionalMetadataFlagValueSupportsIndependentReservedUpdates that
covers the scenario where both "node-group" and "compute-zone" flags are
explicitly set to empty strings; in the test setup for this case call
flagSet.Set("node-group", "") and flagSet.Set("compute-zone", ""), then assert
that validatedOptionalMetadataFlagValue(cliContext, "node-group", "Node group")
and validatedOptionalMetadataFlagValue(cliContext, "compute-zone", "Compute
zone") both return pointers to empty strings (expectNodeGroup and
expectComputeZone should be strPtr("")). Ensure the new case is added to the
tests slice alongside the other cases so it runs with the existing t.Run loop.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 37c335b8-350b-41b7-b933-acb523e05331

📥 Commits

Reviewing files that changed from the base of the PR and between eacd9a4 and e5819ff.

📒 Files selected for processing (3)
  • cmd/fleetint/enroll.go
  • cmd/fleetint/enroll_test.go
  • deployments/helm/fleet-intelligence-agent/values.yaml
💤 Files with no reviewable changes (1)
  • cmd/fleetint/enroll.go

Copy link
Copy Markdown
Collaborator

@jingxiang-z jingxiang-z left a comment

Choose a reason for hiding this comment

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

@ambermingxin You can add your metadata key underscore change in the PR also.

@jingxiang-z jingxiang-z changed the title feat: allow user to only set one field for ng or cz fix: allow user to only set one field for ng or cz May 28, 2026
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/agentstate/sqlite_test.go (1)

93-93: ⚡ Quick win

Prefer the package constant for consistency.

Using the hardcoded string "node_group" instead of the existing MetadataKeyNodeGroup constant creates a maintenance risk. If the constant value changes, this test could pass while verifying the wrong key.

♻️ Refactor to use the constant
-	value, err = pkgmetadata.ReadMetadata(ctx, db, "node_group")
+	value, err = pkgmetadata.ReadMetadata(ctx, db, MetadataKeyNodeGroup)
🤖 Prompt for 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.

In `@internal/agentstate/sqlite_test.go` at line 93, The test calls
pkgmetadata.ReadMetadata with a hardcoded key string "node_group" which risks
divergence from the canonical constant; update the call to use the package
constant MetadataKeyNodeGroup instead so the test always targets the same key as
application code (i.e., replace the literal "node_group" passed to
pkgmetadata.ReadMetadata with MetadataKeyNodeGroup).
🤖 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.

Nitpick comments:
In `@internal/agentstate/sqlite_test.go`:
- Line 93: The test calls pkgmetadata.ReadMetadata with a hardcoded key string
"node_group" which risks divergence from the canonical constant; update the call
to use the package constant MetadataKeyNodeGroup instead so the test always
targets the same key as application code (i.e., replace the literal "node_group"
passed to pkgmetadata.ReadMetadata with MetadataKeyNodeGroup).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 13b404bc-bd14-40f1-9b77-5ac20b0397ba

📥 Commits

Reviewing files that changed from the base of the PR and between e5819ff and 0ba94bf.

📒 Files selected for processing (5)
  • internal/agentstate/sqlite_test.go
  • internal/agentstate/state.go
  • internal/enrollment/enrollment.go
  • internal/exporter/exporter.go
  • internal/inventory/sink/backend.go
✅ Files skipped from review due to trivial changes (4)
  • internal/agentstate/state.go
  • internal/inventory/sink/backend.go
  • internal/exporter/exporter.go
  • internal/enrollment/enrollment.go

Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@jingxiang-z jingxiang-z merged commit fd3575b into main May 28, 2026
9 checks passed
@jingxiang-z jingxiang-z deleted the feat/auto-assign-ng-cz branch May 28, 2026 23:18
jingxiang-z added a commit that referenced this pull request May 28, 2026
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Signed-off-by: Jingxiang Zhang <jingzhang@nvidia.com>
Co-authored-by: ambermingxin <ambermingxin@nvidia.com>
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