Greenfield: Implement direct controller, E2E fixtures, and fuzzer for DiscoveryEngineSchema #13777
Real GCP Audit Logs Verification
The following Google Cloud audit logs demonstrate that the real GCP API endpoints (discoveryengine.googleapis.com) were exercised during E2E testing against project cnrm-barni-4:
---
insertId: xaw0xwe2m97y
logName: projects/cnrm-barni-4/logs/cloudaudit.googleapis.com%2Factivity
operation:
first: true
id: projects/600845353393/locations/global/collections/default_collection/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema/operations/delete-schema-15148982481388079850
last: true
producer: discoveryengine.googleapis.com
protoPayload:
'@type': type.googleapis.com/google.cloud.audit.AuditLog
authenticationInfo:
principalEmail: overseer-kcc-tester@cnrm-barni-4.iam.gserviceaccount.com
authorizationInfo:
- granted: true
permission: discoveryengine.schemas.delete
permissionType: ADMIN_WRITE
resource: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
methodName: google.cloud.discoveryengine.v1.SchemaService.DeleteSchema
request:
'@type': type.googleapis.com/google.cloud.discoveryengine.v1.DeleteSchemaRequest
name: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
requestMetadata:
callerSuppliedUserAgent: kcc/1.159.0 (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/1.159.0,gzip(gfe)
resourceName: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
serviceName: discoveryengine.googleapis.com
severity: NOTICE
timestamp: '2026-10-07T03:45:14.698017508Z'
---
insertId: 7ivjntd5rsi
logName: projects/cnrm-barni-4/logs/cloudaudit.googleapis.com%2Factivity
operation:
first: true
id: projects/600845353393/locations/global/collections/default_collection/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema/operations/update-schema-16394363439438522526
producer: discoveryengine.googleapis.com
protoPayload:
'@type': type.googleapis.com/google.cloud.audit.AuditLog
authenticationInfo:
principalEmail: overseer-kcc-tester@cnrm-barni-4.iam.gserviceaccount.com
authorizationInfo:
- granted: true
permission: discoveryengine.schemas.update
permissionType: ADMIN_WRITE
resource: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
methodName: google.cloud.discoveryengine.v1.SchemaService.UpdateSchema
request:
'@type': type.googleapis.com/google.cloud.discoveryengine.v1.UpdateSchemaRequest
schema:
name: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
requestMetadata:
callerSuppliedUserAgent: kcc/1.159.0 (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/1.159.0,gzip(gfe)
resourceName: projects/cnrm-barni-4/locations/global/dataStores/datastore-6iza4hcaoe2vbmy/schemas/default_schema
serviceName: discoveryengine.googleapis.com
severity: NOTICE
timestamp: '2026-10-07T03:45:08.572945048Z'
---
insertId: 1mtn9cte3sjnr
logName: projects/cnrm-barni-4/logs/cloudaudit.googleapis.com%2Factivity
operation:
first: true
id: projects/600845353393/locations/global/collections/default_collection/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema/operations/delete-schema-7512656779557408155
last: true
producer: discoveryengine.googleapis.com
protoPayload:
'@type': type.googleapis.com/google.cloud.audit.AuditLog
authenticationInfo:
principalEmail: overseer-kcc-tester@cnrm-barni-4.iam.gserviceaccount.com
authorizationInfo:
- granted: true
permission: discoveryengine.schemas.delete
permissionType: ADMIN_WRITE
resource: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
methodName: google.cloud.discoveryengine.v1.SchemaService.DeleteSchema
request:
'@type': type.googleapis.com/google.cloud.discoveryengine.v1.DeleteSchemaRequest
name: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
requestMetadata:
callerSuppliedUserAgent: kcc/1.159.0 (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/1.159.0,gzip(gfe)
resourceName: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
serviceName: discoveryengine.googleapis.com
severity: NOTICE
timestamp: '2026-10-07T03:44:16.674217895Z'
---
insertId: 11r7dqfe3n99v
logName: projects/cnrm-barni-4/logs/cloudaudit.googleapis.com%2Factivity
operation:
first: true
id: projects/600845353393/locations/global/collections/default_collection/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema/operations/update-schema-5906176711145527115
producer: discoveryengine.googleapis.com
protoPayload:
'@type': type.googleapis.com/google.cloud.audit.AuditLog
authenticationInfo:
principalEmail: overseer-kcc-tester@cnrm-barni-4.iam.gserviceaccount.com
authorizationInfo:
- granted: true
permission: discoveryengine.schemas.update
permissionType: ADMIN_WRITE
resource: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
methodName: google.cloud.discoveryengine.v1.SchemaService.UpdateSchema
request:
'@type': type.googleapis.com/google.cloud.discoveryengine.v1.UpdateSchemaRequest
schema:
name: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
requestMetadata:
callerSuppliedUserAgent: kcc/1.159.0 (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/1.159.0,gzip(gfe)
resourceName: projects/cnrm-barni-4/locations/global/dataStores/datastore-5up7hlnjczaev4y/schemas/default_schema
serviceName: discoveryengine.googleapis.com
severity: NOTICE
timestamp: '2026-10-07T03:44:11.534516889Z'
🤖 AI Factory started investigating CI check failures for this pull request.
Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.
Investigating unit-tests-2-of-4 failure
Run: 37569786313
Name:
unit-tests-2-of-4Cause:
Test FailureDetails: In
pkg/cli/powertools/cais unit test TestGoldenIdentitiesYamlFiles, DiscoveryEngineSchema's identity resolution failed because the referenced dependency DiscoveryEngineDataStore in dependencies.yaml did not include status.externalRef. In live E2E tests, the live cluster populates status.externalRef upon creation of the dependency, allowing GetIdentity to resolve successfully when recording _identities.yaml. In static unit tests (TestGoldenIdentitiesYamlFiles), status.externalRef was missing, causing reference normalization to return NewReferenceNotReadyError and mismatching the golden _identities.yaml.Action Taken: Added
status.externalRef to DiscoveryEngineDataStore in pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryengineschema/discoveryengineschema-minimal/dependencies.yaml and pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryengineschema/discoveryengineschema-maximal/dependencies.yaml, verified unit test shard 2 of 4 passes locally, and pushed the updated commit.(This report was generated by overseer)
🤖 AI Factory started reviewing this pull request in a sandbox.
KCC Auto-Review Results
Trigger criteria matched: Yes
Client Creation: Pass - Uses official GAPIC Go REST client
gcp.NewSchemaRESTClient.Default Reconciler Kept: Pass - Greenfield resource correctly registered with
ReconcilerTypeDirect in pkg/controller/resourceconfig/static_config.go.Proto Diffs & Update Mask: Pass - Uses
mappers.OnlySpecFields and common.DiffForTopLevelFields with JSON unmarshaling normalization for whitespace-insensitive schema comparison; UpdateSchemaRequest does not require update_mask.Structured Reporting: Pass -
structuredreporting.ReportDiff(ctx, diffs) is invoked in Update() prior to sending update requests.KRM Status Updates: Pass - Invokes
updateStatus on creation, update, and no-op update paths.LRO Wait: Pass - Waits on operations in
Create, Update, and Delete (handling the REST client empty result gracefully).Test Coverage: Pass - Includes minimal and maximal test cases with recorded real GCP fixtures (
_http.log, golden YAMLs, _identities.yaml), round-trip fuzzer, and updated missing field exceptions.Detailed Findings / Actions Required:
None. The implementation complies with greenfield controller standards.
🤖 AI Factory started addressing review feedback for this pull request.
how come there are no audit probe logs? Either include them or give out a reason as to why you cannot check that the tests ran against real GCP.
🤖 AI Factory started addressing review feedback for this pull request.
🤖 AI Factory started investigating CI check failures for this pull request.
Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.
Please add brief code comments in pkg/controller/direct/discoveryengine/discoveryengineschema_controller.go to document the non-obvious API and protobuf behaviors in Update() and compare().
1. In Update() (around line 241, diffs, _, err := a.compare(...)): Add a comment explaining why updateMask is ignored (_) — i.e., pb.UpdateSchemaRequest in discoveryenginepb does not have an UpdateMask field, so compare() is only used to check diffs.HasDiff() and report diffs via structuredreporting.ReportDiff.
2. In compare() (around line 284, json.Unmarshal + reflect.DeepEqual):
Add a comment explaining why semantic JSON comparison is needed — i.e., the GCP API returns jsonSchema as a compacted JSON string and non-deterministically reorders object keys across GET calls, whereas KRM manifests typically format jsonSchema as a multi-line indented string. Since common.DiffForTopLevelFields performs byte-for-byte string comparison on protoreflect.Value, unmarshaling both into any and checking reflect.DeepEqual prevents false diffs and infinite PATCH loops during re-reconciliation.
Note: Since DiscoveryEngineDataStore doesn't support skipDefaultSchemaCreation yet, the E2E fixtures manage the auto-created default_schema and only hit PATCH (UpdateSchema). We'll follow up in https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/14230 to support skipDefaultSchemaCreation and test the POST (CreateSchema) path.
🤖 AI Factory started addressing review feedback for this pull request.
Please add brief code comments inpkg/controller/direct/discoveryengine/discoveryengineschema_controller.goto document the non-obvious API and protobuf behaviors inUpdate()andcompare().
> 1. InUpdate()(around line 241,diffs, _, err := a.compare(...)): Add a comment explaining whyupdateMaskis ignored (_) — i.e.,pb.UpdateSchemaRequestindiscoveryenginepbdoes not have anUpdateMaskfield, socompare()is only used to checkdiffs.HasDiff()and report diffs viastructuredreporting.ReportDiff.
…
In reply to @maqiuyujoyce's review
Please add brief code comments inpkg/controller/direct/discoveryengine/discoveryengineschema_controller.goto document the non-obvious API and protobuf behaviors inUpdate()andcompare().
> 1. InUpdate()(around line 241,diffs, _, err := a.compare(...)): Add a comment explaining whyupdateMaskis ignored (_) — i.e.,pb.UpdateSchemaRequestindiscoveryenginepbdoes not have anUpdateMaskfield, socompare()is only used to checkdiffs.HasDiff()and report diffs viastructuredreporting.ReportDiff.
> 2. Incompare()(around line 284,json.Unmarshal+reflect.DeepEqual):
Add a comment explaining why semantic JSON comparison is needed — i.e., the GCP API returnsjsonSchemaas a compacted JSON string and non-deterministically reorders object keys acrossGETcalls, whereas KRM manifests typically formatjsonSchemaas a multi-line indented string. Sincecommon.DiffForTopLevelFieldsperforms byte-for-byte string comparison onprotoreflect.Value, unmarshaling both intoanyand checkingreflect.DeepEqualprevents false diffs and infinitePATCHloops during re-reconciliation.
> Note: SinceDiscoveryEngineDataStoredoesn't supportskipDefaultSchemaCreationyet, the E2E fixtures manage the auto-createddefault_schemaand only hitPATCH(UpdateSchema). We'll follow up in https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/14230 to supportskipDefaultSchemaCreationand test thePOST(CreateSchema) path.
Added code comments in pkg/controller/direct/discoveryengine/discoveryengineschema_controller.go to document both behaviors:
1. In Update(): documented that pb.UpdateSchemaRequest does not support update_mask, so compare() is solely used to detect diffs (diffs.HasDiff()) and report them via structuredreporting.ReportDiff.
2. In compare(): documented that semantic JSON comparison (json.Unmarshal into any followed by reflect.DeepEqual) is required because the GCP API returns compacted JSON with non-deterministic key ordering across GET calls, preventing false diffs against indented KRM schema strings and avoiding infinite PATCH loops during re-reconciliation.
(Written by an AI coding agent)
<sub>🤖 Agent session</sub>
<!-- factory:task-output kind=Change task=recipe-care-comments-20261021-111946-70a7 reply=5597035904 -->
Addressed reviewer feedback from @maqiuyujoyce on pkg/controller/direct/discoveryengine/discoveryengineschema_controller.go:
updateMask is ignored in Update().compare().(Written by an AI coding agent)
<sub>🤖 Agent session</sub>
<!-- factory:task-output kind=Change task=recipe-care-comments-20261021-111946-70a7 -->
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/GoogleCloudPlatform/k8s-config-connector/pull/13777#pullrequestreview-5600035187" title="LGTM">maqiuyujoyce</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
maqiuyujoyce
ada-coder-bot
This PR implements the direct controller, E2E fixtures, and fuzzer for
DiscoveryEngineSchema(discoveryengine.cnrm.cloud.google.com/v1alpha1).Fixes #13771
Summary of Changes
1. Direct Controller:
- Implemented
pkg/controller/direct/discoveryengine/discoveryengineschema_controller.gowith GAPIC REST client (NewSchemaRESTClient).- Implemented
Find,Create,Update,Delete, andExport.- Added semantic JSON unmarshaling comparison in
compare()to prevent false diffs caused by whitespace/formatting differences injsonSchema.- Handled
unsupported result type <nil>: <nil>gracefully duringDeleteSchemaoperation wait.2. Fuzzer:
- Implemented
pkg/controller/direct/discoveryengine/discoveryengineschema_fuzzer.goregistering withRegisterKRMSpecFuzzer.3. Static Configuration:
- Registered
DiscoveryEngineSchemawithReconcilerTypeDirectinpkg/controller/resourceconfig/static_config.go.4. E2E Test Fixtures:
- Created minimal and maximal test fixtures under
pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryengineschema/.5. Real GCP Recording:
- Successfully recorded golden files (
_http.log,_generated_object_*.golden.yaml,_identities.yaml) against real GCP projectcnrm-barni-4usingRECORD_AUDIT_PROBE=1 ./hack/record-gcp.6. API Field Checks:
- Updated
alpha-missingfields.txtto reflect test coverage for.spec.dataStoreRefand.spec.jsonSchema.7. Journal:
- Added entry to
.gemini/journals/discoveryengine.mddocumenting controller behavior and GCP API considerations.Testing
discoveryengineschema-minimal,discoveryengineschema-maximal) against real GCP projectcnrm-barni-4.TestSomeMappers).go test ./pkg/crd/template/...).go test ./tests/apichecks/...).This PR was generated by the overseer,greenfield,step/controller,overseer/review agent (powered by the gemini-3.7-flash model).
``
release-note
``NONE