Data migrations create the pipeline service client even when they have nothing to delete
Problem
Two data migrations create the pipeline service client before they check whether there is anything to clean up:
- The OpenMetadata 1.5.0 data migration (MySQL and Postgres) calls
deleteLegacyDataInsightPipelines(getPipelineServiceClient())(v150/Migration.java#L26). The helper looks up the oldOpenMetadata.OpenMetadata_dataInsightingestion pipeline, which Data Insights used before it became an app in 1.5. Only if that pipeline exists does it hard-delete it, which also removes its deployed workflow from the orchestrator (v150/MigrationUtil.java#L115-L141). - Collate's 2.0.0 data migration follows the same pattern through the same helper, to remove agent apps that 2.0 replaced. It also has nothing to remove on a new install.
getPipelineServiceClient() (MigrationProcessImpl.java#L57-L63) builds the client straight away. Building a client can fail for reasons unrelated to the database, such as a config file the client reads at startup that is not there. When it fails, the whole migrate stops, even when there is nothing to delete. On a new install there never is: the legacy Data Insights pipeline only exists on databases created before 1.5.0.
The failed run also leaves the database partly migrated, which is the state where #34382 shows up.
How it was hit
A new Collate 2.0.3 install on Postgres with the Helm chart's argoWorkflows.customConfig enabled. The chart gives the run-db-migrations init container the path /custom-config/workflow-params.yaml but does not mount the file (open-metadata/openmetadata-helm-charts#543). The Argo client reads that file in its constructor, so the first migrate, on an empty database, stopped in the 1.5.0 data migration:
Failed to db migration due to
org.openmetadata.sdk.exception.PipelineServiceClientException: Error trying to load PipelineServiceClient io.collate.pipeline.argo.ArgoServiceClient: java.lang.RuntimeException: Error initializing Argo Service Client due to [org.openmetadata.sdk.exception.PipelineServiceClientException: Failed to load ingestion workflow spec config file from [/custom-config/workflow-params.yaml]: /custom-config/workflow-params.yaml]
at org.openmetadata.service.clients.pipeline.PipelineServiceClientFactory.createPipelineServiceClient(PipelineServiceClientFactory.java:103)
at org.openmetadata.service.migration.api.MigrationProcessImpl.getPipelineServiceClient(MigrationProcessImpl.java:58)
at org.openmetadata.service.migration.postgres.v150.Migration.runDataMigration(Migration.java:26)
at org.openmetadata.service.migration.api.MigrationWorkflow.runStepAndAddStatus(MigrationWorkflow.java:565)
at org.openmetadata.service.migration.api.MigrationWorkflow.runMigrationWorkflows(MigrationWorkflow.java:462)open-metadata/openmetadata-helm-charts#543 fixes the mount. This issue is about the migration itself: with nothing to delete, it should not need the client, so no problem around the pipeline service client setup can stop a new install.
Steps to reproduce
Reproduced with the Collate 2.0.3 server image on Postgres 16, running ./bootstrap/openmetadata-ops.sh migrate directly (no Kubernetes needed):
- Use an empty database, with
PIPELINE_SERVICE_CLIENT_CLASS_NAME=io.collate.pipeline.argo.ArgoServiceClientandARGO_INGESTION_WORKFLOW_SPEC_FILE_PATHpointing at a file that does not exist. - Run
migrate. It stops in the 1.5.0 data migration with the error above, although the database has no Data Insights pipeline to delete.
Expected behaviour
A data migration creates the pipeline service client only when it has something to remove from the orchestrator. When there is nothing to delete, migrate completes even if the client cannot be built.
Suggested approach
- Let migrations get the client lazily, for example through a
Supplier<PipelineServiceClientInterface>provided byMigrationProcessImpl, and have the cleanup helpers call it only after they find something to delete. Doing it in the shared helper covers extension migrations that use it too. - When there is something to delete, behaviour stays as it is today: the client is created and the workflow is removed from the orchestrator.
Changing these helpers is safe for databases that already ran these versions. The runner records each applied version in SERVER_CHANGE_LOG and never runs its Java data migration again, so only new installs and upgrades that have not reached those versions run the new code. No SQL changes are involved.
Tests to include with the fix
- With no legacy Data Insights pipeline and a client supplier that throws,
deleteLegacyDataInsightPipelinescompletes without calling the supplier. - With the pipeline present, the client is created and its
deletePipelineis called, as today.
Related issues
- open-metadata/openmetadata-helm-charts#543: the chart does not mount
custom-configinrun-db-migrations. - #34382: on a partly migrated database, pending native migrations run before pending extension migrations, so a retry after a failure like this one can fail again.
Source: open-metadata/OpenMetadata