fleet-server align structs#7264
Conversation
Use betteralign to automatically align go structs to get rid of padding. Add check:align target to magefile so changes to structs can be caught by the CI pipeline.
TL;DR
Remediation
Investigation detailsRoot CauseThis is a dependency/lockfile drift in the PR's tool module. The PR updates return sh.Run("go", "tool", "-modfile", filepath.Join("dev-tools", "go.mod"), "golang.org/x/tools/cmd/goimports", "-w", ".")With Evidence
VerificationIn a temporary worktree for PR commit go tool -modfile dev-tools/go.mod golang.org/x/tools/cmd/goimports -hThen I ran the suggested command: go get -modfile dev-tools/go.mod golang.org/x/tools/cmd/goimports@v0.46.0After that, a non-mutating goimports invocation succeeded: go tool -modfile dev-tools/go.mod golang.org/x/tools/cmd/goimports -l magefile.goThe remediation adds Follow-upNo What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
| for i, c := range []byte(key) { // convert string into []byte so any runes are properly handled | ||
| buf[i+1] = c |
There was a problem hiding this comment.
This should prevent issues if a non ascii character is ever used as the key/val
cc: @pzl
What is the problem this PR solves?
Structs in fleet-server codebase are padded. This results in more memory usage then required.
How does this PR solve the problem?
Use betteralign to automatically align go structs to get rid of padding.
Add check:align target to magefile and as a dependency of the check:ci target so changes to structs can be caught by the CI pipeline.
How to test this PR locally
mage check:alignDesign Checklist
I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration files./changelog/fragmentsusing the changelog toolRelated issues