Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For more information about each release including git tags and artifacts, see [R

### Changed

- Scylla is now optional via `ITEM_INVESTIGATION_AND_STRIKES_ENABLED` ([#918](https://github.com/roostorg/coop/pull/918) by [@sunilatlas](https://github.com/sunilatlas))
- Scylla is now optional via `SCYLLA_ENABLED` ([#918](https://github.com/roostorg/coop/pull/918) by [@sunilatlas](https://github.com/sunilatlas), [#1268](https://github.com/roostorg/coop/pull/1268) by [@thisismissem](https://github.com/thisismissem))
- Settings "Other" tab renamed to "Partial Items" and its settings relocated ([#965](https://github.com/roostorg/coop/pull/965) by [@golden-fox07](https://github.com/golden-fox07))
- Queue deletion is refused while routing rules still reference the queue ([#808](https://github.com/roostorg/coop/pull/808) by [@reitblatt](https://github.com/reitblatt))
- Long text fields in the review console collapse behind a "Read more" control ([#903](https://github.com/roostorg/coop/pull/903) by [@taobojlen](https://github.com/taobojlen))
Expand Down
2 changes: 1 addition & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ HMA_SERVICE_URL=http://localhost:9876
# empty (strike counts read as 0) and writes are dropped. When "false" (or
# "0"/"no"), the SCYLLA_* connection settings below are not required.
# Defaults to enabled.
ITEM_INVESTIGATION_AND_STRIKES_ENABLED=true
SCYLLA_ENABLED=true
SCYLLA_USERNAME=cassandra
SCYLLA_PASSWORD=cassandra
SCYLLA_HOSTS='127.0.0.1:9042'
Expand Down
16 changes: 4 additions & 12 deletions server/iocContainer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,7 @@ export default async function getBottle(
executionContext,
);
},
itemInvestigationAndStrikesEnabled(
process.env.ITEM_INVESTIGATION_AND_STRIKES_ENABLED,
),
itemInvestigationAndStrikesEnabled(process.env.SCYLLA_ENABLED),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deliberately kept the existing name as this method disappears entirely in #1235, and as it is, it's not using isEnvTrue from server/iocContainer/utils.ts and negating it, but instead implementing the inverse — this is why I flattened all env vars to Env.schema.boolean() in #1235, to prevent issues like this.

),
);

Expand All @@ -799,18 +797,12 @@ export default async function getBottle(
bottle.factory('Scylla', () => {
// Scylla backs the item-investigation and user-strike features. Operators
// who don't need those (and don't want to run a Scylla cluster) can set
// `ITEM_INVESTIGATION_AND_STRIKES_ENABLED=false` to swap in a no-op that
// `SCYLLA_ENABLED=false` to swap in a no-op that
// drops writes and returns empty reads, so no `SCYLLA_*` connection env
// vars are required. Defaults to enabled to preserve existing behaviour.
if (
!itemInvestigationAndStrikesEnabled(
process.env.ITEM_INVESTIGATION_AND_STRIKES_ENABLED,
)
) {
if (!itemInvestigationAndStrikesEnabled(process.env.SCYLLA_ENABLED)) {
// eslint-disable-next-line no-restricted-syntax
logJson(
'scylla.disabled ITEM_INVESTIGATION_AND_STRIKES_ENABLED=false; using no-op Scylla',
);
logJson('scylla.disabled SCYLLA_ENABLED=false; using no-op Scylla');
return new NoOpScylla();
}

Expand Down
4 changes: 2 additions & 2 deletions server/scylla/noOpScylla.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Scylla from './scylla.js';

/**
* Tests for the Scylla-disabled path used when
* `ITEM_INVESTIGATION_AND_STRIKES_ENABLED=false`.
* `SCYLLA_ENABLED=false`.
*
* Two things are covered:
* 1. The behavioural contract of {@link NoOpScylla} (drops writes, empty reads,
Expand All @@ -16,7 +16,7 @@ import Scylla from './scylla.js';
* default-enabled (upstream-preserving) behaviour is guarded by a test.
*/

describe('ITEM_INVESTIGATION_AND_STRIKES_ENABLED gate predicate', () => {
describe('SCYLLA_ENABLED gate predicate', () => {
test('defaults to enabled when unset (preserves upstream behaviour)', () => {
expect(itemInvestigationAndStrikesEnabled(undefined)).toBe(true);
expect(itemInvestigationAndStrikesEnabled('')).toBe(true);
Expand Down
6 changes: 3 additions & 3 deletions server/scylla/noOpScylla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { type CqlSelectOptions, type DBDefinition } from './cqlUtils.js';
import Scylla from './scylla.js';

/**
* Parses the `ITEM_INVESTIGATION_AND_STRIKES_ENABLED` feature flag from its raw
* string value (i.e. `process.env.ITEM_INVESTIGATION_AND_STRIKES_ENABLED`).
* Parses the `SCYLLA_ENABLED` feature flag from its raw
* string value (i.e. `process.env.SCYLLA_ENABLED`).
*
* Shared by the `Scylla` DI factory in `iocContainer` (to decide whether to
* return a real Scylla or a {@link NoOpScylla}) and by the unit tests. Defaults
Expand All @@ -24,7 +24,7 @@ export function itemInvestigationAndStrikesEnabled(
/**
* A no-op implementation of {@link Scylla} used when the Scylla-backed features
* (item investigation and user strikes) are disabled via
* `ITEM_INVESTIGATION_AND_STRIKES_ENABLED=false`.
* `SCYLLA_ENABLED=false`.
*
* Scylla has no managed offering on some deployment platforms, and some
* operators do not need the features that depend on it. Rather than gate the
Expand Down
Loading