增加单一源保护全局策略
This commit is contained in:
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS gateway_runner_policies (
|
||||
failover_policy jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
hard_stop_policy jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
priority_demote_policy jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
single_source_policy jsonb NOT NULL DEFAULT '{"enabled":true}'::jsonb,
|
||||
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
status text NOT NULL DEFAULT 'active',
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
@@ -15,8 +16,11 @@ CREATE TABLE IF NOT EXISTS gateway_runner_policies (
|
||||
ALTER TABLE IF EXISTS gateway_runner_policies
|
||||
ADD COLUMN IF NOT EXISTS priority_demote_policy jsonb NOT NULL DEFAULT '{}'::jsonb;
|
||||
|
||||
ALTER TABLE IF EXISTS gateway_runner_policies
|
||||
ADD COLUMN IF NOT EXISTS single_source_policy jsonb NOT NULL DEFAULT '{"enabled":true}'::jsonb;
|
||||
|
||||
INSERT INTO gateway_runner_policies (
|
||||
policy_key, name, description, failover_policy, hard_stop_policy, priority_demote_policy, metadata, status
|
||||
policy_key, name, description, failover_policy, hard_stop_policy, priority_demote_policy, single_source_policy, metadata, status
|
||||
)
|
||||
VALUES (
|
||||
'default-runner-v1',
|
||||
@@ -54,6 +58,7 @@ VALUES (
|
||||
"statusCodes": [408, 429, 500, 502, 503, 504],
|
||||
"keywords": ["timeout", "network", "rate_limit", "overloaded", "temporarily_unavailable", "server_error", "429", "5xx"]
|
||||
}'::jsonb,
|
||||
'{"enabled": true}'::jsonb,
|
||||
'{"seed":"0026_runner_policies"}'::jsonb,
|
||||
'active'
|
||||
)
|
||||
@@ -63,6 +68,7 @@ SET name = EXCLUDED.name,
|
||||
failover_policy = gateway_runner_policies.failover_policy || EXCLUDED.failover_policy,
|
||||
hard_stop_policy = gateway_runner_policies.hard_stop_policy || EXCLUDED.hard_stop_policy,
|
||||
priority_demote_policy = gateway_runner_policies.priority_demote_policy || EXCLUDED.priority_demote_policy,
|
||||
single_source_policy = gateway_runner_policies.single_source_policy || EXCLUDED.single_source_policy,
|
||||
metadata = gateway_runner_policies.metadata || EXCLUDED.metadata,
|
||||
updated_at = now();
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
ALTER TABLE IF EXISTS gateway_runner_policies
|
||||
ADD COLUMN IF NOT EXISTS single_source_policy jsonb NOT NULL DEFAULT '{"enabled":true}'::jsonb;
|
||||
|
||||
UPDATE gateway_runner_policies
|
||||
SET single_source_policy = COALESCE(single_source_policy, '{}'::jsonb) || '{"enabled":true}'::jsonb,
|
||||
metadata = metadata || jsonb_build_object('singleSourcePolicy', '0050_runner_single_source_policy'),
|
||||
updated_at = now()
|
||||
WHERE COALESCE(single_source_policy, '{}'::jsonb) = '{}'::jsonb
|
||||
OR NOT (COALESCE(single_source_policy, '{}'::jsonb) ? 'enabled');
|
||||
Reference in New Issue
Block a user