Skip to content

docker: share the config file with the mounted source via symlink - #211

Merged
On1x merged 2 commits into
masterfrom
config-symlink
Oct 30, 2026
Merged

On1x merged 2 commits into
masterfrom
config-symlink

Conversation

@On1x

@On1x On1x commented Oct 30, 2026

Copy link
Copy Markdown
Member

What

The image start script (share/vizd/vizd.sh) copied the config into the data dir on every start:

cp /etc/vizd/config.ini $HOME/config.ini

So an admin-UI edit written by the node into $HOME/config.ini never reached the mounted source, and the next restart silently reverted it.

This replaces the copy with a symlink, so there is one config file:

ln -sfn /etc/vizd/config.ini "$HOME/config.ini"

node_admin::write_config_atomic() canonicalizes the path (bfs::canonical), creates its temp file next to the resolved target, then renames. Through the symlink those writes land in /etc/vizd/config.ini, i.e. directly in the mounted host source. No C++ changes.

Deployment requirements (both are real, both were measured)

  1. /etc/vizd must be a directory mount. A file mount (…/config.ini → /etc/vizd/config.ini) makes rename() over the mount point fail with EBUSY. The prod node already mounts a directory (/root/vizconfig → /etc/vizd); the viz-hub mirror currently mounts the file and needs docker-compose changed to a directory.
  2. The mounted directory must be writable by the node user vizd. mkstemp lives next to the target. The prod dir is root:root 0755, so the node (uid 1001) gets EACCES. The script now prints a loud startup warning instead of leaving the operator to discover it from a rejected UI action.

Upgrade path: a regular config file left by the old cp is replaced once at startup, so existing volumes keep working.

Verified

In the real vizblockchain/vizd:latest image (no rebuild needed for the check):

  • symlink created over a stale copied file, readlink = /etc/vizd/config.ini;
  • write as vizd via mktemp + mv in /etc/vizd lands in the host file (content changed on the host side);
  • with a root-owned 0755 /etc/vizd, the new startup warning fires with the uid.

Not verified here: the full image build / PR CI — that runs on this PR.

The start script used to copy /etc/vizd/config.ini into the data dir on
every start, so admin-UI edits stayed inside the container and the mounted
source never changed.

node_admin writes the config atomically: canonicalize the path, create a
temp file next to the resolved target, then rename. A symlink from
$HOME/config.ini to /etc/vizd/config.ini therefore routes those writes
straight into the mounted source, without touching the node code.

Requirements, both checked in the image before this lands:
  * /etc/vizd must be a DIRECTORY mount (rename over a file mount point
    fails with EBUSY);
  * that directory must be writable by the node user (mkstemp lives there),
    otherwise admin config apply fails with EACCES. The script now prints a
    loud warning at startup instead of letting the operator discover it
    from a rejected UI action.

A regular config file left by the old cp is replaced once, so upgrades keep
working.
@On1x
On1x merged commit bd6c240 into master Oct 30, 2026
6 checks passed
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.

1 participant