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 workflow update result, update describe and result commands #658

Merged
merged 8 commits into from
Sep 13, 2024

Conversation

Sushisource
Copy link
Member

This is functionally complete but certainly open to discussion on the details or output.

What was changed

Added these new commands

Why?

More consistent experience for related concepts

Checklist

  1. Closes [Feature Request] Add workflow result, workflow update result, and workflow update describe #647

  2. How was this tested:
    Added tests

  3. Any docs updates needed?

Here are some examples of what output looks like from the tests:

For workflow result:

    commands_test.go:153: Calling: workflow result --address 127.0.0.1:43621 -w d8144f29-a91f-471b-99d7-61a1fc6aa307
    commands_test.go:156: Stdout:
    -----
        Results:
          Status          COMPLETED
          Result          "hi!"
          ResultEncoding  json/plain
        
        -----
        -----
        {
          "workflowId": "d8144f29-a91f-471b-99d7-61a1fc6aa307",
          "runId": "8a17387c-5259-4c31-a104-fe7b9a9017af",
          "namespace": "default",
          "status": "COMPLETED",
          "closeEvent": {
            "eventId": "7",
            "eventTime": "2024-09-09T23:35:01.915449305Z",
            "eventType": "EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED",
            "taskId": "1048607",
            "workflowExecutionCompletedEventAttributes": {
              "result": [
                "hi!"
              ],
              "workflowTaskCompletedEventId": "6"
            }
          },
          "result": "hi!"
        }
        
        -----
    commands_test.go:153: Calling: workflow result --address 127.0.0.1:43621 -w 5cfabe6e-addf-42fc-a458-0061b63c163a
    commands_test.go:156: Stdout:
        -----
        Results:
          Status   FAILED
          Failure  
            Message: failed on purpose
        
        -----
    commands_test.go:153: Calling: workflow result --address 127.0.0.1:43621 -w 5cfabe6e-addf-42fc-a458-0061b63c163a -o json
    commands_test.go:156: Stdout:
        -----
        {
          "workflowId": "5cfabe6e-addf-42fc-a458-0061b63c163a",
          "runId": "368cc0b6-a47f-47c3-9a2f-43c5aa161cd1",
          "namespace": "default",
          "status": "FAILED",
          "closeEvent": {
            "eventId": "6",
            "eventTime": "2024-09-09T23:35:01.921375049Z",
            "eventType": "EVENT_TYPE_WORKFLOW_EXECUTION_FAILED",
            "taskId": "1048625",
            "workflowExecutionFailedEventAttributes": {
              "failure": {
                "message": "failed on purpose",
                "source": "GoSDK",
                "applicationFailureInfo": {}
              },
              "retryState": "RETRY_STATE_RETRY_POLICY_NOT_SET",
              "workflowTaskCompletedEventId": "5"
            }
          }
        }
        
        -----

For update describe:

  commands_test.go:153: Calling: workflow update start --wait-for-stage accepted --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --name test-update -i "pass" --update-id passing
    commands_test.go:156: Stdout:
        -----
          Name      test-update
          UpdateID  passing
        
        -----
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id passing
    commands_test.go:156: Stdout:
        -----
          UpdateID  passing
          Stage     Accepted
        
        -----
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id passing
    commands_test.go:156: Stdout:
        -----
          UpdateID  passing
          Stage     Accepted
        
        -----
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id passing
    commands_test.go:156: Stdout:
        -----
          UpdateID  passing
          Result    hi pass
          Stage     Completed
        
        -----
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id passing -o json
    commands_test.go:156: Stdout:
        -----
        {
          "updateId": "passing",
          "result": "hi pass",
          "stage": "Completed"
        }
        
        -----
    commands_test.go:153: Calling: workflow update execute --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --name test-update -i "reject" --update-id rejected
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id rejected
    commands_test.go:153: Calling: workflow update execute --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --name test-update -i "fail" --update-id fail
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id fail
    commands_test.go:156: Stdout:
        -----
          UpdateID  fail
          Failure   failing
          Stage     Completed
        
        -----
    commands_test.go:153: Calling: workflow update describe --address 127.0.0.1:45097 -w 7bd9e978-65d9-4991-8c87-3f6e47844938 --update-id fail -o json
    commands_test.go:156: Stdout:
        -----
        {
          "updateId": "fail",
          "failure": {
            "message": "failing",
            "source": "GoSDK",
            "FailureInfo": {
              "ApplicationFailureInfo": {}
            }
          },
          "stage": "Completed"
        }
        
        -----

For update result:

  commands_test.go:153: Calling: workflow update execute --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --name test-update -i "pass" --update-id passing
    commands_test.go:156: Stdout:
        -----
          Name      test-update
          UpdateID  passing
          Result    hi pass
        
        -----
    commands_test.go:153: Calling: workflow update result --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --update-id passing
    commands_test.go:156: Stdout:
        -----
          UpdateID  passing
          Result    hi pass
        
        -----
    commands_test.go:153: Calling: workflow update result --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --update-id passing -o json
    commands_test.go:156: Stdout:
        -----
        {
          "updateId": "passing",
          "result": "hi pass"
        }
        
        -----
    commands_test.go:153: Calling: workflow update execute --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --name test-update -i "reject" --update-id rejected
    commands_test.go:153: Calling: workflow update result --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --update-id rejected
    commands_test.go:153: Calling: workflow update execute --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --name test-update -i "fail" --update-id fail
    commands_test.go:153: Calling: workflow update result --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --update-id fail
    commands_test.go:156: Stdout:
        -----
          UpdateID  fail
          Failure   failing
        
        -----
    commands_test.go:153: Calling: workflow update result --address 127.0.0.1:33535 -w 76ab9ebe-acc1-4615-a4aa-a4ebda4ee568 --update-id fail -o json
    commands_test.go:156: Stdout:
        -----
        {
          "updateId": "fail",
          "failure": {
            "message": "failing",
            "details": {}
          }
        }
        
        -----

An Update is a synchronous call to a Workflow Execution that can change its
state, control its flow, and return a result.

Experimental.

#### Options set for update targeting
Copy link
Member

Choose a reason for hiding this comment

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

The named options set should be under the first command that uses it instead of this command. This now shows that this command accepts these args. Can move and replace the #### Options section for temporal workflow update describe with this section.

* `--workflow-id`, `-w` (string) -
Workflow ID.
Required.
* `--update-id` (string) -
Copy link
Member

Choose a reason for hiding this comment

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

This should be required for describe (and therefore reused for result and make start be the unnamed set that has a UUID default)

Copy link
Member

Choose a reason for hiding this comment

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

Meh, just toss this at the bottom of commands.go IMO

return &structuredError{
Message: err.Error(),
Type: err.Type(),
Details: err.Details(),
Copy link
Member

Choose a reason for hiding this comment

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

.Details expects a pointer to deserialize into and returns an error if it can't. You could have var details any and then err.Details(&details) (checking error) and then set details to in this field

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks good catch

@@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"go.temporal.io/sdk/temporal"
Copy link
Member

Choose a reason for hiding this comment

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

Usually go fmt will get these non-stdlib imports separated from the stdlib ones (here and elsewhere in PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't for me, for whatever reason.

Copy link
Member

Choose a reason for hiding this comment

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

Hrmm, maybe it was goimports or similar that I just assumed was in go fmt by now

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

LGTM, but would like someone that has an eye for CLI output to take a peek (@dandavison?)

@josh-berry
Copy link
Collaborator

Filed #667 for an unrelated failed test on Windows that happened to show up in this PR.

@josh-berry
Copy link
Collaborator

LGTM, but would like someone that has an eye for CLI output to take a peek (@dandavison?)

Took a quick look and it seems reasonable to me. Merging so this can be included in the CLI release on Monday.

@josh-berry josh-berry merged commit a754102 into main Sep 13, 2024
7 checks passed
@josh-berry josh-berry deleted the add-result-describe branch September 13, 2024 21:54
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.

[Feature Request] Add workflow result, workflow update result, and workflow update describe
3 participants