Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store compact JSON in annotations storages
Improve how the annotations look like in `kubectl` yaml-format: as one line, not wrapped at arbitrary spaces, making it difficult to read and debug. It still be wrapped at spaces in the handler's progress field, e.g. `message` (which contains error/exception messages), but this happens not so often. The behaviour of the operators during the switch it not affected: they only compare and operate on the actual values, not their string representation. Mass-recoding is not expected either: the existing fields will be compacted only on the next occasion when they are written for any other reason. Note: this is the same as `kubectl` itself stores its own annotation. Compare the output of a command during a sample operator run: ``` kubectl get -o yaml -f examples/obj.yaml ``` Before: ``` apiVersion: zalando.org/v1 kind: KopfExample metadata: annotations: kopf.zalando.org/last-handled-configuration: '{"spec":{"duration":"1m","field":"value","items":["item1","item2"],"x":600},"metadata":{"labels":{"somelabel":"somevalue"},"annotations":{"someannotation":"somevalue"}}}' kopf.zalando.org/update: '{"started": "2020-08-22T19:38:36.850462", "delayed": "2020-08-22T19:38:37.277965", "retries": 4, "success": false, "failure": false, "message": "None", "subrefs": ["update/s1", "update/s2", "update/s2/z1", "update/s2/z2", "update/s3", "update/s4", "update/s4/z1", "update/s4/z2"]}' kopf.zalando.org/update.s1: '{"started": "2020-08-22T19:38:36.851463", "stopped": "2020-08-22T19:38:36.853665", "retries": 1, "success": true, "failure": false}' kopf.zalando.org/update.s2: '{"started": "2020-08-22T19:38:36.851542", "stopped": "2020-08-22T19:38:37.134753", "retries": 2, "success": true, "failure": false, "subrefs": ["update/s2/z1", "update/s2/z2"]}' kopf.zalando.org/update.s2.z1: '{"started": "2020-08-22T19:38:36.997186", "stopped": "2020-08-22T19:38:36.998416", "retries": 1, "success": true, "failure": false}' kopf.zalando.org/update.s2.z2: '{"started": "2020-08-22T19:38:36.997264", "stopped": "2020-08-22T19:38:37.133993", "retries": 1, "success": true, "failure": false}' kopf.zalando.org/update.s3: '{"started": "2020-08-22T19:38:37.135138", "stopped": "2020-08-22T19:38:37.136068", "retries": 1, "success": true, "failure": false}' kopf.zalando.org/update.s4: '{"started": "2020-08-22T19:38:37.135197", "delayed": "2020-08-22T19:38:37.277547", "retries": 1, "success": false, "failure": false, "message": "None", "subrefs": ["update/s4/z1", "update/s4/z2"]}' kopf.zalando.org/update.s4.z1: '{"started": "2020-08-22T19:38:37.275760", "stopped": "2020-08-22T19:38:37.276967", "retries": 1, "success": true, "failure": false}' kopf.zalando.org/update.s4.z2: '{"started": "2020-08-22T19:38:37.275867", "retries": 0, "success": false, "failure": false}' kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"zalando.org/v1","kind":"KopfExample","metadata":{"annotations":{"someannotation":"somevalue"},"labels":{"somelabel":"somevalue"},"name":"kopf-example-1","namespace":"default"},"spec":{"duration":"1m","field":"value"," someannotation: somevalue ``` After: ``` apiVersion: zalando.org/v1 kind: KopfExample metadata: annotations: kopf.zalando.org/last-handled-configuration: | {"spec":{"duration":"1m","field":"value","items":["item1","item2"],"x":700},"metadata":{"labels":{"somelabel":"somevalue"},"annotations":{"someannotation":"somevalue"}}} kopf.zalando.org/update: '{"started":"2020-08-22T19:35:41.853274","delayed":"2020-08-22T19:35:42.291393","retries":4,"success":false,"failure":false,"message":"None","subrefs":["update/s1","update/s2","update/s2/z1","update/s2/z2","up kopf.zalando.org/update.s1: '{"started":"2020-08-22T19:35:41.854561","stopped":"2020-08-22T19:35:41.856038","retries":1,"success":true,"failure":false}' kopf.zalando.org/update.s2: '{"started":"2020-08-22T19:35:41.854639","stopped":"2020-08-22T19:35:42.146998","retries":2,"success":true,"failure":false,"subrefs":["update/s2/z1","update/s2/z2"]}' kopf.zalando.org/update.s2.z1: '{"started":"2020-08-22T19:35:42.013957","stopped":"2020-08-22T19:35:42.014978","retries":1,"success":true,"failure":false}' kopf.zalando.org/update.s2.z2: '{"started":"2020-08-22T19:35:42.014018","stopped":"2020-08-22T19:35:42.145090","retries":1,"success":true,"failure":false}' kopf.zalando.org/update.s3: '{"started":"2020-08-22T19:35:42.147980","stopped":"2020-08-22T19:35:42.149392","retries":1,"success":true,"failure":false}' kopf.zalando.org/update.s4: '{"started":"2020-08-22T19:35:42.148266","delayed":"2020-08-22T19:35:42.290835","retries":1,"success":false,"failure":false,"message":"None","subrefs":["update/s4/z1","update/s4/z2"]}' kopf.zalando.org/update.s4.z1: '{"started":"2020-08-22T19:35:42.288954","stopped":"2020-08-22T19:35:42.290224","retries":1,"success":true,"failure":false}' kopf.zalando.org/update.s4.z2: '{"started":"2020-08-22T19:35:42.289030","retries":0,"success":false,"failure":false}' kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"zalando.org/v1","kind":"KopfExample","metadata":{"annotations":{"someannotation":"somevalue"},"labels":{"somelabel":"somevalue"},"name":"kopf-example-1","namespace":"default"},"spec":{"duration":"1m","field":"value"," someannotation: somevalue ```
- Loading branch information