Skip to content

Log FRR container output to docker logs#3541

Merged
ipspace merged 4 commits into
ipspace:devfrom
jbemmel:frr-docker-logs
Jul 1, 2026
Merged

Log FRR container output to docker logs#3541
ipspace merged 4 commits into
ipspace:devfrom
jbemmel:frr-docker-logs

Conversation

@jbemmel

@jbemmel jbemmel commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Relay FRR file logging to the container stdout stream for clab Docker nodes, enabling debugging when frr.debug is set

Sample use case:

netlab up bgp.session/13-bfd.yml -d frr -p clab -s nodes.dut.clab.image=quay.io/frrouting/frr:10.5.1 -s frr.debug="bfd peer"

With this PR, docker logs clab-bgpsession-dut shows the BFD events working for 10.6.1 but failing for 10.5.1

@ipspace ipspace left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's not much harm in doing this, so let's do it (with a few safeguards ;)

Comment thread netsim/ansible/templates/initial/frr.j2 Outdated
Comment thread netsim/ansible/templates/initial/frr.j2 Outdated
# Redirect FRR's log to the container's stdout so 'docker logs' works
#
FRR_LOG_OUTPUT="/proc/$(pgrep -f '^/bin/bash /usr/lib/frr/docker-start$')/fd/1"
touch /var/log/frr/frr.log && chown frr:frr /var/log/frr/frr.log

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the whole block after FRR configuration is already done, and you won't need this

Comment thread netsim/ansible/templates/initial/frr.j2 Outdated
#
FRR_LOG_OUTPUT="/proc/$(pgrep -f '^/bin/bash /usr/lib/frr/docker-start$')/fd/1"
touch /var/log/frr/frr.log && chown frr:frr /var/log/frr/frr.log
tail -n 0 -F /var/log/frr/frr.log >${FRR_LOG_OUTPUT} 2>&1 &

@ipspace ipspace Jun 30, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You sure you don't need 'nohup' here?

Also, execute this at the very end of the initial configuration, preceded by set +e, so we won't get configuration errors if this concoction crashes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left out the set +e, after removing the touch it's only a tail. I checked that nohup is not needed (bash has huponexit disabled by default)

@jbemmel jbemmel marked this pull request as draft June 30, 2026 17:51
jbemmel and others added 2 commits June 30, 2026 12:52
Relay FRR file logging to the container stdout stream for clab nodes while keeping the regular file target for other providers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use frr.logfile consistently, run tail after vtysh initial config, and
forward to PID 1 stdout so docker logs captures FRR output.

Co-authored-by: Cursor <cursoragent@cursor.com>
FRR creates the log file when logging is enabled; tail can follow it directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jbemmel jbemmel marked this pull request as ready for review June 30, 2026 18:13
@ipspace ipspace merged commit 22a7104 into ipspace:dev Jul 1, 2026
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