Skip to content

Correct documentdb-local option reference against upstream source - #61

Merged
guanzhousongmicrosoft merged 6 commits into
documentdb:mainfrom
GuanzhouSong:fix/documentdb-local-option-reference
Aug 3, 2026
Merged

Correct documentdb-local option reference against upstream source#61
guanzhousongmicrosoft merged 6 commits into
documentdb:mainfrom
GuanzhouSong:fix/documentdb-local-option-reference

Conversation

@GuanzhouSong

Copy link
Copy Markdown
Contributor

Replaces #60, rebased onto current main (which has since picked up #57, #58, #59 and #35, three of which touch files edited here) and with that PR's review folded in.

Follow-up to #56. That PR fixed PG_PORT -> POSTGRESQL_PORT; this validates the rest of the page the same way, against documentdb-local/scripts/emulator_entrypoint.sh, packaging/gateway/docker/Dockerfile_documentdb_local, scripts/start_oss_server.sh, and the gateway's TLS source.

The same bug, five rows up

--documentdb-port was documented as overriding PORT. The entrypoint reads DOCUMENTDB_PORT. Upstream's own test_emulator_entrypoint.py asserts both PG_PORT and PORT must be absent from the help output — #56 covered one of the two.

Option table

RowWasActually
--documentdb-portPORTDOCUMENTDB_PORT
--passwordrequired, default NAdefault Admin100, set before the required-check so that check never fires
--start-pg, --create-userEnv: NASTART_POSTGRESQL / CREATE_USER, both set in the Dockerfile
--start-pg, --create-user, --allow-external-connections, --enable-telemetrybare flagsall consume a following value
--cert-path.pfx + CERT_SECRETPEM only; the gateway is always configured CertType: PemFile. CERT_SECRET exists nowhere in the product
--cert-path / --key-filedescribed standalonemandatory pairing; supplying one without the other exits 1
--enable-telemetry"Azure Application Insights"no such integration exists in the product
--usernameSTRINGreserved role names and the BlockedRolePrefixes (documentdb, citus, pg, internal_role) are rejected before startup
--owner"Specify the owner for DocumentDB"the psql -U role for admin-user creation; initdb runs with no -U as the documentdb OS user, so that is the only superuser and any other value exits 1 after PostgreSQL has already initialized
--allow-external-connections"opens PostgreSQL"also adds host all all 0.0.0.0/0 scram-sha-256, needs -p 9712:9712 to be reachable, and is ignored under --start-pg false
--start-pg, --create-userrestated the flag namefalse means bringing your own PostgreSQL / no admin user at all, so nothing can authenticate and data initialization fails

The bare-flag ones matter more than they look: the argument parser has no *) catch-all, so a value-consuming flag written in its documented bare form swallows the next argument and the parse loop stops making progress. The inverse is worse — --skip-init-data and --disable-extended-rum take no value, and passing one (--disable-extended-rum false) leaves the parser re-testing the same argv forever: no logs, no ready banner, no exit. Both rows now say so.

Five supported options were missing entirely:--tlsMode, --init-data, --init-data-path, --skip-init-data, --disable-extended-rum. --tlsMode is the notable one: it decides whether plain connections are rejected (requireTLS) or accepted alongside TLS (allowTLS, the default — and disabled, which despite the name behaves identically).

Three options that are documented but inert

--log-level, --enable-telemetry, and --disable-extended-rum are all parsed and strictly validated by the entrypoint and then have no effect:

  • LOG_LEVEL never reaches the gateway, which reads only DOCUMENTDB_LOG_LEVEL (a tracingEnvFilter string, in which quiet is not a level).
  • ENABLE_TELEMETRY is exported and never read again; SetupConfiguration.json ships Metrics/TracingEnabled: false and the entrypoint never rewrites them.
  • --disable-extended-rum is implemented by omitting-r from start_oss_server.sh, but that script defaults useDocumentdbExtendedRum="true", so extended RUM stays on.

These are product-side, so the page marks them Known issue rather than papering over them. Filing separately against documentdb/documentdb.

