Skip to content

Airflow plugin Phase 2: clean-room rebuild of openmetadata-airflow-apis (steps 0-7) - #151

Merged
BMJLearnToHelloWorld merged 15 commits into
mainfrom
m2-airflow-plugin
Nov 6, 2026
Merged

BMJLearnToHelloWorld merged 15 commits into
mainfrom
m2-airflow-plugin

Conversation

@BMJLearnToHelloWorld

@BMJLearnToHelloWorld BMJLearnToHelloWorld commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Airflow 插件重建 Phase 2:clean-room 重建官方 openmetadata-airflow-apis

将官方 CCL 插件 openmetadata-airflow-apis(pin a3012259ca)按 server 调用契约 clean-room 重写,落在产品包 smartmetadata-airflow-apis 上,并补齐启动脚本、DAG 镜像与 compose 接线。官方 Airflow 本体是 Apache-2.0,用官方镜像,不重建;只重写集成层。

分支已从新主干 6b9faf35(#155 合入后)更新,头 6267cb94。53 文件,+5467/−221,对主干零冲突(dry-run tree c9d394c1,mergeable_state clean)。

Ruling:~/workspace/work/airflow-plugin/RULING.md(Phase 1 深研 + 步 2–7 定案与纠正);实施日志:~/workspace/work/airflow-plugin/IMPLEMENTATION.md;verify-rebuild 修复记录:~/workspace/work/pr151-verify-rebuild/FIX.md。

验收(当前状态)

  • apis 单元:本地 Airflow venv 80 passed;verify-rebuild 门禁 venv 66 passed + 14 skipped(见下残留)。
  • ingestion 针对性测试:24 passed(MySQL/postgres authType password 缺陷修复含测试——两处均在产品包 smartmetadata-ingestion/)。
  • verify-rebuild CI 在新头 6267cb94 上 SUCCESS;service-unit-tests、java-checkstyle、ui/py-checkstyle 均绿;maven-sonarcloud-ci 未跑(path-filter,未碰 openmetadata-service/**)。

verify-rebuild 修复(f889c4ea,7 行)

门禁 venv 不装 Airflow(by design),11 个测试因 ModuleNotFoundError: No module named 'airflow' 失败。修复:在 test_builders.py(6 行)与 test_plugin.py(1 行)加 pytest.importorskip("airflow"),与 plugin.py 的降级约定一致。零产品代码改动。本地核验:门禁 venv 66 passed + 14 skipped,Airflow venv 80 passed。

残留:11 个测试在 CI 里 skip

修复后这 11 个测试在 CI 中 skip——build_dag 与 SmartMetadataPlugin 类在 CI 中无覆盖;完整 80 个只在本地 Airflow venv 跑过。后续:加一个 Airflow CI job,或明确接受门禁-only 的契约覆盖。不要把“本地 80 全过”等同于 CI 覆盖。

各步验收

步 内容 验收
0 契约测试先行 16 个契约测试红起
1 骨架 + 健康 + 认证 三前缀挂载(带 /openmetadata)、health/health-auth/csrf-token、Basic + 权限 fail closed
2 deploy 翻译层(T-1~T-4)+ workflow factory + AirflowBackend.deploy;真实 Airflow deploy 门禁 PASS(config JSON 已写且 JWT 已 pin,DAG 已渲染,DagModel + SerializedDagModel 已注册)
3 trigger + status + logs 真实门禁 PASS:trigger 回 server mint 的 UUID、run 6.3 秒达 success、logs 取回 1 chunk 2286 字符
4 run_automation 执行器落在 ingestion 包 automations/execute.py(server 发加密 Workflow、按名重取解密版);真实门禁 7/7(协议级 MySQL stub + OM stub)
5 enable/disable/delete/kill/ip 单元 29 全过;真实门禁 PASS(delete DB 先文件后、删失败文件留着;kill 置 RUNNING/QUEUED 为 FAILED)
6 workflow builders metadata/profiler/usage/lineage 四型各一真实 pipeline 全链打通;TestSuite/dbt/dataInsight/autoClassification deploy 500;单元 35 全过
7 启动脚本 + DAG 镜像 + compose 见下

步 7

  • 插件入口:此前树里根本没有 entry point(无 plugin.py、无 entry points 声明)——步 7 门禁逼它现形。新建 plugin.py(SmartMetadataPlugin,单 blueprint /api/v2/openmetadata + Admin 视图)与 views/rest_api.py,pyproject.toml 加 [project.entry-points."airflow.plugins"]。
  • CSRF 纠正(步 7 关键发现):步 1 的 CSRF 设计在生产挂载下不完整——11 条路由只在注释里称豁免、实际未对 FAB 的 CSRFProtect 豁免,真实 api-server 下 POST deploy 400 "The CSRF token is missing"。步 7 按官方原样补齐(12 条路由经 FAB 的 csrf 对象 @csrf.exempt,csrf-token 与 status 不豁免;csrf-token 路由优先返回 Flask-WTF 会话 token)。另补 blueprint 认证 fallback 与默认 store 选择。
  • 启动脚本:docker/rebuild/airflow-entrypoint.sh,clean-room 重写官方行为(同 env 默认值、同三进程形、同每次 airflow db migrate、同口令文件合并 upsert)。Bai 17:18:admin/admin 默认;口令经环境变量传给内嵌 Python;mkdir -p logs。
  • DAG 镜像:docker/rebuild/Dockerfile.airflow(底 apache/airflow:3.3.2-python3.12;USER 序列与官方同;约束文件只 pin 插件安装,全部是门禁 venv 里与 Airflow 3.3.2 同跑过的版本;FAB provider 显式安装;mysqlclient==2.1.1 + ingestion [postgres,mysql,kafka,snowflake];构建时 airflow db migrate && rm -f airflow.db)+ .dockerignore + 约束文件。
  • compose:airflow service(Bai 17:18:8080:8080 全开、无资源限制、DB 口令 airflow_pass;depends_on mysql healthy;healthcheck 用插件公开 /health)。server 开关仍 "false",本 PR 不翻开关、不部署。
  • postgres 同款缺陷:postgres.py:314 改调 password_of + 新测试(与步 6 的 MySQL 缺陷同类)。

U 系列处置

  • U-1(health-auth 版本):已决,报 2.0.0-SNAPSHOT。
  • U-2(dbt/es_reindex/application/autoClassification):已决(步 6),四型均无产品执行映射,不建 builder,deploy 500;执行能力记下一里程碑残留。
  • U-3(Data Diff live 链):已决(步 6),无 live 链,插件不做;触发设计留待下一里程碑。
  • U-4(run_automation 执行器落点):已决(步 4),ingestion 包 automations/execute.py,按名重取。
  • U-5(admin 口令默认):已决(Bai 2026-11-06 17:18),admin/admin 官方默认;ruling 各处“生成口令”表述已纠正。

部署说明(合入后)

  • 本 PR 不翻 server 开关(仍 "false")、不部署。
  • 部署时须先加 airflow service 到产品 compose(compose 里实际没有 airflow service,只有两处注释提到它),再翻 PIPELINE_SERVICE_CLIENT_ENABLED 为 "true" + 4 个 env var,建 airflow_db/user,重建 server,逐个 deploy 已有 pipeline,全链 live 验证。
  • docker build(Dockerfile.airflow)首次真实验证在部署时;FAB Admin 视图的可达 URL 未断言(server 契约不依赖它)。
  • 下一里程碑残留(ruling 记):MySQL usage live reader、TestSuite 渲染层、U-2 四型执行能力、Data Diff 触发设计。

复核状态

  • 全量复核 APPROVE(2026-11-06 19:28);verify-rebuild 修复复核 APPROVE(2026-11-06 23:08);新头 CI 全绿(verify-rebuild SUCCESS)。

…ctory/builders, AirflowBackend.deploy, store protocol + handlers rewrite, packaging fix)
…nId conf-first, file-streamed logs + TaskLogReader fallback)
…ackend (DB-first delete, fail unfinished runs, real host ip)
…OnError omission for profiler; mysql source reads authType password (fixes 1045 on server-fetched configs)
…exemption via FAB csrf, startup script, DAG image, airflow compose service; postgres authType password fix
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

verify-rebuild treated compose service 'airflow' as CCL. Product path now
keeps Apache Airflow + smartmetadata-airflow-apis as a required rebuild
service; CCL names (ingestion, openmetadata-ui/mcp, fuseki) stay forbidden.
Docs/ADR/tests updated. mvn spotless:apply for Metric* unused imports.

Copy link
Copy Markdown
Owner Author

CI fix pushed (ad1c337491): product-path guard no longer treats compose airflow as CCL — required product service (Apache Airflow + smartmetadata-airflow-apis / Dockerfile.airflow); CCL names stay forbidden. PRODUCT_PATH + docker ADR + tests updated. mvn spotless:apply for unused imports in MetricResource / MetricGroupResource. Local: check_product_path_hints pass; product-path unit tests for airflow/ingestion pass (Windows bash path tests still env-noisy). Not merged.

…red dag_id; N-10 non-dict filter pattern is a deploy 400
…ine names; N-11 malformed sourceConfig shapes are a deploy 400
BMJLearnToHelloWorld added a commit that referenced this pull request Nov 6, 2026
… args to 5-component record (main compile error blocking #151) (#152)

* fix(it): EnrichmentTarget call passes 5 args to match 5-component record

* fix(ci): fold ad1c337 Metric* unused-import deletions into #152 (spotless)
The offline rebuild gate installs smartmetadata-airflow-apis/[test] only (flask + pytest, no Airflow by design), but 11 tests added in #151 build real DAGs (via build_dag -> 'from airflow import DAG') or load the plugin entry point, which degrades to None without Airflow. Add pytest.importorskip('airflow') - the same pattern the sibling tests in test_plugin.py already use - so the 11 tests skip in the gate venv and still run where Airflow is installed (80 passed locally in the Airflow venv).

Gate venv: 66 passed, 14 skipped, 0 failed (was 11 failed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant