Skip to content

Commit 02fe288

Browse files
authored
Add structured reporting diff to KMSKeyHandle (#6727)
### BRIEF Change description Fixes #6590 #### WHY do we need this change? Add structured reporting diff to the controller in `pkg/controller/direct/kms/keyhandle/keyhandle_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 3f256ac + 648116c commit 02fe288

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controller/direct/kms/keyhandle/keyhandle_controller.go

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

3132
gcp "cloud.google.com/go/kms/apiv1"
3233

@@ -202,6 +203,12 @@ func (a *Adapter) Update(ctx context.Context, updateOp *directbase.UpdateOperati
202203
status.ExternalRef = &externalRef
203204
return updateOp.UpdateStatus(ctx, status, nil)
204205
} else {
206+
report := &structuredreporting.Diff{Object: updateOp.GetUnstructured()}
207+
for path := range paths {
208+
report.AddField(path, nil, nil)
209+
}
210+
structuredreporting.ReportDiff(ctx, report)
211+
205212
return fmt.Errorf("update operation not supported for resource %v %v, field(s) changed: %v",
206213
a.desired.GroupVersionKind(), k8s.GetNamespacedName(a.desired), paths)
207214
}

0 commit comments

Comments
 (0)