Skip to content

Commit 6a9ede1

Browse files
committed
fix(admin): disk info mount and stability
1 parent 752b023 commit 6a9ede1

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

admin/app/services/system_service.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,25 @@ export class SystemService {
129129
si.time(),
130130
])
131131

132-
const diskInfoRawString = await getFile(
133-
path.join(process.cwd(), SystemService.diskInfoFile),
134-
'string'
135-
)
132+
let diskInfo: NomadDiskInfoRaw | undefined
133+
let disk: NomadDiskInfo[] = []
136134

137-
const diskInfo = (
138-
diskInfoRawString
139-
? JSON.parse(diskInfoRawString.toString())
140-
: { diskLayout: { blockdevices: [] }, fsSize: [] }
141-
) as NomadDiskInfoRaw
135+
try {
136+
const diskInfoRawString = await getFile(
137+
path.join(process.cwd(), SystemService.diskInfoFile),
138+
'string'
139+
)
140+
141+
diskInfo = (
142+
diskInfoRawString
143+
? JSON.parse(diskInfoRawString.toString())
144+
: { diskLayout: { blockdevices: [] }, fsSize: [] }
145+
) as NomadDiskInfoRaw
142146

143-
const disk = this.calculateDiskUsage(diskInfo)
147+
disk = this.calculateDiskUsage(diskInfo)
148+
} catch (error) {
149+
logger.error('Error reading disk info file:', error)
150+
}
144151

145152
return {
146153
cpu,
@@ -164,7 +171,7 @@ export class SystemService {
164171
*/
165172
private async _syncContainersWithDatabase() {
166173
try {
167-
const allServices = await Service.all();
174+
const allServices = await Service.all()
168175
const serviceStatusList = await this.dockerService.getServicesStatus()
169176

170177
for (const service of allServices) {
@@ -189,7 +196,6 @@ export class SystemService {
189196
}
190197
}
191198
}
192-
193199
} catch (error) {
194200
logger.error('Error syncing containers with database:', error)
195201
}

install/install_nomad.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ create_nomad_directory(){
237237
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
238238
}
239239

240+
create_disk_info_file() {
241+
# Disk info file MUST be created before the admin container starts.
242+
# Otherwise, Docker will assume we meant to mount a directory and will create an empty directory at the mount point
243+
echo '{}' > /tmp/nomad-disk-info.json
244+
}
245+
240246
download_management_compose_file() {
241247
local compose_file_path="${NOMAD_DIR}/compose.yml"
242248

0 commit comments

Comments
 (0)