Skip to content

Commit 3c7e2fe

Browse files
authored
Add structured reporting diff to ComputeNetworkEdgeSecurityService (#6756)
### BRIEF Change description Fixes #6558 #### WHY do we need this change? Add structured reporting diff to the controller in `pkg/controller/direct/compute/networkedgesecurityservice_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 b0139e5 + d183b01 commit 3c7e2fe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controller/direct/compute/networkedgesecurityservice_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct"
3636
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase"
3737
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry"
38+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/structuredreporting"
3839
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3940
"k8s.io/apimachinery/pkg/runtime"
4041
"k8s.io/klog/v2"
@@ -197,11 +198,15 @@ func (a *NetworkEdgeSecurityServiceAdapter) Update(ctx context.Context, updateOp
197198
// An up-to-date fingerprint must be provided in order to patch
198199
resource.Fingerprint = a.actual.Fingerprint
199200

201+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
202+
200203
var paths []string
201204
if !reflect.DeepEqual(resource.SecurityPolicy, a.actual.SecurityPolicy) {
205+
report.AddField("security_policy", a.actual.SecurityPolicy, resource.SecurityPolicy)
202206
paths = append(paths, "security_policy")
203207
}
204208
if !reflect.DeepEqual(resource.Description, a.actual.Description) {
209+
report.AddField("description", a.actual.Description, resource.Description)
205210
paths = append(paths, "description")
206211
}
207212

@@ -215,6 +220,8 @@ func (a *NetworkEdgeSecurityServiceAdapter) Update(ctx context.Context, updateOp
215220
return updateOp.UpdateStatus(ctx, status, nil)
216221
}
217222

223+
structuredreporting.ReportDiff(ctx, report)
224+
218225
// updateMask is a comma-separated list of fully qualified names of fields.
219226
sort.Strings(paths)
220227
updateMask := strings.Join(paths, ",")

0 commit comments

Comments
 (0)