1
- import { PlainMessage } from '@bufbuild/protobuf'
2
1
import { execa } from 'execa'
3
- import { DiskSpace } from '../gen/ts/depot/cloud/v3/machine_pb'
4
2
import { sleep } from '../utils/common'
5
- import { DiskStats , stats } from '../utils/disk'
3
+ import { stats } from '../utils/disk'
6
4
import { client } from '../utils/grpc'
7
5
8
6
export interface ReportHealthParams {
9
7
machineId : string
10
8
signal : AbortSignal
11
9
headers : HeadersInit
12
- mounts : Mount [ ]
13
- }
14
-
15
- export interface Mount {
16
- device : string
17
10
path : string
18
11
}
19
12
20
- export async function reportEngineHealth ( { machineId, signal, headers, mounts } : ReportHealthParams ) {
13
+ export async function reportEngineHealth ( { machineId, signal, headers, path } : ReportHealthParams ) {
21
14
while ( true ) {
22
15
if ( signal . aborted ) return
23
16
@@ -27,23 +20,20 @@ export async function reportEngineHealth({machineId, signal, headers, mounts}: R
27
20
while ( true ) {
28
21
if ( signal . aborted ) return
29
22
30
- const disk_stats = await Promise . all ( mounts . map ( ( { device, path} ) => stats ( device , path ) ) )
31
- const disks : PlainMessage < DiskSpace > [ ] = disk_stats
32
- . filter ( ( item : DiskStats | undefined ) : item is DiskStats => {
33
- return item !== undefined
34
- } )
35
- . map ( ( { device, path, freeMb, totalMb, freeInodes, totalInodes} ) => {
36
- return {
37
- device,
38
- path,
39
- freeMb,
40
- totalMb,
41
- freeInodes,
42
- totalInodes,
43
- }
44
- } )
23
+ const disk_stats = await stats ( path )
24
+ const disk_space = disk_stats
25
+ ? [
26
+ {
27
+ path,
28
+ freeMb : disk_stats . freeMb ,
29
+ totalMb : disk_stats . totalMb ,
30
+ freeInodes : disk_stats . freeInodes ,
31
+ totalInodes : disk_stats . totalInodes ,
32
+ } ,
33
+ ]
34
+ : undefined
45
35
46
- await client . pingMachineHealth ( { machineId, disks} , { headers, signal} )
36
+ await client . pingMachineHealth ( { machineId, disks : disk_space } , { headers, signal} )
47
37
await sleep ( 1000 )
48
38
}
49
39
} catch ( error ) {
0 commit comments