🛡️ Validate deployed source-index profile for image releases
This commit is contained in:
parent
7b739fd4c6
commit
3353f75900
@ -10,6 +10,12 @@
|
||||
首版只支持 **Fanyu 现有 API 与切片处理器的同一不可变镜像更新**,并同步容器的
|
||||
`DROBOTICFLOW_BUILD_COMMIT`。保留 ConfigMap、Secret、PVC、Service、资源和副本数。
|
||||
需要更改配置、其他组件或数据库时,单独设计并审查变更计划;首版不提供绕过参数。
|
||||
|
||||
2026-10-17 已部署的源索引基线也可做上述镜像更新:处理器必须精确匹配
|
||||
fanyu-policy.json 引用的容量文件(2 副本、每副本 8 修订槽、4 GiB limit、
|
||||
Recreate、source-index/striped/verify-existing)。校验不调整该配置;旧单处理器
|
||||
配置继续按原规则检查,未知角色、资源或模式不匹配则阻断。校验器、Worker、
|
||||
Coordinator 保留当前镜像;更新它们仍须单独审查与授权。
|
||||
`deploy-k8s.sh` 的 Fanyu 全量 apply 入口已阻断,其他环境的原流程不变。
|
||||
|
||||
这是命令行防误操作流程,不是安全边界:操作者仍可以直接运行 kubectl。团队级强制执行
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
"bucket": "drobodata-fanyu",
|
||||
"workspaceMount": "/workspace",
|
||||
"workspacePVC": "droboticflow-workspace",
|
||||
"processorCapacityProfile": "docs/capacity/source-index-100.json",
|
||||
"mongoSecret": "droboticflow-mongo-secret",
|
||||
"deployments": {
|
||||
"droboticflow-api": "api",
|
||||
|
||||
@ -19,6 +19,8 @@ RECORDS = ROOT / 'local-data/releases'
|
||||
POLICY = ROOT / 'docs/release/fanyu-policy.json'
|
||||
SAFE_ENV = ('MONGO_DB', 'DROBOTICFLOW_REQUIRE_SESSION_AUTH',
|
||||
'ANNOTATION_PROCESSOR_MODE', 'ANNOTATION_PROCESSOR_CONCURRENCY',
|
||||
'ANNOTATION_PROCESSOR_ROLE', 'ANNOTATION_SOURCE_INDEX', 'ANNOTATION_INDEX_CONCURRENCY',
|
||||
'DROBOTICFLOW_DATABASE_BOOTSTRAP', 'DROBOTICFLOW_PROJECT_WRITE_LOCK_MODE',
|
||||
'ANNOTATION_INDEX_BACKFILL', 'ANNOTATION_WORKSPACE_CONNECTION_ID',
|
||||
'ANNOTATION_WORKSPACE_BUCKET', 'WORKSPACE_MOUNT_PATH')
|
||||
|
||||
@ -190,11 +192,25 @@ def inspect_deployment(deployment, container_name, configs, p):
|
||||
require(e.get('ANNOTATION_PROCESSOR_MODE') == 'external', 'API must use external processor.')
|
||||
else:
|
||||
require(e.get('ANNOTATION_PROCESSOR_MODE') == 'processor', 'Processor mode mismatch.')
|
||||
require(e.get('ANNOTATION_PROCESSOR_CONCURRENCY') == '1', 'First release profile requires concurrency 1.')
|
||||
require(e.get('ANNOTATION_INDEX_BACKFILL') == '0', 'Historical backfill must remain disabled.')
|
||||
require(c.get('resources', {}).get('limits', {}).get('memory') == '8Gi', 'First release profile requires processor memory limit 8Gi.')
|
||||
require(spec.get('replicas') == 1 and spec.get('strategy', {}).get('type') == 'Recreate',
|
||||
'Processor must have one replica and Recreate strategy.')
|
||||
if e.get('ANNOTATION_PROCESSOR_ROLE') == 'revision':
|
||||
# Recognize the previously approved deployed profile, never resize
|
||||
# it. nonReleaseHash and conditional patches still prohibit drift.
|
||||
profile = json.loads((ROOT / p['processorCapacityProfile']).read_text())
|
||||
require(profile['schemaVersion'] == 1 and profile['profile'] == 'fanyu-source-index-100-v1'
|
||||
and profile['namespace'] == p['namespace'], 'Unsupported capacity profile.')
|
||||
desired = profile['deployments']['droboticflow-annotation-processor']
|
||||
require(all(e.get(k) == v for k, v in desired['env'].items()), 'Source-index processor settings differ from approved capacity profile.')
|
||||
require(c.get('resources') == {k: desired[k] for k in ('requests', 'limits')},
|
||||
'Source-index processor resources differ from approved capacity profile.')
|
||||
require(spec.get('replicas') == desired['replicas'] and spec.get('strategy', {}).get('type') == 'Recreate',
|
||||
'Source-index processor replicas/strategy differ from approved deployed profile.')
|
||||
else:
|
||||
require(not e.get('ANNOTATION_PROCESSOR_ROLE'), 'Unsupported processor role.')
|
||||
require(e.get('ANNOTATION_PROCESSOR_CONCURRENCY') == '1', 'First release profile requires concurrency 1.')
|
||||
require(c.get('resources', {}).get('limits', {}).get('memory') == '8Gi', 'First release profile requires processor memory limit 8Gi.')
|
||||
require(spec.get('replicas') == 1 and spec.get('strategy', {}).get('type') == 'Recreate',
|
||||
'Processor must have one replica and Recreate strategy.')
|
||||
status = deployment.get('status', {})
|
||||
ready = (status.get('observedGeneration', 0) >= deployment['metadata'].get('generation', 1)
|
||||
and status.get('updatedReplicas', 0) == spec.get('replicas', 1)
|
||||
|
||||
@ -122,6 +122,61 @@ class ReleaseTests(unittest.TestCase):
|
||||
self.evidence('change-safety')
|
||||
return argparse.Namespace(confirm_plan=self.r['planHash'], approval_ref='user-message:test')
|
||||
|
||||
def use_current_source_profile(self):
|
||||
profile = json.loads((ROOT / 'docs/capacity/source-index-100.json').read_text())
|
||||
for name, d in self.ds.items():
|
||||
desired = profile['deployments'][name]
|
||||
d['spec']['replicas'] = desired['replicas']
|
||||
c = d['spec']['template']['spec']['containers'][0]
|
||||
c['resources'] = {k: copy.deepcopy(desired[k]) for k in ('requests', 'limits')}
|
||||
overrides = dict(desired['env'])
|
||||
for e in c['env']:
|
||||
if e['name'] in overrides:
|
||||
e['value'] = overrides.pop(e['name'])
|
||||
c['env'] += [{'name': k, 'value': v} for k, v in overrides.items()]
|
||||
d['status'].update({k: desired['replicas'] for k in ('replicas', 'updatedReplicas', 'readyReplicas')})
|
||||
|
||||
def test_current_source_profile_keeps_resources_and_only_updates_image(self):
|
||||
self.use_current_source_profile()
|
||||
before = {name: copy.deepcopy(d['spec']) for name, d in self.ds.items()}
|
||||
self.plan()
|
||||
m.deploy(self.r, self.approve())
|
||||
for name, d in self.ds.items():
|
||||
old = m.inspect_deployment({'metadata': d['metadata'], 'spec': before[name]}, self.p['deployments'][name], self.configs, self.p)
|
||||
current = m.inspect_deployment(d, self.p['deployments'][name], self.configs, self.p)
|
||||
self.assertEqual(old['nonReleaseHash'], current['nonReleaseHash'])
|
||||
self.assertEqual(self.writes, ['droboticflow-annotation-processor', 'droboticflow-api'])
|
||||
|
||||
def test_source_profile_rejects_resource_or_mode_drift(self):
|
||||
self.use_current_source_profile()
|
||||
name = 'droboticflow-annotation-processor'
|
||||
good = copy.deepcopy(self.ds[name])
|
||||
mutations = [
|
||||
('ANNOTATION_PROCESSOR_CONCURRENCY', '16'),
|
||||
('ANNOTATION_SOURCE_INDEX', 'false'),
|
||||
('ANNOTATION_INDEX_CONCURRENCY', '8'),
|
||||
('ANNOTATION_INDEX_BACKFILL', '1'),
|
||||
('DROBOTICFLOW_DATABASE_BOOTSTRAP', 'migrate'),
|
||||
('DROBOTICFLOW_PROJECT_WRITE_LOCK_MODE', 'legacy'),
|
||||
('ANNOTATION_PROCESSOR_ROLE', 'unknown'),
|
||||
]
|
||||
for key, value in mutations:
|
||||
d = copy.deepcopy(good)
|
||||
c = d['spec']['template']['spec']['containers'][0]
|
||||
next(e for e in c['env'] if e['name'] == key)['value'] = value
|
||||
with self.subTest(key=key), self.assertRaises(m.Blocked):
|
||||
m.inspect_deployment(d, 'processor', self.configs, self.p)
|
||||
for key in ('replicas', 'resources', 'strategy'):
|
||||
d = copy.deepcopy(good)
|
||||
if key == 'replicas':
|
||||
d['spec']['replicas'] = 3
|
||||
elif key == 'resources':
|
||||
d['spec']['template']['spec']['containers'][0]['resources']['limits']['memory'] = '2Gi'
|
||||
else:
|
||||
d['spec']['strategy']['type'] = 'RollingUpdate'
|
||||
with self.subTest(key=key), self.assertRaises(m.Blocked):
|
||||
m.inspect_deployment(d, 'processor', self.configs, self.p)
|
||||
|
||||
def test_historical_status_is_readonly_without_fabricated_evidence(self):
|
||||
import contextlib, io
|
||||
for record in [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user