fix: Replace `sessions`, `kernels`'s `status_history`'s type `map` with `list`
refs #412, follow-up to #480
Checklist: (if applicable)
- [ ] Milestone metadata specifying the target backport version
- [x] Mention to the original issue
- [ ] Documentation
- [ ] API server-client counterparts (e.g., manager API -> client SDK)
- [ ] Test case(s) to demonstrate the difference of before/after
The current implementation saves only the most recent timestamp when status information in status_history is updated, and all previous information is deleted.
This PR updates status_history to list type for saving all previous information and utilizing it.
Related issue: https://github.com/lablup/backend.ai/pull/1116
Tested manually by writing some temporary client code.
@api_function
@pass_ctx_obj
async def get_status_history(ctx: CLIContext, self):
"""
Retrieves the status transition history of the compute session.
"""
try:
with Session() as session:
fetch_func = lambda pg_offset, pg_size: session.ComputeSession.paginated_list(fields=(
session_fields["status_history"],
session_fields["status_history_log"],
))
ctx.output.print_paginated_list(
fetch_func,
initial_page_offset=0,
page_size=20,
)
except Exception as e:
ctx.output.print_error(e)
sys.exit(ExitCode.FAILURE)
The result is as follows.
You can see status_history via graphene still use the same format, and the status_history_log uses the migrationed format.
We also need to update clients using the session resource usage API handler's status_history field at:
https://github.com/lablup/backend.ai/blob/e77c4a3cd79246541746fca5336a10261d7dc00b/src/ai/backend/manager/api/resource.py#L466
as this does not go through the GraphQL's backward-compatible field generation.
Switching to another PR as we introduce Graphite. See #2116.