Beyond the table

  • Readiness step added.docker ps reports Up long before the gateway accepts connections; the gateway readiness poll alone allows 60s. Following the page literally gave MongoServerSelectionError. The wait is a bounded until ... grep -q loop rather than docker logs -f, which never returns — the entrypoint tail -Fs four log files into stdout for the container's whole life. It deliberately avoids timeout, which is GNU coreutils and absent on macOS.
  • Certificates are reused, not regenerated — but only across restarts of the same container; docker rm + docker run mints a new one unless the state dir is persisted. Validity is 365 days with no renewal and no expiry check on the reuse path, so both facts are now stated. The same stale "new certificate on each start" sentence was in three getting-started pages; corrected there too.
  • Certificate copy path no longer exists. Auto-generated TLS material moved to a resolved state directory. The documented default /var/lib/documentdb-gateway/tls is created by the gateway DEB's packaging, not by this image, and the container runs as non-root documentdb — so resolution falls through to $HOME/.local/state/documentdb-gateway/tls. The page now names that path and keeps docker logs | grep "TLS auto-gen" as the authoritative check. The persistence option pins DOCUMENTDB_TLS_STATE_DIR inside the data volume, which the entrypoint chowns on every start; a volume of its own is created root-owned and the unprivileged gateway cannot write its key there. The chmod -R 750 trade-off that comes with /data is stated rather than hidden.
  • Data persistence. The image declares VOLUME ["/data"], so without an explicit mount the data is stranded in an anonymous volume rather than discarded. Fixed the --data-path example, which was only a bind mount and never actually changed the data path, and added one complete docker run showing that -v goes before the image name and --data-path after it.
  • Sample output. Showed optimistic_blackwell despite --name docdb in the command above it, and leaked a real home directory (/Users/<name>/) into the mongosh connection string.

Getting-started pages

Aligned with the corrected option table: the credential notes said the username and password "must be set … for authentication to work", which is false — omitting them silently selects the public default_user / Admin100, so they now carry the same warning as the --password row. "DocumentDB Local requires TLS" became "accepts TLS connections … and requires authentication", since the default allowTLS does not reject plain clients. All three pages carry the same readiness wait. postgres-api/configuration.md notes the DOCUMENTDB_TLS_STATE_DIR fallback so it no longer contradicts this page.


Written with assistance from Claude Code; every claim above was verified against the upstream source tree by a human before submitting.

