Title: Keep Alloy starting when an Elasticsearch exporter credential is gone by shipmill-romamo[bot] · Pull Request #328 · cloudfall-dev/cloudfall · GitHub
Open Graph Title: Keep Alloy starting when an Elasticsearch exporter credential is gone by shipmill-romamo[bot] · Pull Request #328 · cloudfall-dev/cloudfall
X Title: Keep Alloy starting when an Elasticsearch exporter credential is gone by shipmill-romamo[bot] · Pull Request #328 · cloudfall-dev/cloudfall
Description: Summary
With metrics.enabled on an Elasticsearch service, the Alloy drop-in loaded the node's cloudfall password (and, with remoteAccess, the project CA) with a bare LoadCredential= on an absolute path. When that file went away after logging deploy (the service removed from the project, its files cleaned up), systemd refused to start alloy.service on its next restart, so every log and host metric from the host stopped.
The drop-in now pairs each LoadCredential= with a SetCredential= of the same ID holding a single newline. systemd documents that pairing as a default: when the file can't be read the missing file is not fatal and the credential holds the fallback instead (load_credential() in src/core/execute.c on v252, src/core/exec-credential.c on v257; an empty SetCredential=ID: is dropped by the parser, hence the newline). The credential stays a systemd credential only Alloy sees (D-10).
The fallback is also safe for Alloy 1.17.1, which the stack pins: its Elasticsearch exporter trims the password file to an empty password and ignores a CA file without a PEM block, so it starts and only its own scrapes fail. A missing file was worse than a failed load: a missing password file fails Alloy's initial load, and a missing CA file hits log.Fatalf in the exporter's createTLSConfig, which exits the whole process. Now the credential file always exists, so neither can happen.
Removing an Elasticsearch service: Cloudfall has no remove path for services, so taking one out of the project is what removes it. The next logging deploy renders neither its exporter block nor its credential lines, and the preflight that requires the node's files no longer looks for them. Until then, the old drop-in still starts Alloy because of the fallback.
The preflight that refuses logging deploy while the node's files are missing stays. Without it, a collector deployed before its node would send an empty password and fail quietly. Its comment now says why it is kept.
Plan
Serves: quality bar (Q-1)
Files: engine/ansible/roles/cloudfall_logging_collector/templates/alloy-systemd-override.conf.j2, engine/ansible/roles/cloudfall_logging_collector/tasks/main.yml (comment), engine/tests/test_s012_elasticsearch_access.py, changelog.d/326-alloy-optional-es-credential.md
Order: a test that every LoadCredential= in the rendered drop-in has a non-empty SetCredential= fallback with the same ID, and that removing the service drops its exporter and credential lines (fails on main); then the template change; then the comments and the changelog fragment
Proof: uv run pytest engine/tests/test_s012_elasticsearch_access.py engine/tests/test_logging_templates.py, plus ruff, mypy, ansible-lint and cloudfall config validate --project config/examples
Test plan
New test test_a_missing_exporter_credential_falls_back_instead_of_stopping_alloy renders the drop-in with a loopback node and with a remoteAccess node. It checks that each LoadCredential= ID has a SetCredential=
Open Graph Description: Summary With metrics.enabled on an Elasticsearch service, the Alloy drop-in loaded the node's cloudfall password (and, with remoteAccess, the project CA) with a bare LoadCredential= on an absol...
X Description: Summary With metrics.enabled on an Elasticsearch service, the Alloy drop-in loaded the node's cloudfall password (and, with remoteAccess, the project CA) with a bare LoadCredential= on an a...
Opengraph URL: https://github.com/cloudfall-dev/cloudfall/pull/328
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aa8a09be-7c2f-3376-888f-a112234bf1af |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9082:28EBDB:1DE9646:287CC9D:6B055CF5 |
| html-safe-nonce | 1661160ba5f34311f246840fe264b5ae093057bb02e9c987ce90b652544c2ef9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDgyOjI4RUJEQjoxREU5NjQ2OjI4N0NDOUQ6NkIwNTVDRjUiLCJ2aXNpdG9yX2lkIjoiMjA1ODk2NzY5ODEyOTY0MDY5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 700d9adffd529a96acafde687aedb00039c9e81c31da4e21652b107ca4966b32 |
| hovercard-subject-tag | pull_request:5313851624 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/cloudfall-dev/cloudfall/pull/328/files |
| twitter:image | https://avatars.githubusercontent.com/u/5600783?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/5600783?s=400&v=4 |
| og:image:alt | Summary With metrics.enabled on an Elasticsearch service, the Alloy drop-in loaded the node's cloudfall password (and, with remoteAccess, the project CA) with a bare LoadCredential= on an absol... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8a6760da3cce5e2d079d07e3b62df71194316c4478db1a5e38050f44fce72c72 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/cloudfall-dev/cloudfall git https://github.com/cloudfall-dev/cloudfall.git |
| octolytics-dimension-user_id | 339512759 |
| octolytics-dimension-user_login | cloudfall-dev |
| octolytics-dimension-repository_id | 1360999777 |
| octolytics-dimension-repository_nwo | cloudfall-dev/cloudfall |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1360999777 |
| octolytics-dimension-repository_network_root_nwo | cloudfall-dev/cloudfall |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8327739ac0648b9c3c722b5f401f7338553936b8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width