Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SasSwart merged 18 commits intomainfromjjs/15048-fe
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
7df3b27
add alert to the create workspace page
SasSwartNov 19, 2024
1e1262f
improve error case documentation
SasSwartNov 19, 2024
0f78afc
add provisioner health hook
SasSwartNov 20, 2024
f0f7216
show provisioner health warnings for templates
SasSwartNov 21, 2024
a3eeb9c
consistent formatting for alerts across pages
SasSwartNov 21, 2024
3cf53ef
Finalise Provisioner Warnings for Templates and template versions
SasSwartNov 22, 2024
e281d6b
linter fixes
SasSwartNov 22, 2024
2baa81e
Merge remote-tracking branch 'origin/main' into jjs/15048-fe
SasSwartNov 26, 2024
0cab768
use matched_provisioners instead of a second api call
SasSwartNov 27, 2024
b228257
provide a key to provisioner tags to keep react happy
SasSwartNov 27, 2024
8b91dc0
fix linting issues
SasSwartNov 27, 2024
bec2913
make fmt
SasSwartNov 27, 2024
4796a32
Copy updates
SasSwartNov 28, 2024
b6f99a6
make fmt
SasSwartNov 28, 2024
aec9cba
add loader back in to build logs drawer
SasSwartNov 28, 2024
75e7394
simplify logic
SasSwartNov 28, 2024
0aed543
fix logic
SasSwartNov 28, 2024
0bd9478
make fmt
SasSwartNov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
add provisioner health hook
  • Loading branch information
@SasSwart
SasSwart committedNov 20, 2024
commit0f78afc32ddfd9ef60b1ca34f49f70414543ada9
10 changes: 9 additions & 1 deletionsite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -682,12 +682,20 @@ class ApiMethods {

/**
* @param organization Can be the organization's ID or name
* @param tags to filter provisioner daemons by.
*/
getProvisionerDaemonsByOrganization = async (
organization: string,
tags?: Record<string, string>
): Promise<TypesGen.ProvisionerDaemon[]> => {
const params = new URLSearchParams();

if (tags) {
params.append('tags', encodeURIComponent(JSON.stringify(tags)));
}

const response = await this.axios.get<TypesGen.ProvisionerDaemon[]>(
`/api/v2/organizations/${organization}/provisionerdaemons`,
`/api/v2/organizations/${organization}/provisionerdaemons?${params.toString()}`
);
return response.data;
};
Expand Down
29 changes: 29 additions & 0 deletionssite/src/modules/provisioners/useCompatibleProvisioners.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
import { API } from "api/api";
import { ProvisionerDaemon } from "api/typesGenerated";
import { useEffect, useState } from "react";

export const useCompatibleProvisioners = (organization: string | undefined, tags: Record<string, string> | undefined) => {
const [compatibleProvisioners, setCompatibleProvisioners] = useState<ProvisionerDaemon[]>([])

useEffect(() => {
(async () => {
if (!organization) {
setCompatibleProvisioners([])
return
}

try {
const provisioners = await API.getProvisionerDaemonsByOrganization(
organization,
tags,
);

setCompatibleProvisioners(provisioners);
} catch (error) {
setCompatibleProvisioners([])
}
})();
}, [organization, tags])

return compatibleProvisioners
}
38 changes: 38 additions & 0 deletionssite/src/pages/CreateTemplatePage/BuildLogsDrawer.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ import { useWatchVersionLogs } from "modules/templates/useWatchVersionLogs";
import { WorkspaceBuildLogs } from "modules/workspaces/WorkspaceBuildLogs/WorkspaceBuildLogs";
import { type FC, useLayoutEffect, useRef } from "react";
import { navHeight } from "theme/constants";
import { useCompatibleProvisioners } from "modules/provisioners/useCompatibleProvisioners";

type BuildLogsDrawerProps = {
error: unknown;
Expand All@@ -27,6 +28,31 @@ export const BuildLogsDrawer: FC<BuildLogsDrawerProps> = ({
variablesSectionRef,
...drawerProps
}) => {
const compatibleProvisioners = useCompatibleProvisioners(
templateVersion?.organization_id,
templateVersion?.job.tags
);
const compatibleProvisionersUnhealthy = compatibleProvisioners.reduce((allUnhealthy, provisioner) => {
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);
const unhealthy = lastSeen < oneMinuteAgo;


return allUnhealthy && unhealthy;
}, true);

const logs = useWatchVersionLogs(templateVersion);
const logsContainer = useRef<HTMLDivElement>(null);

Expand DownExpand Up@@ -65,6 +91,18 @@ export const BuildLogsDrawer: FC<BuildLogsDrawerProps> = ({
</IconButton>
</header>

{ !compatibleProvisioners && !logs ? (
// If there are no compatible provisioners, warn that this job may be stuck
<>No compatible provisioners</>
) : compatibleProvisionersUnhealthy && !logs ? (
// If there are compatible provisioners in the db, but they have not reported recent health checks,
// warn that the job might be stuck
<>Compatible provisioners are potentially unhealthy. Your job might be delayed</>
) : (
// If there are compatible provisioners and at least one was recently seen, no warning is necessary.
<></>
)}

{isMissingVariables ? (
<MissingVariablesBanner
onFillVariables={() => {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp