Skip to content

fix: derive running ws stop time from deadline #1920

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

Merged
merged 11 commits into from
May 31, 2022
Prev Previous commit
fixup! Merge origin/main
  • Loading branch information
greyscaled committed May 31, 2022
commit 6a48ea6e62a11b1f824aaa61eb8bc43a50d542d2
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { WorkspaceSchedule, WorkspaceScheduleProps } from "./WorkspaceSchedule"

dayjs.extend(utc)

// REMARK: There's a known problem with storybook and using date libraries that
// call string.toLowerCase
// SEE: https:github.com/storybookjs/storybook/issues/12208#issuecomment-697044557
const ONE = 1
const SEVEN = 7

export default {
title: "components/WorkspaceSchedule",
component: WorkspaceSchedule,
argTypes: {},
}

const Template: Story<WorkspaceScheduleProps> = (args) => <WorkspaceSchedule {...args} />
Expand All @@ -32,13 +37,9 @@ export const ShutdownSoon = Template.bind({})
ShutdownSoon.args = {
workspace: {
...Mocks.MockWorkspace,

latest_build: {
...Mocks.MockWorkspaceBuild,
deadline: dayjs().utc().add(1, "hour").toString(), // in 1 hour ago
job: {
...Mocks.MockProvisionerJob,
},
deadline: dayjs().add(ONE, "hour").utc().format(),
transition: "start",
},
ttl: 2 * 60 * 60 * 1000 * 1_000_000, // 2 hours
Expand All @@ -52,7 +53,7 @@ ShutdownLong.args = {

latest_build: {
...Mocks.MockWorkspaceBuild,
deadline: dayjs().utc().add(7, "days").toString(), // in 7 days
deadline: dayjs().add(SEVEN, "days").utc().format(),
transition: "start",
},
ttl: 7 * 24 * 60 * 60 * 1000 * 1_000_000, // 7 days
Expand All @@ -67,7 +68,6 @@ WorkspaceOffShort.args = {
latest_build: {
...Mocks.MockWorkspaceBuild,
transition: "stop",
updated_at: dayjs().subtract(2, "days").toString(),
},
ttl: 2 * 60 * 60 * 1000 * 1_000_000, // 2 hours
},
Expand All @@ -81,7 +81,6 @@ WorkspaceOffLong.args = {
latest_build: {
...Mocks.MockWorkspaceBuild,
transition: "stop",
updated_at: dayjs().subtract(2, "days").toString(),
},
ttl: 2 * 365 * 24 * 60 * 60 * 1000 * 1_000_000, // 2 years
},
Expand Down