Skip to content

Commit b981eb2

Browse files
authored
Add structured reporting diff to VMwareEngineExternalAddress (#6706)
### BRIEF Change description Fixes #6623 #### WHY do we need this change? Add structured reporting diff to the controller in `pkg/controller/direct/vmwareengine/externaladdress_controller.go`. The `structuredreporting.ReportDiff` should be used in the `Update` method of the adapter to report which fields are being updated. This helps in debugging reconciliation loops and provides better visibility into what changed. #### Special notes for your reviewer: #### Does this PR add something which needs to be 'release noted'? ```release-note NONE ``` #### Additional documentation e.g., references, usage docs, etc.: ```docs NONE ``` #### Intended Milestone - [ ] Reviewer tagged PR with the actual milestone. ### Tests you have done - [ ] Run `make ready-pr` to ensure this PR is ready for review. - [ ] Perform necessary E2E testing for changed resources.
2 parents ff9eee0 + 43139d8 commit b981eb2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/controller/direct/vmwareengine/externaladdress_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct"
3737
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase"
3838
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry"
39+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/structuredreporting"
3940
)
4041

4142
func init() {
@@ -160,12 +161,16 @@ func (a *externalAddressAdapter) Update(ctx context.Context, updateOp *directbas
160161
return mapCtx.Err()
161162
}
162163

164+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
165+
163166
paths := []string{}
164167
// UpdateMask for ExternalAddress allows updating description and internal_ip
165168
if desired.Spec.Description != nil && !reflect.DeepEqual(resource.Description, a.actual.Description) {
169+
report.AddField("description", a.actual.Description, resource.Description)
166170
paths = append(paths, "description")
167171
}
168172
if desired.Spec.InternalIP != nil && !reflect.DeepEqual(resource.InternalIp, a.actual.InternalIp) {
173+
report.AddField("internal_ip", a.actual.InternalIp, resource.InternalIp)
169174
paths = append(paths, "internal_ip")
170175
}
171176

@@ -174,6 +179,7 @@ func (a *externalAddressAdapter) Update(ctx context.Context, updateOp *directbas
174179
log.V(2).Info("no field needs update", "name", a.id)
175180
updated = a.actual
176181
} else {
182+
structuredreporting.ReportDiff(ctx, report)
177183
resource.Name = a.id.String() // we need to set the name so that GCP API can identify the resource
178184
req := &pb.UpdateExternalAddressRequest{
179185
ExternalAddress: resource,

0 commit comments

Comments
 (0)