Published Dockerfiles set ENV NODE_HOSTNAME=localhost, silently disabling replication after an in-place 4.x→5.x upgrade
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, node.js, typescript
- Domain
- databases, devops, distributed-systems
Research direction
Start with the ENV NODE_HOSTNAME=localhost lines in Dockerfile, Dockerfile-gpu, and Dockerfile-openshift, then read getThisNodeName() in server/nodeName.ts to confirm the precedence described in the issue. Build or inspect the published image environment and verify that a clustered upgrade can use replication.hostname without the image supplying a localhost override.
Written by the indexing model from the issue text.
Description
Summary
All three published Dockerfiles set ENV NODE_HOSTNAME=localhost. Because Harper reads environment variables as configuration, that env var becomes node.hostname — which getThisNodeName() treats as the highest-priority source of node identity. On an in-place 4.x → 5.x upgrade of a clustered node, the node therefore identifies as localhost, does not match its row in system.hdb_nodes, and user-database replication silently stops running for that node.
The operator-facing symptom is worse than the misconfiguration itself: Harper writes the env-derived value back into harperdb-config.yaml on every boot, so editing or deleting node.hostname in the config file appears to "work" and then reverts on the next restart. There is no obvious signal that an environment variable is the thing overriding it.
Where
Dockerfile:114—ENV NODE_HOSTNAME=localhostDockerfile-gpu:115— sameDockerfile-openshift:118— same
Identity resolution that consumes it (core): server/nodeName.ts getThisNodeName() checks node.hostname first and only falls back to replication.hostname, replication.url, the TLS CN, and finally the listening port.
Reproduction
On a two-node 4.x cluster whose nodes are registered in system.hdb_nodes as node-1.example.com / node-2.example.com, with replication.hostname correctly set per node:
- Upgrade one node in place to 5.2.x using the published image.
- On boot, the log reports:
Replication identity mismatch: this node identifies as "localhost" (url wss://localhost:9933)
but no matching row exists in system.hdb_nodes (which has 2 node(s): node-1.example.com,
node-2.example.com). User-database replication will NOT run for this node until its identity
matches a registered node name.
grep hostname harperdb-config.yamlshows bothreplication.hostname: node-1.example.com(correct) andnode.hostname: localhost(wrong, and it wins).- Remove
node.hostnamefromharperdb-config.yaml, or set it tonode-1.example.com, and restart → the file is rewritten withlocalhostagain. Config file mtime lands ~1s after container start. docker inspect <container> --format '{{json .Config.Env}}'showsNODE_HOSTNAME=localhost, anddocker history <image>attributes it to anENV NODE_HOSTNAME=localhostlayer, i.e. it comes from the image rather than the deployment.
Verified against harperfast/harper-pro:5.2.3.
Impact
- Any in-place upgrade of a clustered node to 5.x loses user-database replication for that node until an operator discovers the env var. Replication failing silently while the node otherwise serves traffic is the dangerous part — on an active-active pair it presents as data divergence rather than as an upgrade error.
- Every node from these images is affected identically, so an operator fixing node 1 will hit it again on node 2.
node.hostnamedid not carry this meaning in 4.x, so the env var was inert there. Nothing in an upgrade runbook would flag it.
Suggested fix
Drop ENV NODE_HOSTNAME=localhost from all three Dockerfiles. If a default is wanted for single-node/dev container use, it should not be one that outranks replication.hostname on an upgraded cluster member — leaving it unset lets getThisNodeName() fall through to replication.hostname, which is already correct on a registered node.
Two smaller things that would each have saved most of the debugging time:
- The mismatch warning is good, and correctly does not tell the operator to cement the wrong value. It could go one step further and name where the losing value came from (env var vs config file), since the config file is the misleading place to look.
- Persisting env-derived config back into
harperdb-config.yamlmakes an env override indistinguishable from a file setting after the first boot. Worth considering whether env-sourced values should be persisted at all.
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 0
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 83
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HarperFast/harper-pro
-
Difficulty 2/5 Half a day Newbie friendliness 88/100
HarperFast/harper-pro#836 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HarperFast/harper-pro#685 ·
-
area:replication enhancement feature:plugin-substrate
Difficulty 5/5 Over a week Newbie friendliness 25/100
HarperFast/harper-pro#886 ·
-
area:replication enhancement feature:plugin-substrate
Difficulty 3/5 1-2 days Newbie friendliness 68/100
HarperFast/harper-pro#885 ·
-
area:replication enhancement feature:plugin-substrate
Difficulty 5/5 Over a week Newbie friendliness 25/100
HarperFast/harper-pro#884 ·
All issues in HarperFast/harper-pro
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·