Prathmesh010190 commented on issue #135:
URL: https://github.com/apache/openserverless/issues/135#issuecomment-5060256858
Hi @sciabarracom, I'd like to work on this — could I get it assigned to me?
Solution approach, following the codebase's existing conventions (modeled
closely on openserverless/rest/build.py's /system/api/v1/build/cleanup
endpoint, which already does age-based job cleanup):
1. New REST module openserverless/rest/admin_clean.py
POST /system/api/v1/admin/clean — accepts a JSON body {"activations": bool,
"queues": bool, "actions": bool}, mirroring the max_age_hours pattern already
used in build.py's cleanup endpoint.
Reuse the existing authorize() / env_to_dict() /
res_builder.build_response_message() / res_builder.build_error_message()
helpers already used across rest/build.py and rest/auth.py, so the new endpoint
matches the auth flow and response shape of the rest of the API.
2. New service class openserverless/impl/admin/clean_service.py (parallel to
impl/builder/build_service.py):
clean_activations() — uses the existing
openserverless/couchdb/couchdb_util.py::CouchDB client (already wraps
auth/session/db_base URL construction) to bulk-delete old docs from the
activations DB, the same way couchdb_util.py already does
delete_db/create_db/recreate_db.
clean_queues() — new logic, since there's no existing Kafka helper in the
repo; would add a small openserverless/common/kafka_util.py alongside the
existing common/ utils to purge/reset invoker topics.
clean_actions() — needs scope clarification (see below).
3. CLI side (openserverless-task repo): add admin clean [--activations]
[--queues] [--actions] calling this new endpoint, matching how admin
compact/admin usage are already wired to admin-api endpoints.
4. Swagger docs: follow the exact docstring format already used in build.py
(tags, summary, parameters, responses per status code) so it shows up correctly
at /system/apidocs/.
One open question before I start: should --actions clear stuck/dead action
invocations, or something else? Want to avoid scope creep into deleting
user-deployed actions.
Happy to open a draft PR once assigned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]