Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kernels.status_history JSONB column to track the datetimes for each status change #412

Closed
achimnol opened this issue Apr 8, 2022 · 1 comment · Fixed by #480
Closed
Assignees
Labels
comp:manager Related to Manager component
Milestone

Comments

@achimnol
Copy link
Member

achimnol commented Apr 8, 2022

Let's allow users to query when their sessions and kernels enteres which status.
(e.g., when did this session move from PENDING to SCHEDULED, PREPARING to RUNNING, etc. afterwards)

Fortunately, there is no backward status transition in the kernel's lifecycle.
(e.g., PENDING -> SCHEDULED exists but SCHEDULED -> PENDING does not exist)
So we could use a simple JSONB column whose keys are the status names and their values are the timestamps when the row's status is set as the key.

{
  "PENDING": "...",  // would be same to created_at
  "SCHEDULED": "...",
  "PREPARING": "...",
  "RUNNING": "...",
  // ...
  "TERMINATED": "...",  // would be same to terminated_at
}

When the key does not exist or null, it means either the kernel has not been gone into that status or the record is a migrated one from older versions.

Let's use manager.models.utils.sql_json_merge() to incrementally add a new key as follows:

sa.update(kernels).values(..., status_history=sql_json_merge(
    kernels.c.status_history, [], {"<new-status>": "<timestamp>"},
))

For maximum interoperability, the timestamp values could be formatted as UTC-based ISO8601 datetime.

Q. How could we "ensure" all database status change queries to update this json field altogether?

@achimnol achimnol added type:feature Add new features comp:manager Related to Manager component labels Apr 8, 2022
@achimnol achimnol added this to the 22.09 milestone Apr 8, 2022
@achimnol achimnol changed the title Add status_history JSONB column to track the datetimes for each status change Add kernsl.status_history JSONB column to track the datetimes for each status change Apr 8, 2022
@achimnol achimnol changed the title Add kernsl.status_history JSONB column to track the datetimes for each status change Add kernels.status_history JSONB column to track the datetimes for each status change Apr 8, 2022
@rapsealk
Copy link
Member

This feature would be also helpful to the future work on #395.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component
Projects
None yet
2 participants