Repository navigation
feat(bbb-export-annotations): Add env override for bbb-export-annotations - #26662
TiagoJacobs merged 6 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 4
Please check the settings in the CodeRabbit UI or the
|
|
Thanks, this replaces my #26658, which I'm closing. Using A few points from comparing the two:
The compose setup in #26186 will use your variables once this is merged. |
|
hello @imdt-claudiop - please review this PR |
ReviewSummary. This PR replaces the hand-rolled deep merge in FindingsBlocker: a malformed override file no longer stops the service; it silently runs on defaults try { envConfig = JSON.parse(process.env.NODE_CONFIG); }
catch(e) { console.error('The $NODE_CONFIG environment variable is malformed JSON'); }It does not throw: startup continues with only if (fs.existsSync(OVERRIDE_PATH)) {
let fileOverride;
try {
fileOverride = JSON.parse(fs.readFileSync(OVERRIDE_PATH, 'utf8'));
} catch (e) {
throw new Error(`Invalid JSON in ${OVERRIDE_PATH}: ${e.message}`);
}
// merge with an existing NODE_CONFIG (see point 1 below) and re-serialize
process.env.NODE_CONFIG = JSON.stringify(fileOverride /* merged */);
}Suggestion: environment variable names break with the sibling PRs and the other node-config services Suggestion: map only what a deployment actually needs to set Suggestion: Nit: the code comment names a variable that doesn't exist Nit: Nit: env values are parsed strictly and quietly On tibroc's three points
On "Updated documentation"The two doc changes only rename
The checkbox should stay unchecked until that is added. |
|
@imdt-claudiop recheck again |
Follow-up review (head
|
| Finding | Status |
|---|---|
| Blocker: malformed override silently ignored | Fixed. config.js:16-25 parses the file before handing it to config and throws Invalid JSON in /etc/bigbluebutton/bbb-export-annotations.json: <reason>, so it fails loudly and names the file. |
tibroc's point 1: existing NODE_CONFIG silently skips the file |
Addressed by forbidding it (config.js:5-9). Rejecting a pre-set NODE_CONFIG is a fine answer, simpler than merging, but as written it breaks the workers (new blocker above). |
| Env set too wide | Fixed. config/custom-environment-variables.json now maps only log.level, the shared.* paths, process.rasterizeTimeoutSeconds, bbbWebAPI and redis.host/port/password. That covers the docker motivation: Redis host/port/password, the bbb-web URL, the dropbox dir and the log level. Nothing needed was dropped; the paths in sync with akka-apps/bbb-web, the channels and the message names are no longer exposed. |
NODE_ENV=production strictness warning |
Fixed. config/production.json ({}) is a deployment file that matches production, so the check finds a file and stays quiet. Workers load the same directory, so they are covered too. It is not excluded by .dockerignore or .build-files, so it ships in the image and in the .deb. Nit: no trailing newline. |
| Naming convention (tibroc's point 3) | Resolved: shared settings are unprefixed (REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, BBB_WEB_HOST), component settings keep BBB_EXPORT_ANNOTATIONS_*. That matches sfu/webhooks and the sibling PRs. One follow-up on BBB_WEB_HOST below. |
docker/README.md not updated |
Fixed (table row and image contract section), in the same shape as the sfu/webhooks entry. |
Nit: CAIRO_SVGUNSAFE_FLAG |
Gone, the key is no longer mapped. |
| Nit: strict boolean/number parsing | Mostly moot: no boolean is mapped anymore. The two numbers (REDIS_PORT, ..._RASTERIZE_TIMEOUT_SECONDS) still turn a non-numeric value into undefined quietly; optional half sentence in the README. |
| Nit: code comment names a variable that doesn't exist | Still open. config.js:14 now gives BBB_EXPORT_ANNOTATIONS_BBB_WEB_API=https://example.com as the example, which is not mapped (the variable is BBB_WEB_HOST), and the )) is still there. |
New suggestions
BBB_WEB_HOST holds a URL here but a bare host in shared-notes
bbb-export-annotations/config/custom-environment-variables.json:18
Here BBB_WEB_HOST maps to bbbWebAPI, a full URL (the README example is http://web:8090). In #26656, shared-notes reads the same name into config.bbbWeb.host, a bare host with the port kept separately (port: 8090). A compose file that shares one value between the two services breaks one of them: web gives this component no scheme or port, and http://web:8090 gives shared-notes an invalid host. Either rename this one (e.g. BBB_WEB_URL) or align both PRs on one shape. Since the point of the plain names is sharing them across containers, the same name should mean the same thing.
Nit: the catch block reports every error as invalid JSON
bbb-export-annotations/lib/utils/config.js:18-23
readFileSync sits inside the same try, so a permission error (EACCES, e.g. the file is root:root 0600 and the service runs as bigbluebutton) becomes Invalid JSON in ...: EACCES .... The path is right but the label sends the admin to look for a syntax error. Moving the read out of the try, or using Cannot read ${OVERRIDE_PATH} for read errors, fixes it.
Optional: mention the NODE_CONFIG restriction
Now that a pre-set NODE_CONFIG makes the service refuse to start, a line in the export-annotations entry of docker/README.md saves someone a confused restart loop.
b9428c4 to
f67546c
Compare
|
@imdt-claudiop recheck again |
Follow-up review (head
|
f67546c to
eb0662e
Compare
|
@imdt-claudiop recheck again |
Follow-up review (head
|
| Finding | Status |
|---|---|
| Malformed override silently ignored | Fixed by design. config reads the override as a regular file and throws Cannot parse config file: '<path>': ... on invalid content. |
EACCES labeled "Invalid JSON" |
Fixed by design. An unreadable file now fails with Config file <path> cannot be read. Error code is: EACCES. |
tibroc's point 1, existing NODE_CONFIG skips the file |
Moot. The code no longer injects anything through NODE_CONFIG; an operator-set NODE_CONFIG just merges on top of the files, which is standard node-config behavior. |
Worker threads and NODE_CONFIG |
Sound. lib/utils/config.js:1-6 is now a plain import config from 'config'. Workers inherit NODE_ENV and NODE_CONFIG_DIR from the process environment and load the same files as the main thread, with no special case. |
Comment example naming an unmapped variable, stray ) |
Gone, the comment was rewritten (see the nit below). |
BBB_WEB_HOST URL vs bare host in #26656 |
Fixed. Renamed to BBB_WEB_API (config/custom-environment-variables.json:18), matching the config key and its URL shape. docker/README.md follows. |
NODE_ENV=production warning |
Still fine. production.json now exists in both directories. |
New scope
Suggestion: upgrading servers lose their override with no warning from the service
build/packages-template/bbb-export-annotations/after-install.sh, bigbluebutton-config/bin/bbb-conf:852-857
After the package upgrade, /etc/bigbluebutton/bbb-export-annotations.json is ignored. The docs tell admins to put redis.password exactly there (configuration-files.md, the Redis password table). On a server with requirepass, the service then runs without the password and fails on its first Redis command, in a restart loop whose log doesn't point at the moved file.
The bbb-conf check itself is correct. It runs in check_configuration, reached from check_state (bbb-conf --check). It fires only while the old file exists, which is exactly when that file is being ignored, so there are no false positives; it also correctly keeps warning when both files exist. The weakness is reach: it only helps admins who run --check. Two cheap ways to close the gap, either one is enough:
- in
after-install.sh: if the old file exists and the new one doesn't,mkdir -p /etc/bigbluebutton/bbb-export-annotationsand move (or copy) it, then print a line saying so; - or have the service log a warning at startup when the old path exists, so the hint lands in
journalctl -u bbb-export-annotations, next to the failure.
The release-notes mention in docs/docs/new-features.md is good and should stay either way.
Suggestion: list the /etc directory last in NODE_CONFIG_DIR
build/packages-template/bbb-export-annotations/bbb-export-annotations.service:15, bbb-export-annotations/Dockerfile:20-21, bbb-export-annotations/run-dev.sh:19-21
config sorts the files it finds by base name (default, then production, then local...). Reading locateMatchingFiles, files with the same name keep the order the directories have in NODE_CONFIG_DIR, and later files win the merge. With /etc/...:/usr/local/.../config/, the shipped config/production.json is merged after the admin's /etc/.../production.json. Today that is harmless only because the shipped file is {}; the day someone puts a key in it, that key silently beats the admin's override. Putting the app directory first (/usr/local/bigbluebutton/bbb-export-annotations/config/:/etc/bigbluebutton/bbb-export-annotations/) makes the admin file win by construction. Worth a quick test with a temporary key in the shipped file to confirm.
Suggestion: an unreadable /etc directory is skipped silently
config lists each directory inside a try with an empty catch. A missing directory being skipped is what we want, because a fresh install has no override. But a directory the bigbluebutton user can't list (say an admin creates it 0700 root to protect the Redis password) is skipped the same way: the service runs on defaults with no message. An unreadable file does fail loudly, so the gap is only the directory. A short permissions note in configuration-files.md (directory 0755, file readable by bigbluebutton) covers it.
Nit: the new comment overstates what is read
bbb-export-annotations/lib/utils/config.js:1-3
NODE_CONFIG_DIR doesn't limit loading to default.json and the /etc override. config also reads config/production.json, custom-environment-variables.json, and any local*, <hostname>* or other supported extension (.yml, .json5, .js...) in both directories. Something like "settings come from default.json, the production.* files in both directories of NODE_CONFIG_DIR, then the env vars mapped in custom-environment-variables.json" would be accurate.
Docs
docker/README.md: the env variables, the new path and the precedence (env over the mounted file) are documented, in the same shape as sfu/webhooks. Matches the code.docs/docs/administration/configuration-files.md:39and the Redis password table: both now point at the new path. Nit: the struck-through old path inside a table cell is hard to read. The new path plus "(was/etc/bigbluebutton/bbb-export-annotations.jsonbefore 4.1)" says the same thing more plainly.docs/docs/new-features.md: the move is called out for the 4.1 notes.- The env variables are documented only in
docker/README.md. That fits the docker motivation; for bare metal, the/etcfile stays the documented way, which is fine.
Nits
- PR title:
feat(bbb-export-annotation)is missing thesof the component name. config/production.jsonstill has no trailing newline.
Replace the hand-written loader with node-config, configured like bbb-webrtc-sfu: - config/settings.json becomes config/default.json - the override is /etc/bigbluebutton/bbb-export-annotations/production.json, found through NODE_CONFIG_DIR, which the systemd unit, the Dockerfile and run-dev.sh set - environment variables listed in config/custom-environment-variables.json (REDIS_*, BBB_WEB_API and a few BBB_EXPORT_ANNOTATIONS_* settings) take precedence over both files - nothing sets NODE_CONFIG, so the master and its workers resolve the same settings - an empty config/production.json silences node-config's warning when no override exists Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
/etc/bigbluebutton/bbb-export-annotations.json is no longer read; the override now lives in /etc/bigbluebutton/bbb-export-annotations/production.json. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
If /etc/bigbluebutton/bbb-export-annotations.json exists and the new /etc/bigbluebutton/bbb-export-annotations/production.json does not, after-install.sh moves it, so settings such as the Redis password survive the upgrade. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ide path Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
3b4cb62 to
bf07013
Compare
|
@imdt-claudiop recheck again |
…e service user Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Follow-up review (head
|
| Item | Status |
|---|---|
NODE_CONFIG_DIR order (/etc must come last so the admin file wins) |
Fixed in all three places: bbb-export-annotations.service:15, Dockerfile:20-21, run-dev.sh:21. |
Unreadable /etc directory skipped silently |
Addressed in the docs: the new paragraph after the Redis password table in configuration-files.md says the directory must be 0755 and the file readable by bigbluebutton, or the override is skipped without a message. |
| Overstated comment | Fixed. lib/utils/config.js:1-3 now says default.json, the production.json files in both directories (/etc last), then the mapped env vars. That is accurate for everything this component ships. |
production.json trailing newline |
Fixed. |
| Struck-through old path in the docs table | Fixed: configuration-files.md:39 reads .../production.json (was /etc/bigbluebutton/bbb-export-annotations.json before 4.1). |
| PR title | Fixed. |
bbb-conf and docs
bigbluebutton-config/bin/bbb-conf:852-857: unchanged. Still correct. Nit: after this PR the old file only survives the upgrade when the new one already existed, so "Move it to ..." will usually find a target that is already there. "Merge it into/etc/bigbluebutton/bbb-export-annotations/production.jsonand remove it" fits that case better.docker/README.md,configuration-files.md(both tables plus the permissions note) andnew-features.md: consistent with the code. Optional: thenew-features.mdentry could add that the package moves the file automatically on upgrade, so admins know they only need to act when both files exist.
New findings
None besides the chown suggestion above.
mv keeps the owner and mode, so the service can still read the file. The chown made it writable by the service user, which could then change the binaries it executes (shared.cairosvg and others) or the Redis password. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
✅ Automated tests have passed! |
|
merging, considering I'll do a follow-up PR with a small fix tonight |
b26dba2
into
bigbluebutton:v4.1.x-develop
What does this PR do?
This PR adds env support for bbb-export-annotations
/etc/bigbluebutton/bbb-export-annotations.jsonto/etc/bigbluebutton/bbb-export-annotations/production.jsonNote: The pattern used by other packages, e.g. bbb-webrtc-sfu
@antobinary: Mention override file change in release notes
Motivation
Docker setup not needing override files to get the basic setup running
How to test
More