Title: General use scheduler for jobs like Auto ON/OFF · Issue #271 · coder/coder · GitHub
Open Graph Title: General use scheduler for jobs like Auto ON/OFF · Issue #271 · coder/coder
X Title: General use scheduler for jobs like Auto ON/OFF · Issue #271 · coder/coder
Description: Create a scheduler/executor implementation for workspace auto on/off. Add table workspace_lifecycle_job CREATE TYPE workspace_lifecycle_operation AS ENUM ('stop', 'start') CREATE TABLE workspace_lifecycle_job ( id uuid NOT NULL, -- uniqu...
Open Graph Description: Create a scheduler/executor implementation for workspace auto on/off. Add table workspace_lifecycle_job CREATE TYPE workspace_lifecycle_operation AS ENUM ('stop', 'start') CREATE TABLE workspace_li...
X Description: Create a scheduler/executor implementation for workspace auto on/off. Add table workspace_lifecycle_job CREATE TYPE workspace_lifecycle_operation AS ENUM ('stop', 'start') CREATE TA...
Opengraph URL: https://github.com/coder/coder/issues/271
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"General use scheduler for jobs like Auto ON/OFF","articleBody":"Create a scheduler/executor implementation for workspace auto on/off.\r\n\r\n- Add table `workspace_lifecycle_job` \r\n ```sql\r\n CREATE TYPE workspace_lifecycle_operation AS ENUM ('stop', 'start')\r\n CREATE TABLE workspace_lifecycle_job (\r\n id uuid NOT NULL, -- unique job ID\r\n created_at timestamp with time zone NOT NULL, -- when the job was created\r\n updated_at timestamp with time zone NOT NULL, -- when the job was last updated\r\n started_at timestamp with time zone, -- when the job was started, null means it's pending\r\n cancelled_at timestamp with time zone, -- when the job was cancelled, null means it hasn't been cancelled\r\n completed_at timestamp with time zone, -- when the job was completed, null means it hasn't finished yet \r\n error text, -- any errors encountered from the job\r\n workspace_id uuid NOT NULL, -- target workspace\r\n operation workspace_lifecycle_operation NOT NULL, -- start or stop\r\n deadline timestamp with time zone NOT NULL, -- when the job is to be executed\r\n PRIMARY KEY (id)\r\n )\r\n ```\r\n\r\n- Add table `workspace_lifecycle_job_logs`\r\n ```sql\r\n CREATE TABLE workspace_lifecycle_job_logs (\r\n id uuid NOT NULL, -- unique row id\r\n job_id uuid NOT NULL, -- uuid of the workspace lifecycle job that created it\r\n created_at timestamp with time zone NOT NULL, -- when the logs were created\r\n level log_level NOT NULL, -- level of the log\r\n output character varying(1024) NOT NULL -- content of the log\r\n );\r\n ```\r\n\r\n- Add required methods to `querier.go`:\r\n - `AcquireWorkspaceLifecycleJob` acquires the lock for a single workspace lifecycle job that isn't started, completed, or cancelled using SKIP LOCKED.\r\n - `InsertWorkspaceLifecycleJob` inserts a new row into the `workspace_lifecycle_job` table\r\n - `InsertWorkspaceLifecycleJobLogs` inserts a new row into the `workspace_lifecycle_job_logs` table\r\n - `UpdateWorkspaceLifecycleJobByID` updates a row of the `workspace_lifecycle_job_logs` table\r\n - `UpdateWorkspaceLifecycleJobWithCancelByID` marks a row of the `workspace_lifecycle_job` table as cancelled\r\n - `UpdateWorkspaceLifecycleJobWithCompleteByID` marks a row of the `workspace_lifecycle_job` table as completed\r\n\r\n- Create a `WorkspaceLifecycleJobScheduler` that schedules starting and stopping workspaces at their scheduled start time/stop time\r\n - A goroutine tied to the application lifecycle will iterate over all workspaces periodically.\r\n - If a workspace is running and has a defined auto-stop time, if there is no corresponding auto-stop job pending then create said job.\r\n - If a workspace is stopped and has a defined auto-start time, if there is no corresponding auto-start job pending then create said job.\r\n - If an auto-start job is pending for a workspace that has no defined auto-start time, mark the job as cancelled.\r\n - If an auto-stop job is pending for a workspace that has no defined auto-stop time, mark the job as cancelled.\r\n\r\n- Create an `WorkspaceLifecycleJobExecutor` that executes jobs from `workspace_lifecycle_job`:\r\n - A goroutine tied to the application lifecycle will continuously wait for a pending workspace lifecycle job that has not been claimed.\r\n - When an unclaimed job is found:\r\n - Mark the job as claimed (setting `started_at` and `updated_at`)\r\n - Triggers the workspace stop/start unless the workspace is already in the desired state (stopped for auto-stop, running for auto-start)\r\n - Mark the job as completed\r\n","author":{"url":"https://github.com/misskniss","@type":"Person","name":"misskniss"},"datePublished":"2022-02-11T16:43:11Z","url":"https://github.com/coder/coder/issues/271"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a9c82e59-0a3d-83c6-399a-1cd0d5b26110 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B968:B1B84:110CBC4:159B84A:6B0152AC |
| html-safe-nonce | 239ae850e184ee559dce7d1accbb2386d3239eadcde90fb5a3cee55b56ddbd51 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTY4OkIxQjg0OjExMENCQzQ6MTU5Qjg0QTo2QjAxNTJBQyIsInZpc2l0b3JfaWQiOiIxNDY0NTcxMjM5NzA3MjY3NzU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ebb5328c1fd004d5d57ca8e602c62d244372a0c5709506ef7ef8a56c2bd79f67 |
| hovercard-subject-tag | issue:1132841370 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/271/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e57ab83e599be1ccfe1c58576f386a3f5f287990393325d24be54157a1ebadf/coder/coder/issues/271 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e57ab83e599be1ccfe1c58576f386a3f5f287990393325d24be54157a1ebadf/coder/coder/issues/271 |
| og:image:alt | Create a scheduler/executor implementation for workspace auto on/off. Add table workspace_lifecycle_job CREATE TYPE workspace_lifecycle_operation AS ENUM ('stop', 'start') CREATE TABLE workspace_li... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | misskniss |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width