hashicorp / hashicorp/nomad

Task Log Config Validation: Log usage calculation incorrect

Open
#18,933 4 comments 0 reactions 0 assignees View on GitHub
stage/needs-discussion theme/jobspec type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

I believe that the calculation of disk space needed by logs when comparing to available ephemeral disk is incorrect. Either that or the documentation on [max_files](https://developer.hashicorp.com/nomad/docs/job-specification/logs#max_files) and [ephemeral_disk](https://developer.hashicorp.com/nomad/docs/job-specification/ephemeral_disk) is incorrect. I think this calculation needs to be doubled: [https://github.com/hashicorp/nomad/blob/66fbc0f67e47b3fc5f6007e624173e18905f9b63/nomad/structs/structs.go#L7438](https://github.com/hashicorp/nomad/blob/66fbc0f67e47b3fc5f6007e624173e18905f9b63/nomad/structs/structs.go#L7438)

The max files documentation states that this value is per stream. So without the multiplier, it's only checking that there is room for one stream on disk. I checked where the max files are set to make sure files aren't doubled there instead. That didn't seem to be the case and constructing the TaskLogger objects doesn't halve the value. I could have still missed a detail somewhere.

I think this is pretty minor as the default settings are safe. Ephemeral disk defaults to 300mb which exceeds the default log config's 200mb (2 * 10 files * 10mb).

I'm sorry I didn't make a pr for this, but our legal department hasn't approved of me signing the CLA yet. Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at nomad/structs/structs.go around line 7438 and trace how max_files is passed into TaskLogger objects. Compare that calculation with the max_files and ephemeral_disk documentation, then confirm whether disk accounting covers both log streams and update the validation behavior accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure, observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.