Repository navigation
feat: check the service info's environment - #348
Conversation
Refuse to start if the environment of the service info isn't one of the values allowed for services, with an error naming both settings. An empty list allows any value, and a service info without `environment` passes, as for services. The defaults pass (`dev` is in the default list), so only deployments that changed one of the two are affected. Closes #346 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Set the service info's environment in the example of allowed environments, as the app refuses to start otherwise. Parametrize the test of allowed environments, and wrap the changed paragraph. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR adds an app-startup guard ensuring service_info.service.environment is compatible with custom.endpoints.services.environments, with deliberate handling for empty allowlists and missing/null values, comprehensive tests, and synchronized operator documentation. Sequence diagram for service environment startup validationsequenceDiagram
participant App
participant ServiceInfo as service_info
participant Config as custom_config
App->>ServiceInfo: check_service_info_environment()
ServiceInfo->>Config: get_custom_config(CustomConfig)
Config-->>ServiceInfo: environments
alt environment is missing or null
ServiceInfo-->>App: return
else environments is empty
ServiceInfo-->>App: return
else environment is in environments
ServiceInfo-->>App: return
else environment is not allowed
ServiceInfo-->>App: raise RuntimeError
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #348 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 2426 2436 +10
=========================================
+ Hits 2426 2436 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#346 feat: check the environment of the service info · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Refuse to start when the service info environment is not allowed, with an error naming both settings. | ✅ Met | The startup check raises a RuntimeError naming both settings and is called during app creation. |
| 2 | Allow any environment when the list is empty, and allow service info without an environment. | ✅ Met | The check returns for an empty allowed list or a missing/null environment. |
| 3 | Explain the defaults and the mismatch impact in the docs and upgrade notes. | ✅ Met | The docs and upgrade notes state that the defaults pass and deployments with a mismatch must adjust their configuration. |
Sourcery assessment
Needs a human reviewer. A deployment whose allowed service environments omit the service-info environment will now abort app startup, leaving the service unavailable until the config is changed or the code is rolled back. Reverting restores the prior startup behavior, but cannot undo any downtime already incurred.
Summary
The app now refuses to start if the environment of its service info (
service_info.service.environment) isn't one of the values allowed for services (custom.endpoints.services.environments), with an error naming both settings.environment(alsonullin an overlay) passes, as for services. Values are compared case-sensitively, also as for services.devis in the default list, so the defaults pass and nothing changes for deployments that changed neither setting. Deployments with a mismatch no longer start; the configuration guide, chart README, upgrade notes and release notes say so. The example of allowed environments in the configuration guide now also sets the service info's environment.Closes #346
How it was verified
coverage run --source cloud_registry,scripts -m pytest, mongomock: 1969 passed, 11 skipped, before the last small test and docs commit. The local coverage report was unreliable, as I edited a docstring ofcloud_registry/app.pyduring the run (line numbers shifted).Test (mongomock)with its 100 % coverage gate andTest (MongoDB 7.0).MONGODB_TEST_URI=... pytest tests/ga4gh tests/test_app.pyagainstmongo:7.0in a container: passed.pre-commit runon the changed files: passed;mkdocs build --strict: passed; version guard (tests/test_version_mentions.py): passed.adversarial-reviewerandquality-reviewer: three low findings, all fixed;light lanewasn't used.Declined review findings
None.
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Ensure the service info environment matches the environments permitted for registered services before starting the application.
New Features:
Enhancements:
Documentation:
Tests: