refac: Update Satellite to use generated GC Client - #615
Conversation
Signed-off-by: vg006 <devvg006@gmail.com>
Signed-off-by: vg006 <devvg006@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe PR updates Ground Control status metric types, replaces manual registration and reporting HTTP calls with generated client operations, standardizes typed response errors, and reuses generated cached-image and status request models. ChangesGround Control client migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels: Sequence Diagram(s)sequenceDiagram
participant Satellite
participant GroundControlClient
participant GroundControlAPI
Satellite->>GroundControlClient: ZTRRequest or SatelliteStatusRequest
GroundControlClient->>GroundControlAPI: ZtrWithResponse, SpiffeZtrWithResponse, or SyncSatelliteWithResponse
GroundControlAPI-->>GroundControlClient: typed success or error response
GroundControlClient-->>Satellite: StateConfig, status result, or structured error
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 medium |
🟢 Metrics 22 complexity · 13 duplication
Metric Results Complexity 22 Duplication 13
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
spec/ground-control/openapi.yaml (1)
2318-2322: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAdd a non-negative constraint for
last_sync_duration_ms.The schema accepts negative integers. The generated Go field is
uint64. Addminimum: 0so OpenAPI clients and validators use the same contract.🤖 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 `@spec/ground-control/openapi.yaml` around lines 2318 - 2322, Update the last_sync_duration_ms schema property to add a minimum value of 0, aligning OpenAPI validation with its uint64 x-go-type and preventing negative durations.
🤖 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 `@internal/groundcontrol/server/helpers.go`:
- Around line 366-368: Update the request handling flow after DecodeRequestBody
and before artifact or status inserts to reject any of the three uint64 fields
exceeding math.MaxInt64. Return the existing appropriate validation error
response without converting or persisting invalid values, while keeping
toNullUInt64 unchanged for in-range values.
In `@internal/satellite/state/registration_process.go`:
- Around line 244-255: Update the TLS configuration branch in the registration
client to also execute when tlsCfg.SkipVerify is true, even if CertFile and
CAFile are empty. Preserve the existing satTLS.LoadClientTLSConfig call and
validation behavior, including ValidateAndEnforceDefaults handling incomplete
certificate/key pairs.
In `@internal/satellite/state/report_test.go`:
- Around line 23-25: Update TestCollectStatusReportParams_UnreachableRegistry to
use int32(0) as the expected value in the assertion comparing against
req.ImageCount, preserving the existing unreachable-registry test behavior.
In `@internal/satellite/state/reporting_process.go`:
- Around line 148-159: Move the UseUnsecure/groundControlURL HTTPS validation
from the non-SPIFFE else branch to execute before the s.spiffeClient branch.
When UseUnsecure is false, reject any Ground Control URL that does not use HTTPS
before selecting either the SPIFFE or TLS client, while preserving the existing
client setup and error message.
---
Outside diff comments:
In `@spec/ground-control/openapi.yaml`:
- Around line 2318-2322: Update the last_sync_duration_ms schema property to add
a minimum value of 0, aligning OpenAPI validation with its uint64 x-go-type and
preventing negative durations.
🪄 Autofix
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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f2711430-7c04-4106-b026-1884e762dd00
📒 Files selected for processing (14)
internal/groundcontrol/server/helpers.gointernal/groundcontrol/server/satellite_handlers.gointernal/groundcontrol/server/server.gen.gointernal/satellite/state/catalog.gointernal/satellite/state/helpers.gointernal/satellite/state/registration_process.gointernal/satellite/state/registration_process_test.gointernal/satellite/state/report.gointernal/satellite/state/report_test.gointernal/satellite/state/reporting_process.gointernal/satellite/state/reporting_process_test.gointernal/satellite/state/spiffe_registration.gopkg/groundcontrol/client.gen.gospec/ground-control/openapi.yaml
There was a problem hiding this comment.
1 issue found across 14 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pkg/groundcontrol/client.gen.go">
<violation number="1" location="pkg/groundcontrol/client.gen.go:423">
P2: Status reports can persist corrupted negative byte/duration metrics when a value above `math.MaxInt64` is sent, because this model now accepts the full `uint64` range while Ground Control stores it in signed `BIGINT` fields. Keeping the request range within `int64` or rejecting oversized values before the `toNullUInt64` conversion would preserve the API and database contract.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| CPUPercent float64 `json:"cpu_percent,omitempty,omitzero"` | ||
| ImageCount int32 `json:"image_count,omitempty,omitzero"` | ||
| LastSyncDurationMs int64 `json:"last_sync_duration_ms,omitempty,omitzero"` | ||
| LastSyncDurationMs uint64 `json:"last_sync_duration_ms,omitempty,omitzero"` |
There was a problem hiding this comment.
P2: Status reports can persist corrupted negative byte/duration metrics when a value above math.MaxInt64 is sent, because this model now accepts the full uint64 range while Ground Control stores it in signed BIGINT fields. Keeping the request range within int64 or rejecting oversized values before the toNullUInt64 conversion would preserve the API and database contract.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/groundcontrol/client.gen.go, line 423:
<comment>Status reports can persist corrupted negative byte/duration metrics when a value above `math.MaxInt64` is sent, because this model now accepts the full `uint64` range while Ground Control stores it in signed `BIGINT` fields. Keeping the request range within `int64` or rejecting oversized values before the `toNullUInt64` conversion would preserve the API and database contract.</comment>
<file context>
@@ -420,14 +420,14 @@ type SatelliteStatusRequest struct {
CPUPercent float64 `json:"cpu_percent,omitempty,omitzero"`
ImageCount int32 `json:"image_count,omitempty,omitzero"`
- LastSyncDurationMs int64 `json:"last_sync_duration_ms,omitempty,omitzero"`
+ LastSyncDurationMs uint64 `json:"last_sync_duration_ms,omitempty,omitzero"`
LatestConfigDigest string `json:"latest_config_digest,omitempty,omitzero"`
LatestStateDigest string `json:"latest_state_digest,omitempty,omitzero"`
</file context>
Signed-off-by: vg006 <devvg006@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
=======================================
Coverage ? 20.75%
=======================================
Files ? 131
Lines ? 14131
Branches ? 0
=======================================
Hits ? 2933
Misses ? 10924
Partials ? 274
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
This PR updates the
satellitepackage to use the generated Ground Control package inpkg/groundcontrolto communicate with it. This will enable type-safe and type-aware request-response model for Satellite and GC.Summary by CodeRabbit