Skip to content

Commit d7324a5

Browse files
authored
Add structured reporting diff to WorkstationCluster (#6700)
### BRIEF Change description Fixes #6630 #### WHY do we need this change? Add structured reporting diff to the controller in `pkg/controller/direct/workstations/cluster_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 a848629 + 91937a0 commit d7324a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controller/direct/workstations/cluster_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase"
2727
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry"
2828
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/fuzztesting"
29+
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/structuredreporting"
2930

3031
gcp "cloud.google.com/go/workstations/apiv1"
3132
pb "cloud.google.com/go/workstations/apiv1/workstationspb"
@@ -251,18 +252,24 @@ func (a *Adapter) Update(ctx context.Context, updateOp *directbase.UpdateOperati
251252
}
252253
resource.Name = a.id.FullyQualifiedName()
253254

255+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
256+
254257
updateMask := &fieldmaskpb.FieldMask{}
255258
if !reflect.DeepEqual(resource.Annotations, a.actual.Annotations) {
259+
report.AddField("annotations", a.actual.Annotations, resource.Annotations)
256260
updateMask.Paths = append(updateMask.Paths, "annotations")
257261
}
258262
if !reflect.DeepEqual(resource.Labels, a.actual.Labels) {
263+
report.AddField("labels", a.actual.Labels, resource.Labels)
259264
updateMask.Paths = append(updateMask.Paths, "labels")
260265
}
261266

262267
if len(updateMask.Paths) == 0 {
263268
return nil
264269
}
265270

271+
structuredreporting.ReportDiff(ctx, report)
272+
266273
req := &pb.UpdateWorkstationClusterRequest{
267274
UpdateMask: updateMask,
268275
WorkstationCluster: resource,

0 commit comments

Comments
 (0)