kestra-io / kestra

:zap: Workflow Automation Platform. Orchestrate & Schedule code in any language, run anywhere, 500+ plugins. Alternative to Zapier, Rundeck, Camunda, Airflow...
https://kestra.io
Apache License 2.0
12.98k stars 1.13k forks source link

Deleting a flow duplicates its sources in database #5770

Open brian-mulier-p opened 1 week ago

brian-mulier-p commented 1 week ago

Describe the issue

The bug is present in JDBC (and probably in ES), it's due to the fact that deleting a flow is doing a soft-delete (so still present in database) but the persist method puts the delete: true flag BUT saves a FlowWithSource instead of a Flow along with adding a source_code field:

FlowWithSource deleted = flow.toDeleted();

Map<Field<Object>, Object> fields = this.jdbcRepository.persistFields(deleted);
fields.put(field("source_code"), deleted.getSource());

this.jdbcRepository.persist(deleted, fields);

We should save a raw Flow with delete: true instead to avoid duplicating the source inside the value

image

Environment

asharan2buff commented 1 week ago

Can I work on this?

MilosPaunovic commented 1 week ago

@asharan2buff I've just assigned you to another issues, so let's close that one first, and after you can work on this one if no one picks it up in the meantime.

Malaydewangan09 commented 1 week ago

@MilosPaunovic, can I pick this up? If this is still open Thanks!

mithindev commented 1 week ago

@Malaydewangan09, @brian-mulier-p I investigated the issue and found the following:

The source_code field cannot be null.

image

To address this, I considered using a placeholder value like "deleted" for source_code and setting the deleted flag to true. Is there a better approach to do this?

MilosPaunovic commented 1 week ago

Hi guys @Malaydewangan09, @mithindev,

Maybe we should wait for @brian-mulier-p to give us a guideline here, and then, two of you could collaborate in solving this one, maybe one submitting the change and other one reviewing it?