k8ssandra / management-api-for-apache-cassandra

RESTful / Secure Management Sidecar for Apache Cassandra
Apache License 2.0
72 stars 51 forks source link

Job Status Serialisation issue #393

Closed Miles-Garnsey closed 1 year ago

Miles-Garnsey commented 1 year ago

The Job constructor currently has a string type for the statusChanges parameter in the constructor and it appears that this causes RestEasy to output the statusChanges as a String in HTTP responses, instead of correctly serialising it into an Array (as it is declared to be in the actual class body for Job). Thanks RestEasy.

Meanwhile, the annotations picked up for the OpenAPI document (which are subsequently propagated to the automatically generated client) pick up the statusChanges field (correctly) as a List , which causes a deserialisation error on the client side when the client attempts to deserialise the JSON string primitive as an array.

This PR harmonises the two by ensuring that any inputs to the Job constructor are declared as a real List<StatusChange> which necessitates some additional manipulation to deserialise the json from the RPC layer before re-serialising the whole thing as the correct JSON in the Resources layer.

This whole situation really needs a re-design.

github-actions[bot] commented 1 year ago

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

burmanm commented 1 year ago

Seems to work:

cassandra@cluster2-dc2-r1-sts-0 /]$ curl 'http://localhost:8080/api/v0/ops/executor/job?job_id=repair-0'
{"id":"repair-0","type":"repair","status":"COMPLETED","submit_time":1695758304316,"end_time":1695758304320,"error":null,"status_changes":[{"status":"COMPLETE","change_time":1695758304320,"message":""}]}
[cassandra@cluster2-dc2-r1-sts-0 /]$