Skip to content

server: optional log of served device config#154

Merged
milan-zededa merged 1 commit into
lf-edge:masterfrom
eriknordmark:log-device-config-env-var
May 15, 2026
Merged

server: optional log of served device config#154
milan-zededa merged 1 commit into
lf-edge:masterfrom
eriknordmark:log-device-config-env-var

Conversation

@eriknordmark
Copy link
Copy Markdown
Contributor

Summary

Adam logs every inbound API request (requested /api/v2/edgedevice/id/<UUID>/config).
For investigations where you also need to see what was returned
which baseos, which content tree, how many apps/networks etc. — the
request log alone isn't enough.

This PR adds a one-line response summary, gated by an env var so the
default log volume is unchanged.

Behaviour

With ADAM_LOG_DEVICE_CONFIG=1 set, every served device config emits
on stderr:

config served: uuid=<UUID> version=<N> baseos.version=<V> \
    baseos.activate=<bool> baseos.ct=<UUID> baseosconfig_list=<n> \
    contentInfo=<n> apps=<n> networks=<n> volumes=<n> datastores=<n>

Off by default → no log-volume cost for normal operators.

The log fires before the 304 Not Modified short-circuit so it
surfaces the response shape on every poll, even those where EVE
already has the current config. That makes it useful for "is EVE
even polling for /config right now?" questions, not just "what's in
the response?".

How to enable

# bare adam
ADAM_LOG_DEVICE_CONFIG=1 adam server

# adam container
docker run -e ADAM_LOG_DEVICE_CONFIG=1 lfedge/adam server

# eden-managed adam
docker run -e ADAM_LOG_DEVICE_CONFIG=1 ... lfedge/adam:<tag> ...

docker logs eden_adam (or wherever stderr lands) then carries one
config served: line per /config poll.

Field choice

The fields cover the categories the response body decomposes into —
baseos block, baseos list (legacy), contentInfo, apps, networks,
volumes, datastores. Each is summarised by either a key fact
(baseos: version + activate + content-tree UUID) or a count (lists).
That keeps the line a single grep target while still answering the
common debugging questions:

  • "Did adam send a baseos this poll?" — baseos.version
  • "Is it asking EVE to install it?" — baseos.activate
  • "Why does my contentInfo count differ across polls?" — contentInfo=N
  • "How long since the controller's last edit?" — version=N

Test

make build
ADAM_LOG_DEVICE_CONFIG=1 ./bin/adam-linux-amd64 server ...   # then poll /config
# observe one "config served: uuid=..." line per poll on stderr
unset ADAM_LOG_DEVICE_CONFIG
./bin/adam-linux-amd64 server ...                            # poll /config
# observe no extra log lines (only the existing request-line)

Unit tests (go test ./...) pass.

Adam logs every inbound API request, but not the response shape. When
debugging "what did adam tell EVE on this poll?" the request log
alone doesn't say whether adam returned a baseos to install, what
content-tree UUID, how many apps/networks/etc.

Add a one-line response summary at log.Printf level, gated by an
env var (ADAM_LOG_DEVICE_CONFIG=1) so the default log volume is
unchanged. Fires before the 304 Not Modified check so no-change
polls still surface what would have been returned.

Format:
  config served: uuid=<UUID> version=<N> baseos.version=<V>
      baseos.activate=<bool> baseos.ct=<UUID> baseosconfig_list=<n>
      contentInfo=<n> apps=<n> networks=<n> volumes=<n>
      datastores=<n>

README gets a short subsection in Options describing the variable
and an example docker invocation.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@milan-zededa milan-zededa merged commit 4875249 into lf-edge:master May 15, 2026
2 checks passed
@eriknordmark eriknordmark deleted the log-device-config-env-var branch May 15, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants