Open
Conversation
e00fa29 to
dc4cd63
Compare
dc4cd63 to
efbe9b2
Compare
0a01c07 to
fac22fe
Compare
bruelea
reviewed
Mar 27, 2026
Collaborator
bruelea
left a comment
There was a problem hiding this comment.
The review is focused on the ip address controller, since the structure of the controllers are aligned the comments apply to all 3 controllers.
Thanks for adding extensive testing!
Co-authored-by: bruelea <166021996+bruelea@users.noreply.github.com>
e5e8100 to
d6491e9
Compare
d6491e9 to
db6ff95
Compare
bruelea
reviewed
Mar 31, 2026
Co-authored-by: bruelea <166021996+bruelea@users.noreply.github.com>
Co-authored-by: bruelea <166021996+bruelea@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces unnecessary NetBox reconcile updates by tracking status.lastUpdated for IpAddress, IpRange, and Prefix, and by skipping update calls when the NetBox last_updated timestamp and the CR Ready condition’s ObservedGeneration indicate everything is already in sync.
Changes:
- Add
Status.LastUpdatedtoIpAddress,IpRange, andPrefixCRDs/types and propagate NetBoxLastUpdatedinto status from controllers. - Introduce
utils.IsUpToDateand use it in NetBox API clients to skip update operations whenLastUpdated+Readycondition + generation match. - Refactor Prefix API v3/v4 request building and add/extend unit + controller tests for the new behavior.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/netbox/utils/helpers.go | Adds IsUpToDate helper used to decide whether to skip updates. |
| pkg/netbox/api/prefix.go | Updates Prefix reserve/update logic to return (resp, isUpToDate, err) and skip updates when up to date; refactors v3/v4 request building usage. |
| pkg/netbox/api/prefix_v4.go | Extracts v4 writable request builder + v4 create/update helpers. |
| pkg/netbox/api/prefix_v4_test.go | Adds tests for writablePrefixRequestV4. |
| pkg/netbox/api/prefix_v3.go | Adjusts v3 prefix client return signature and adds v3 writable request builder. |
| pkg/netbox/api/prefix_v3_test.go | Adds tests for v3 writable prefix request builder and updated signature. |
| pkg/netbox/api/prefix_test.go | Extends Prefix composite-client tests for up-to-date skipping behavior and LastUpdated. |
| pkg/netbox/api/ip_range.go | Updates IP range reserve/update logic to return (resp, isUpToDate, err) and skip updates when up to date. |
| pkg/netbox/api/ip_range_test.go | Extends IP range tests for up-to-date skipping and LastUpdated. |
| pkg/netbox/api/ip_address.go | Updates IP address reserve/update logic to return (resp, isUpToDate, err) and skip updates when up to date; uses NetBox LastUpdated. |
| pkg/netbox/api/ip_address_test.go | Extends IP address tests for up-to-date skipping and LastUpdated. |
| internal/controller/prefix_controller.go | Skips status updates when NetBox object is already up to date; persists status.lastUpdated. |
| internal/controller/iprange_controller.go | Skips status updates when up to date; persists status.lastUpdated. |
| internal/controller/ipaddress_controller.go | Skips status updates when up to date; persists status.lastUpdated. |
| internal/controller/ipaddress_controller_test.go | Adds a controller test case for “skip update when already up to date”. |
| internal/controller/netbox_testdata_test.go | Adds stable NetBox LastUpdated test data and an “up to date” CR helper. |
| config/crd/bases/netbox.dev_prefixes.yaml | Adds status.lastUpdated field to Prefix CRD schema. |
| config/crd/bases/netbox.dev_ipranges.yaml | Adds status.lastUpdated field to IpRange CRD schema. |
| config/crd/bases/netbox.dev_ipaddresses.yaml | Adds status.lastUpdated field to IpAddress CRD schema. |
| api/v1/prefix_types.go | Adds LastUpdated *metav1.Time to PrefixStatus. |
| api/v1/iprange_types.go | Adds LastUpdated *metav1.Time to IpRangeStatus. |
| api/v1/ipaddress_types.go | Adds LastUpdated *metav1.Time to IpAddressStatus. |
| api/v1/zz_generated.deepcopy.go | Updates deep-copy logic for new LastUpdated fields. |
| Makefile | Uses $(GOBIN)/ginkgo for integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Summary from CoPilot)
This PR reduces unnecessary NetBox reconcile updates by tracking status.lastUpdated for IpAddress, IpRange, and Prefix, and by skipping update calls when the NetBox last_updated timestamp and the CR Ready condition’s ObservedGeneration indicate everything is already in sync.
Changes: