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

Add created, updated, and provisioned timestamps to saved template #551

Merged
merged 11 commits into from
Mar 9, 2024

Conversation

dbwiddis
Copy link
Member

@dbwiddis dbwiddis commented Mar 5, 2024

Description

Adds created time, last updated time, and last provisioned time to the template stored in the global context.

  • Updates the last updated time when updating a workflow
  • Updates the last provisioned time when provisoning a workflow

Also adds BWC tests!

Also fixes Integ tests which were essentially running twice since yamlRestTest was not properly filtered and was running them a second time.

Issues Resolved

Fixes #548

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions github-actions bot added the backport 2.x backport PRs to 2.x branch label Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 77.50000% with 27 lines in your changes are missing coverage. Please review.

Project coverage is 72.81%. Comparing base (e9686f7) to head (3f9a899).

❗ Current head 3f9a899 differs from pull request most recent head c600d9e. Consider uploading reports for the commit c600d9e to get more accurate results

Files Patch % Lines
...ework/transport/CreateWorkflowTransportAction.java 72.34% 12 Missing and 1 partial ⚠️
...rk/transport/ProvisionWorkflowTransportAction.java 53.33% 7 Missing ⚠️
...a/org/opensearch/flowframework/model/Template.java 88.67% 3 Missing and 3 partials ⚠️
...framework/indices/FlowFrameworkIndicesHandler.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #551      +/-   ##
============================================
- Coverage     72.98%   72.81%   -0.18%     
- Complexity      662      675      +13     
============================================
  Files            79       79              
  Lines          3395     3451      +56     
  Branches        264      273       +9     
============================================
+ Hits           2478     2513      +35     
- Misses          803      822      +19     
- Partials        114      116       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joshpalis joshpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, pending fix for failing integration tests. Just a small comment

@dbwiddis
Copy link
Member Author

dbwiddis commented Mar 5, 2024

pending fix for failing integration tests.

Yeah, I chose to update the state index before updating the template in the global context which triggers this. I can easily reverse the order (it made more sense that way) but I wanted to flip the flag to provisioning as soon as possible to avoid a race condition! Will see if there's another workaround.

@dbwiddis dbwiddis force-pushed the add-timestamps branch 2 times, most recently from 9d1089d to 19156ec Compare March 5, 2024 08:00
Signed-off-by: Daniel Widdis <[email protected]>
@dbwiddis
Copy link
Member Author

dbwiddis commented Mar 5, 2024

POST localhost:9200/_plugins/_flow_framework/workflow/
{
  "name": "test",
  "description": "Flow template",
  "use_case": "TESTING",
  "version": {
    "template": "1.0.0",
    "compatibility": ["2.12.0", "3.0.0"]
  },
  "workflows": {
    "provision": {
      "user_params": {},
      "nodes": [
        {
          "id": "test-step",
          "type": "noop"
        }
      ]
    }
  }
}
{
    "workflow_id": "v5icD44BN3l14GXsicR6"
}
GET localhost:9200/_plugins/_flow_framework/workflow/v5icD44BN3l14GXsicR6
{
    "name": "test",
    "description": "Flow template",
    "use_case": "TESTING",
    "version": {
        "template": "1.0.0",
        "compatibility": [
            "2.12.0",
            "3.0.0"
        ]
    },
    "workflows": {
        "provision": {
            "user_params": {},
            "nodes": [
                {
                    "id": "test-step",
                    "type": "noop",
                    "previous_node_inputs": {},
                    "user_inputs": {}
                }
            ],
            "edges": []
        }
    },
    "created_time": 1709658900798,
    "last_updated_time": 1709658900798
}
PUT localhost:9200/_plugins/_flow_framework/workflow/v5icD44BN3l14GXsicR6
{
  "name": "test-update",
  "description": "Flow template",
  "use_case": "TESTING",
  "version": {
    "template": "1.0.0",
    "compatibility": ["2.12.0", "3.0.0"]
  },
  "workflows": {
    "provision": {
      "user_params": {},
      "nodes": [
        {
          "id": "test-step",
          "type": "noop"
        }
      ]
    }
  }
}
{
    "workflow_id": "v5icD44BN3l14GXsicR6"
}
GET localhost:9200/_plugins/_flow_framework/workflow/v5icD44BN3l14GXsicR6
{
    "name": "test-update",
    "description": "Flow template",
    "use_case": "TESTING",
    "version": {
        "template": "1.0.0",
        "compatibility": [
            "2.12.0",
            "3.0.0"
        ]
    },
    "workflows": {
        "provision": {
            "user_params": {},
            "nodes": [
                {
                    "id": "test-step",
                    "type": "noop",
                    "previous_node_inputs": {},
                    "user_inputs": {}
                }
            ],
            "edges": []
        }
    },
    "created_time": 1709658900798,
    "last_updated_time": 1709658977120
}
POST localhost:9200/_plugins/_flow_framework/workflow/v5icD44BN3l14GXsicR6/_provision
{
    "workflow_id": "v5icD44BN3l14GXsicR6"
}
GET localhost:9200/_plugins/_flow_framework/workflow/v5icD44BN3l14GXsicR6
{
    "name": "test-update",
    "description": "Flow template",
    "use_case": "TESTING",
    "version": {
        "template": "1.0.0",
        "compatibility": [
            "2.12.0",
            "3.0.0"
        ]
    },
    "workflows": {
        "provision": {
            "user_params": {},
            "nodes": [
                {
                    "id": "test-step",
                    "type": "noop",
                    "previous_node_inputs": {},
                    "user_inputs": {}
                }
            ],
            "edges": []
        }
    },
    "created_time": 1709658900798,
    "last_updated_time": 1709658977120,
    "last_provisioned_time": 1709659053752
}

@amitgalitz
Copy link
Member

Start and end time should already be in the state index

@dbwiddis
Copy link
Member Author

dbwiddis commented Mar 5, 2024

Start and end time should already be in the state index

Yes, they are.

This should match (within milliseconds) the start time of the latest provisioning attempt. Probably didn't need to add it here, but now that it's here should we leave it or take it back out?

@dbwiddis dbwiddis force-pushed the add-timestamps branch 7 times, most recently from 14fcb40 to 19772b7 Compare March 6, 2024 06:28
@dbwiddis dbwiddis force-pushed the add-timestamps branch 13 times, most recently from 873bf6a to a9b0a51 Compare March 7, 2024 18:03
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test classes yet to be reviewed. Added few comments

Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Few comments

Signed-off-by: Daniel Widdis <[email protected]>
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve on the manual copying of distribution to zip in the future

.github/workflows/test_bwc.yml Show resolved Hide resolved
.github/workflows/test_bwc.yml Show resolved Hide resolved
.github/workflows/test_bwc.yml Show resolved Hide resolved
.github/workflows/test_bwc.yml Show resolved Hide resolved
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for addressing the comments.

@dbwiddis dbwiddis merged commit 2707210 into opensearch-project:main Mar 9, 2024
60 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 9, 2024
)

* Add created, last updated, and last provisioned fields to Template

Signed-off-by: Daniel Widdis <[email protected]>

* Change last updated timestamp when updating workflow

Signed-off-by: Daniel Widdis <[email protected]>

* Change last provisioned timestamp when provisioning workflow

Signed-off-by: Daniel Widdis <[email protected]>

* Allow overriding template not started check

Signed-off-by: Daniel Widdis <[email protected]>

* Use java.time and not joda time

Signed-off-by: Daniel Widdis <[email protected]>

* Preserve timestamps when encrypting and redacting template

Signed-off-by: Daniel Widdis <[email protected]>

* Add bwc tests, more timestamp testing

Signed-off-by: Daniel Widdis <[email protected]>

* Build a Template from an existing one

Signed-off-by: Daniel Widdis <[email protected]>

* Rename param, add comments

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
(cherry picked from commit 2707210)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@dbwiddis dbwiddis deleted the add-timestamps branch March 9, 2024 05:03
dbwiddis added a commit that referenced this pull request Mar 9, 2024
…ved template (#556)

* Add created, updated, and provisioned timestamps to saved template (#551)

* Add created, last updated, and last provisioned fields to Template

Signed-off-by: Daniel Widdis <[email protected]>

* Change last updated timestamp when updating workflow

Signed-off-by: Daniel Widdis <[email protected]>

* Change last provisioned timestamp when provisioning workflow

Signed-off-by: Daniel Widdis <[email protected]>

* Allow overriding template not started check

Signed-off-by: Daniel Widdis <[email protected]>

* Use java.time and not joda time

Signed-off-by: Daniel Widdis <[email protected]>

* Preserve timestamps when encrypting and redacting template

Signed-off-by: Daniel Widdis <[email protected]>

* Add bwc tests, more timestamp testing

Signed-off-by: Daniel Widdis <[email protected]>

* Build a Template from an existing one

Signed-off-by: Daniel Widdis <[email protected]>

* Rename param, add comments

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
(cherry picked from commit 2707210)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update imports for 2.x branch

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Widdis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport PRs to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Support timestamp fields in workflows
4 participants