-
Notifications
You must be signed in to change notification settings - Fork 943
feat(site): warn on provisioner health during builds #15589
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
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7df3b27
add alert to the create workspace page
SasSwart 1e1262f
improve error case documentation
SasSwart 0f78afc
add provisioner health hook
SasSwart f0f7216
show provisioner health warnings for templates
SasSwart a3eeb9c
consistent formatting for alerts across pages
SasSwart 3cf53ef
Finalise Provisioner Warnings for Templates and template versions
SasSwart e281d6b
linter fixes
SasSwart 2baa81e
Merge remote-tracking branch 'origin/main' into jjs/15048-fe
SasSwart 0cab768
use matched_provisioners instead of a second api call
SasSwart b228257
provide a key to provisioner tags to keep react happy
SasSwart 8b91dc0
fix linting issues
SasSwart bec2913
make fmt
SasSwart 4796a32
Copy updates
SasSwart b6f99a6
make fmt
SasSwart aec9cba
add loader back in to build logs drawer
SasSwart 75e7394
simplify logic
SasSwart 0aed543
fix logic
SasSwart 0bd9478
make fmt
SasSwart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Theme } from "@mui/material"; | ||
import Alert from "@mui/material/Alert"; | ||
import AlertTitle from "@mui/material/AlertTitle"; | ||
import type { AlertColor } from "@mui/material/Alert"; | ||
import { AlertDetail } from "components/Alert/Alert"; | ||
import type { FC } from "react"; | ||
|
||
type ProvisionerAlertProps = { | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
title: string, | ||
detail: string, | ||
severity: AlertColor, | ||
} | ||
|
||
export const ProvisionerAlert : FC<ProvisionerAlertProps> = ({ | ||
title, | ||
detail, | ||
severity, | ||
}) => { | ||
return ( | ||
<Alert | ||
severity={severity} | ||
css={(theme: Theme) => ({ | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
borderRadius: 0, | ||
border: 0, | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
borderLeft: `2px solid ${theme.palette.error.main}`, | ||
})} | ||
> | ||
<AlertTitle>{title}</AlertTitle> | ||
<AlertDetail>{detail}</AlertDetail> | ||
</Alert> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
site/src/modules/provisioners/useCompatibleProvisioners.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ProvisionerDaemon } from "api/typesGenerated"; | ||
|
||
export const provisionersUnhealthy = (provisioners : ProvisionerDaemon[]) => { | ||
return provisioners.reduce((allUnhealthy, provisioner) => { | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!allUnhealthy) { | ||
// If we've found one healthy provisioner, then we don't need to look at the rest | ||
return allUnhealthy; | ||
} | ||
// Otherwise, all provisioners so far have been unhealthy, so we check the next one | ||
|
||
// If a provisioner has no last_seen_at value, then it's considered unhealthy | ||
if (!provisioner.last_seen_at) { | ||
return allUnhealthy; | ||
} | ||
|
||
// If a provisioner has not been seen within the last 60 seconds, then it's considered unhealthy | ||
const lastSeen = new Date(provisioner.last_seen_at); | ||
const oneMinuteAgo = new Date(Date.now() - 60000); | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const unhealthy = lastSeen < oneMinuteAgo; | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
return allUnhealthy && unhealthy; | ||
}, true); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import { | |
MockWorkspaceResourceSensitive, | ||
MockWorkspaceVolumeResource, | ||
} from "testHelpers/entities"; | ||
import { withDashboardProvider } from "testHelpers/storybook"; | ||
import { withDashboardProvider, withProvisioners } from "testHelpers/storybook"; | ||
import { TemplateVersionEditor } from "./TemplateVersionEditor"; | ||
|
||
const meta: Meta<typeof TemplateVersionEditor> = { | ||
|
@@ -49,6 +49,101 @@ type Story = StoryObj<typeof TemplateVersionEditor>; | |
|
||
export const Example: Story = {}; | ||
|
||
export const UndefinedLogs: Story = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
args: { | ||
defaultTab: "logs", | ||
buildLogs: undefined, | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
}, | ||
}, | ||
}; | ||
|
||
export const EmptyLogs: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
buildLogs: [], | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
}, | ||
}, | ||
}; | ||
|
||
export const CouldntGetProvisioners: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
buildLogs: [], | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoProvisioners: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
buildLogs: [], | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
organization_id: "org-id", | ||
}, | ||
}, | ||
decorators: [withProvisioners], | ||
parameters: { | ||
organization_id: "org-id", | ||
tags: MockRunningProvisionerJob.tags, | ||
provisioners: [], | ||
} | ||
}; | ||
|
||
export const UnhealthyProvisioners: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
buildLogs: [], | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
organization_id: "org-id" | ||
}, | ||
}, | ||
decorators: [withProvisioners], | ||
parameters: { | ||
organization_id: "org-id", | ||
tags: MockRunningProvisionerJob.tags, | ||
provisioners: [ | ||
{ | ||
last_seen_at: new Date(new Date().getTime() - 5 * 60 * 1000).toISOString() | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
export const HealthyProvisioners: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
buildLogs: [], | ||
templateVersion: { | ||
...MockTemplateVersion, | ||
job: MockRunningProvisionerJob, | ||
organization_id: "org-id" | ||
}, | ||
}, | ||
decorators: [withProvisioners], | ||
parameters: { | ||
organization_id: "org-id", | ||
tags: MockRunningProvisionerJob.tags, | ||
provisioners: [ | ||
{ | ||
last_seen_at: new Date(), | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
export const Logs: Story = { | ||
args: { | ||
defaultTab: "logs", | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.