Follow-up to documentdb#56, which fixed the PG_PORT -> POSTGRESQL_PORT name. The
same class of error was present throughout the page. Validated every row
of the option table against documentdb-local/scripts/emulator_entrypoint.sh
and packaging/gateway/docker/Dockerfile_documentdb_local.
Corrections:
- --documentdb-port documented PORT; the entrypoint reads DOCUMENTDB_PORT.
Identical bug to the one documentdb#56 fixed, five rows above it.
- --password was documented as required with default NA. The real default
is Admin100, applied before the required-check, so the check never fires.
Documented the actual default and why it must be overridden.
- --start-pg and --create-user claimed no env var. Both read
START_POSTGRESQL / CREATE_USER, and both are set in the Dockerfile.
- --start-pg, --create-user, --allow-external-connections and
--enable-telemetry all consume a following value but were documented as
bare flags. The documented form swallows the next argument.
- --cert-path described .pfx certificates and a CERT_SECRET variable.
Neither exists; the gateway is always configured with CertType PemFile.
- The mandatory --cert-path/--key-file pairing was never stated. Supplying
one without the other exits 1 at startup.
- Dropped the Azure Application Insights attribution from --enable-telemetry;
it appears nowhere in the product.
- Added the five supported options that were missing entirely: --tlsMode,
--init-data, --init-data-path, --skip-init-data, --disable-extended-rum.
--tlsMode governs whether the tls=true examples on this page work.
Beyond the table:
- Added a readiness step. docker ps reports Up long before the gateway
accepts connections; the gateway poll alone allows 60s. Following the
page literally produced MongoServerSelectionError.
- Certificates are generated on first start and reused, not regenerated
every start. The gateway logs "reusing existing certificate" and the
reuse is deliberate so client trust pinning survives restart. Same stale
sentence corrected in three getting-started pages.
- The certificate copy path no longer exists. Auto-generated TLS material
now lives under a resolved state directory; the example pins it with
DOCUMENTDB_TLS_STATE_DIR rather than hardcoding a path that depends on
which directories happen to be writable.
- Noted that data is discarded on container removal unless a volume is
mounted, and corrected the --data-path example, which was only a bind
mount and never changed the data path.
- Sample output showed container name optimistic_blackwell despite
--name docdb in the command above it, and leaked a real home directory
into the mongosh connection string.
Follow-up corrections after validating the page against the upstream
entrypoint, Dockerfile, and gateway source:
- Certificate section no longer starts a second container. The name and
published port collided with the container started under Running, so
the page could not be followed top to bottom. It now documents the
path the gateway actually resolves to in this image
(/home/documentdb/.local/state/documentdb-gateway/tls) and keeps the
log-grep as the authoritative check.
- Data persistence: the image declares VOLUME ["/data"], so data is
orphaned in an anonymous volume, not discarded.
- Readiness wait is now a bounded command. "docker logs -f" never
returns, because the entrypoint streams logs for the container's life.
- --log-level, --enable-telemetry, and --disable-extended-rum are marked
as known issues: all three are validated at startup and then have no
effect.
- Valueless flags (--skip-init-data, --disable-extended-rum) warn that
passing a value hangs the argument parser.
- --username documents the reserved-name and blocked-prefix constraints.
- --owner documents that any non-default value aborts startup.
- --allow-external-connections documents the pg_hba rule it adds, the
need to publish 9712, and that it is ignored with --start-pg false.
- --data-path clarifies that the mount is a docker option and the flag a
container argument; adds a complete example.
- Certificate stability is scoped to restarts of the same container, and
the 365-day validity is stated.
Getting-started pages: align the credential and TLS wording with the
corrected option table (credentials default rather than being required,
default tlsMode accepts plain connections) and carry the readiness step.
configuration.md notes the TLS state dir fallback.
…ance
- The readiness wait used `timeout`, which is GNU coreutils and not
present on macOS. Replaced with a plain `until` loop plus explicit
guidance on what a hang means.
- The persistence example pinned DOCUMENTDB_TLS_STATE_DIR at a separate
named volume. Docker creates such a mount point root-owned and the
gateway runs as the unprivileged `documentdb` user, so it could not
write the key there. Pinned inside the data volume instead, which the
entrypoint chowns on every start, and stated the chmod trade-off.
- --owner wording now describes the initialized cluster rather than the
image.
…ects
No other page in this repo uses in-page anchor links, so the reference to
the Running section is now plain text.
--start-pg and --create-user had tautological descriptions. Both have
real consequences: false means supplying your own PostgreSQL, and false
means no admin user is created, so --username / --password do nothing and
nothing can authenticate.
--username / --password are still validated and still used by data
initialization when --create-user is false; only authentication is
impossible. Say that rather than "have no effect".
Third docker run on the page reusing --name docdb and -p 10260:10260;
say to remove the earlier container first so the page still reads
top to bottom.
@guanzhousongmicrosoft
guanzhousongmicrosoft merged commit 89dbc27 into documentdb:mainAug 3, 2026
guanzhousongmicrosoft pushed a commit that referenced this pull request Aug 3, 2026
Two loose ends from #62, both created by pull requests that merged
independently of it and could not have known about each other.
The contributing instructions in readme.md list the folders that hold
documentation articles, and #35 wrote that list while #62 was still
open, so it names four folders where there are now five. A contributor
following it would not know the kubernetes-operator section exists or
that it follows the same rules.
The documentdb-local page had no route onward. Someone who has just run
the container and wants replication, failover, or rolling upgrades has
no reason to guess that the answer is a different section of the site;
it is the most likely place in these docs for that question to occur, so
it now points at the operator section and at the pre-built packages.
This was deliberately held back while #61 was rewriting that page, and
lands now that it has merged.
Sign up for freeto 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

@GuanzhouSong@guanzhousongmicrosoft