Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Deprovision doesn't remove the error field if it exists #578

Closed
amitgalitz opened this issue Mar 14, 2024 · 2 comments · Fixed by #635
Closed

[BUG] Deprovision doesn't remove the error field if it exists #578

amitgalitz opened this issue Mar 14, 2024 · 2 comments · Fixed by #635
Assignees
Labels
bug Something isn't working v2.14.0

Comments

@amitgalitz
Copy link
Member

What is the bug?

If provisioning has a failure on one of the steps we write to the error field in the state index. However when we deprovision that same workflow we don't remove the error message from the document in the workflow state index.

How can one reproduce the bug?

  1. Provision with an expected failure (easy way is to provision a pipeline with a processor that isn't in your cluster)
    2.Deprovision the same workflow:

resulting state index:

            {
                "_index": ".plugins-flow-framework-state",
                "_id": "QljrPY4BJDcxHyOJPUNd",
                "_score": 1.0,
                "_source": {
                    "workflow_id": "QljrPY4BJDcxHyOJPUNd",
                    "state": "NOT_STARTED",
                    "provisioning_progress": "NOT_STARTED",
                    "provision_start_time": 1710435961112,
                    "resources_created": [],
                    "provision_end_time": 1710435828966,
                    "error": "org.opensearch.flowframework.exception.WorkflowStepException during step create_ingest_pipeline, restStatus: BAD_REQUEST"
                }
            }
            

What is the expected behavior?

error field shouldn't be there anymore

Potential solution

Some potential solution

  1. We can either simply place the error field as an empty string, however this isn't prefered because if the error field wasn't there to begin with now we have the field with just "error": "".
  2. You can't directly remove the field through update, this has to be done through a script as far as I know. You also can't provide both a contentMap(doc) and a script in the same update request. This means we either have to just update the logic here https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/transport/DeprovisionWorkflowTransportAction.java#L230 to update with a script that removes the error field if it exists (e.g "if (ctx._source.contains(error)) { ctx._source.remove('error)}") and updates the other fields accordingly or we have to make two update operations, one with the current way we do it with a new doc and another with the painless script
@amitgalitz amitgalitz added bug Something isn't working untriaged labels Mar 14, 2024
@dbwiddis
Copy link
Member

It's not a bug, it's a feature! 😁

Seriously, though, this is very interesting. I'm not overly concerned a provisioning error hangs around after deprovisioning the failure (although should we re-populate it with deprovisioning failures, that I don't think we do?). More importantly if I provision a second time does the error remain even if provisioning was successful?

@dbwiddis
Copy link
Member

dbwiddis commented Apr 1, 2024

While implementing #631 I couldn't use the field-by-field update or script, so I added some helper methods to WorkflowState that would enable this:

  • Create a builder using the existing state
  • update the fields as necessary (e.g., set error to null)
  • just index the new document to overwrite the old one, instead of using update.

See https://github.com/opensearch-project/flow-framework/pull/631/files#diff-d49816ce76f874e242a545dd3de0515c2435ec7a6a315faf83ae28e4069f08e0, some of those changes should probably be kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.14.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants