You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log the JSON patch document when updating resource (#95)
This patch updates the `resourceReconciler.patchResourceMetadataAndSpec` and
`resourceReconciler.patchResourceStatus` methods in a couple ways.
First, I ensure that the desired and latest resource parameters are
*never* modified by either method by ensuring that only copies of
desired and latest are used when calling Patch against the API server.
Second, I added some debug-level logging of the exact JSON patch
document that is sent over the wire to the Kubernetes API server when
patching either the metadata/spec *or* the status.
Here is what this looks like in the debug logging output:
metadata+spec:
```
1.65540769296847e+09 DEBUG ackrt >>>> kc.Patch (metadata + spec) {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-u8loelgfy", "is_adopted": false, "generation": 1}
1.6554076929743059e+09 DEBUG ackrt patched resource metadata + spec {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-u8loelgfy", "is_adopted": false, "generation": 1, "json": "{\"metadata\":{\"generation\":2,\"resourceVersion\":\"1049\"},\"spec\":{\"encryptionConfiguration\":{\"encryptionType\":\"AES256\"},\"imageScanningConfiguration\":{\"scanOnPush\":false},\"imageTagMutability\":\"MUTABLE\",\"registryID\":\"750630568209\",\"tags\":null},\"status\":{\"conditions\":null}}"}
1.6554076929743316e+09 DEBUG ackrt <<<< kc.Patch (metadata + spec) {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-u8loelgfy", "is_adopted": false, "generation": 1}
```
status:
```
1.6554077304127564e+09 DEBUG ackrt >> kc.Patch (status) {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-yq327yxdo", "is_adopted": false, "generation": 5}
1.6554077304208796e+09 DEBUG ackrt patched resource status {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-yq327yxdo", "is_adopted": false, "generation": 5, "json": "{\"metadata\":{\"resourceVersion\":\"1129\"},\"spec\":{\"tags\":[{\"key\":\"k1\",\"value\":\"v1\"}]},\"status\":{\"conditions\":[{\"lastTransitionTime\":\"2022-06-16T19:28:50Z\",\"message\":\"Late initialization successful\",\"reason\":\"Late initialization successful\",\"status\":\"True\",\"type\":\"ACK.LateInitialized\"},{\"lastTransitionTime\":\"2022-06-16T19:28:50Z\",\"message\":\"Resource synced successfully\",\"reason\":\"\",\"status\":\"True\",\"type\":\"ACK.ResourceSynced\"}]}}"}
1.6554077304209113e+09 DEBUG ackrt << kc.Patch (status) {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-yq327yxdo", "is_adopted": false, "generation": 5}
1.655407730420916e+09 DEBUG ackrt < r.patchResourceStatus {"account": "750630568209", "role": "", "region": "us-west-2", "kind": "Repository", "namespace": "default", "name": "ecr-repository-yq327yxdo", "is_adopted": false, "generation": 5}
```
I specifically strip out all of the Kubernetes server-side apply
annotations out of the patch document because they are super verbose and
are not helpful since we don't use server-side apply.
I'm hoping this extra bit of logging information will be useful when
attempting to diagnose exactly when and what changes are being applied
to resources in the Kubernetes API.
Signed-off-by: Jay Pipes <[email protected]>
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
0 commit comments