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

feat(stepfunctions): allow setting comment on state machine #25858

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

curquhart
Copy link
Contributor

Just a small PR to allow setting top level comment on a state machine

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Jun 5, 2023

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Jun 5, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team June 5, 2023 20:16
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review June 5, 2023 22:03

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@curquhart curquhart changed the title feat(sfn): allow setting comment on state machine feat(stepfunctions): allow setting comment on state machine Jun 5, 2023
@curquhart
Copy link
Contributor Author

this is "ready" but the build is failing for what appears to be an unrelated reason... going to mark as draft until i have the cycles to look into that more thoroughly (also going to update from main in case it was just a flake)

@curquhart curquhart marked this pull request as draft June 6, 2023 22:24
@curquhart curquhart marked this pull request as ready for review June 7, 2023 00:03
@curquhart
Copy link
Contributor Author

build succeeded on re-run so good to go :)

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

1 similar comment
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@curquhart
Copy link
Contributor Author

I probably won't have time to look into the merge conflict until next week. Let me know if I should just close this until then or not (donno if the new DefinitionBody.fromChainable stuff sets the sfn comment or not so need to test, but def don't have time this week.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

2 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 19, 2023
@curquhart
Copy link
Contributor Author

Just wanted to follow up on this- would appreciate if someone has time to look at it thanks :)

Copy link
Contributor

@vinayak-kukreja vinayak-kukreja left a comment

Choose a reason for hiding this comment

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

Hey, this looks great. Thank you for contributing.
I have just some NITs.

Tagging @iliapolo for a second opinion.

* Read/write. Only makes sense on the top-level graph, subgraphs
* do not support this feature.
*
* @default No comment
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Could you change this to @default - No comment.

/**
* Comment that describes this state machine
*
* @default No comment
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to earlier comment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

heh yup, np, updated :D

@mergify mergify bot dismissed vinayak-kukreja’s stale review June 27, 2023 22:52

Pull request has been modified.

@vinayak-kukreja
Copy link
Contributor

Thank you for addressing the feedback. :) LGTM, syncing with Eli to get a second opinion.

Comment on lines 41 to 42
* Read/write. Only makes sense on the top-level graph, subgraphs
* do not support this feature.
Copy link
Contributor

@iliapolo iliapolo Jun 29, 2023

Choose a reason for hiding this comment

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

I understand you followed the same pattern as the timeout property - but this behavior makes me a little uncomfortable and I think that timeout also wasn't implemented in an ideal way. Lets see if we can make it better?

See other comments.

@@ -707,6 +714,7 @@ export class ChainDefinitionBody extends DefinitionBody {
public bind(scope: Construct, sfnPrincipal: iam.IPrincipal, sfnProps: StateMachineProps): DefinitionConfig {
const graph = new StateGraph(this.chainable.startState, 'State Machine definition');
graph.timeout = sfnProps.timeout;
graph.comment = sfnProps.comment;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if instead we do:

const graphJson = Stack.of(scope).toJsonString(graph.toGraphJson());
return {
  definitionString: { Comment: sfnProps.comment, ...graphJson },
};

Basically having the state machine augment the graph with properties that are only relevant to the state machine as a whole - and not to sub-graphs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

finally updated,

    const graphJson = graph.toGraphJson();
    return {
      definitionString: Stack.of(scope).toJsonString({ ...graphJson, Comment: sfnProps.comment }),
    };

how's that? I included comment after since the graph always sets it (even if undefined) and {something: 'foo', ... {something:undefined}} will override with undefined

@vinayak-kukreja vinayak-kukreja removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 4, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 4, 2023
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

@curquhart leaving a request changes review to reflect the current state of this PR and remove the needs-review label. We'll take another look when outstanding comments are addressed!

@kaizencc kaizencc removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 13, 2023
@curquhart
Copy link
Contributor Author

@curquhart leaving a request changes review to reflect the current state of this PR and remove the needs-review label. We'll take another look when outstanding comments are addressed!

sure thing. Sorry haven't addressed yet, I'm on vaca at the moment, should address it next week.

@mergify mergify bot dismissed kaizencc’s stale review July 31, 2023 19:02

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 31, 2023
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Hi @curquhart! Thanks for sticking with this PR. One last comment about the changes to StateGraph.

@@ -113,6 +123,7 @@ export class StateGraph {
StartAt: this.startState.stateId,
States: states,
TimeoutSeconds: this.timeout && this.timeout.toSeconds(),
Comment: this.comment,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think changes to StateGraph are necessary anymore. StateGraph is exposed but not meant to be used externally. No one should be setting comment on StateGraph and internally we are not doing that anymore either. So there's no need to have this prop.

(This means that the ordering between ...graphJson and Comment: sfnProps.comment won't matter anymore, but its fine to have graphJson in front).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha... I forgot i added it to state-graph, totally makes sense to take it out - updated

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 1, 2023
@mergify mergify bot dismissed kaizencc’s stale review August 1, 2023 15:32

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 1, 2023
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks @curquhart! Looks good

@mergify
Copy link
Contributor

mergify bot commented Aug 2, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 2, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: dc348a3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 6a70b4f into aws:main Aug 2, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 2, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@curquhart curquhart deleted the sfn_add_comment branch April 17, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants