fix(admin): disk info mount and stability

This commit is contained in:
Jake Turner 2026-01-13 07:57:26 -08:00 committed by Jake Turner
parent 752b023798
commit 6a9ede1776
2 changed files with 24 additions and 12 deletions

View File

@ -129,18 +129,25 @@ export class SystemService {
si.time(),
])
let diskInfo: NomadDiskInfoRaw | undefined
let disk: NomadDiskInfo[] = []
try {
const diskInfoRawString = await getFile(
path.join(process.cwd(), SystemService.diskInfoFile),
'string'
)
const diskInfo = (
diskInfo = (
diskInfoRawString
? JSON.parse(diskInfoRawString.toString())
: { diskLayout: { blockdevices: [] }, fsSize: [] }
) as NomadDiskInfoRaw
const disk = this.calculateDiskUsage(diskInfo)
disk = this.calculateDiskUsage(diskInfo)
} catch (error) {
logger.error('Error reading disk info file:', error)
}
return {
cpu,
@ -164,7 +171,7 @@ export class SystemService {
*/
private async _syncContainersWithDatabase() {
try {
const allServices = await Service.all();
const allServices = await Service.all()
const serviceStatusList = await this.dockerService.getServicesStatus()
for (const service of allServices) {
@ -189,7 +196,6 @@ export class SystemService {
}
}
}
} catch (error) {
logger.error('Error syncing containers with database:', error)
}

View File

@ -237,6 +237,12 @@ create_nomad_directory(){
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
}
create_disk_info_file() {
# Disk info file MUST be created before the admin container starts.
# Otherwise, Docker will assume we meant to mount a directory and will create an empty directory at the mount point
echo '{}' > /tmp/nomad-disk-info.json
}
download_management_compose_file() {
local compose_file_path="${NOMAD_DIR}/compose.yml"