Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: Updated EKS integration to use integration_pattern#177

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ca-nguyen merged 8 commits intoaws:mainfromca-nguyen:update-eks-integration
Nov 8, 2021

Conversation

@ca-nguyen
Copy link
Contributor

@ca-nguyenca-nguyen commentedNov 1, 2021
edited
Loading

Description

Update Amazon EKS service integration to useintegration_pattern input instead orwait_for_completion flag.

Fixes #(issue) -N/A

Why is the change necessary?

This change is necessary for consistency with the new service integration implementation pattern introduced incommit (Add support for Nested Step Functions) that uses theintegration_pattern arg in the step constructor to build the resource.

Support for Amazon EKS service integration was added in thiscommit, but notreleased yet.
A latercommit (Add support for Nested Step Functions) introduced a new implementation pattern using theIntegrationPattern enum as input to construct the step instead of thewait_for_completion flag. (SeePR for more detail on rationale behind the implementation).

Solution

Replace thewait_for_completion flag withintegration_pattern arg for the step construction:

TheIntegrationPattern is used to build theResource arn as follow:

IntegrationPatternResourceDoc
WaitForCompletion"arn:aws:states:::states:eks:createCluster.sync"Run A job
CallAndContinue"arn:aws:states:::states:eks:createCluster"Request Response

SeeService Integration Patterns for more details

Apply changes to the following steps:

  • EksRunJob to create a Task state that allows you to run a job on your Amazon EKS cluster
    • CallAndContinue:arn:aws:states:::eks:runJob
    • WaitForCompletion:arn:aws:states:::eks:runJob.sync
  • EksCall to create a Task state that allows you to use the Kubernetes API to read and write Kubernetes resource objects via a Kubernetes API endpoint
    • CallAndContinue:arn: arn:aws:states:::eks:call
  • EksCreateClusterStep to create a Task state that creates an Amazon EKS cluster
    • CallAndContinue: arn:aws:states:::eks:createCluster
    • WaitForCompletion:arn:aws:states:::eks:createCluster.sync
  • EksDeleteClusterStep to create a Task state that deletes an Amazon EKS cluster
    • CallAndContinue:arn:aws:states:::eks:deleteCluster
    • WaitForCompletion:arn:aws:states:::eks:deleteCluster.sync
  • EksCreateFargateProfileStep to create a Task state that creates a Fargate profile
    • CallAndContinue:arn:aws:states:::eks:createFargateProfile
    • WaitForCompletion:arn:aws:states:::eks:createFargateProfile.sync
  • EksDeleteFargateProfileStep to create a Task state that deletes a Fargate profile
    • CallAndContinue:arn:aws:states:::eks:deleteFargateProfile
    • WaitForCompletion:arn:aws:states:::eks:deleteFargateProfile.sync
  • EksCreateNodeGroupStep to create a Task state that creates a node group
    • CallAndContinue:arn:aws:states:::eks:createNodegroup
    • WaitForCompletion:arn:aws:states:::eks:createNodegroup.sync
  • EksDeleteNodeGroupStep to create a Task state that deletes a node group
    • CallAndContinue:arn:aws:states:::eks:deleteNodegroup
    • WaitForCompletion:arn:aws:states:::eks:deleteNodegroup.sync

Normally, replacing a constructor argument would be a breaking change, but since we have not released support for Amazon EKS service integration yet, it is acceptable to do so. After next release, it making such changes will be considered as not being backward compatible.

Testing

  • Updated unit tests for all resources
  • No integ tests added as external resources were required for testing
  • Manual test done for all resources

Manual tests

EKS cluster management

Created step machine to test several eks steps (based on theManage EKS cluster sample project):

create_cluster_step = EksCreateClusterStep(    "Create Eks cluster",    integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'Name': 'ExampleCluster',        'ResourcesVpcConfig': {          'SubnetIds': [            'subnet-XXXXXXXXXXXXXXXXX',            'subnet-XXXXXXXXXXXXXXXXX'          ]        },        'RoleArn': <execution_role_arn>    },    result_path="$.eks")create_node_group_step = EksCreateNodegroupStep(    "Create Node Group", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'ClusterName': 'ExampleCluster',        'NodegroupName': 'ExampleNodegroup',        'NodeRole': <node_role_arn>,        'Subnets': [            'subnet-XXXXXXXXXXXXXXXXX',            'subnet-XXXXXXXXXXXXXXXXX'        ]    },    result_path="$.nodegroup")run_job_step = EksRunJobStep("Run Job", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'ClusterName': 'ExampleCluster',        'CertificateAuthority.$': '$.eks.Cluster.CertificateAuthority.Data',        'Endpoint.$': '$.eks.Cluster.Endpoint',        'LogOptions': {            'RetrieveLogs': True        },        'Job': {            'apiVersion': 'batch/v1',            'kind': 'Job',            'metadata': {                'name': 'example-job'            },            'spec': {                'backoffLimit': 0,                'template': {                    'metadata': {                        'name': 'example-job'                    },                    'spec': {                        'containers': [                            {                                'name': 'pi-20',                                'image': 'perl',                                'command': ['perl'],                                'args': [                                    '-Mbignum=bpi',                                    '-wle',                                    'print bpi(20)'                                ]                            }                        ],                        'restartPolicy': 'Never'                    }                }            }        }    },    result_path="$.RunJobResult")call_delete_job_step = EksCallStep("Call", parameters={    'ClusterName': 'ExampleCluster',    'CertificateAuthority.$': '$.eks.Cluster.CertificateAuthority.Data',    'Endpoint.$': '$.eks.Cluster.Endpoint',    'Method': 'DELETE',    'Path': '/apis/batch/v1/namespaces/default/jobs/example-job',    })delete_node_group = EksDeleteNodegroupStep(    "Delete Node Group", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'ClusterName': 'ExampleCluster',        'NodegroupName': 'ExampleNodegroup'    })delete_cluster_step = EksDeleteClusterStep(    "Delete Eks cluster", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'Name': 'ExampleCluster'    })# Chain the stepspath=Chain([create_cluster_step, create_node_group_step, run_job_step, call_delete_job_step, delete_node_group, delete_cluster_step])# Define workflowworkflow = Workflow(    name="EKSStateMachineExample",    definition=path,    role=<workflow_execution_arn>)workflow.create()workflow.execute()
Fargate profile creation/deletion test

Using an existing cluster <cluster_name>, create Fargate profile and delete it once profile creation succeeds

create_fargate_profile_step = EksCreateFargateProfileStep(    "Create Fargate profile", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={        'ClusterName': <cluster_name>,        'FargateProfileName': 'ExampleFargateProfile',        'PodExecutionRoleArn': <pod_execution_role_arn>,        'Selectors': [{            'Namespace': 'my-namespace',            'Labels': {'my-label': 'my-value'}          }],          'Subnets': [            'subnet-XXXXXXXX'          ]    })delete_fargate_profile_step = EksDeleteFargateProfileStep(    "Delete Fargate profile", integration_pattern=IntegrationPattern.CallAndContinue, parameters={        'ClusterName': <cluster_name>,        'FargateProfileName': 'ExampleFargateProfile'    })# Chain the stepspath=Chain([create_fargate_profile_step, delete_fargate_profile_step])# Define the workflowworkflow = Workflow(    name="EKSFargateProfileExample",    definition=path,    role=<workflow_execution_role>)workflow.create()workflow.execute()

Pull Request Checklist

Please check all boxes (including N/A items)

Testing

  • Unit tests added
  • Integration test added -N/A No integ tests added since external resources required for testing
  • Manual testing - No integ tests added since external resources required for testing

Documentation

  • docs: All relevantdocs updated
  • docstrings: All public APIs documented

Title and description

  • Change type: Title is prefixed with change type: and followsconventional commits
  • References: Indicate issues fixed via:Fixes #xxx -N/A

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

@ca-nguyenca-nguyen marked this pull request as ready for reviewNovember 1, 2021 18:50
shivlaks
shivlaks previously requested changesNov 2, 2021
Copy link
Contributor

@shivlaksshivlaks left a comment

Choose a reason for hiding this comment

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

nice change! all the locations where a service integration pattern is now accepted also need a test case exercising an "unsupported" integration pattern.

ca-nguyenand others added2 commitsNovember 2, 2021 11:06
Co-authored-by: Shiv Lakshminarayan <shivlaks@amazon.com>
@ca-nguyen
Copy link
ContributorAuthor

Thanks for the review@shivlaks !

all the locations where a service integration pattern is now accepted also need a test case exercising an "unsupported" integration pattern.

Added the unite tests for unsupportedintegration_patterns in the latest commit

I also added theintegration_pattern arg in theEksCallStep constructor for consistency with the other steps (it was the only one that was missing - omitted previously since it only supports one of the integration patterns)

shivlaks reacted with hooray emoji

@ca-nguyenca-nguyen dismissedshivlaks’sstale reviewNovember 2, 2021 22:46

Comments were addressed and suggested changes were added with last commits

shivlaks
shivlaks previously approved these changesNov 2, 2021

@patch.object(boto3.session.Session,'region_name','us-east-1')
deftest_eks_create_cluster_step_creation_wait_for_task_token_raises_error():
error_message=re.escape(f"Integration Pattern ({IntegrationPattern.WaitForTaskToken.name}) is not supported for this step - "
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I was debating on adding a method in test/unit/utils to build the error message to avoid code repetition, but found that building the error message in each test improves readability. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

i like having it in the test for readability so don't have any objections to what you've gone with.

ca-nguyen reacted with thumbs up emoji
@StepFunctions-Bot
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-sEHrOdk7acJc
  • Commit ID:1677185
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered bygithub-codebuild-logs, available on theAWS Serverless Application Repository

Copy link

@evscottevscott left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

@ca-nguyenca-nguyen merged commitaafdb76 intoaws:mainNov 8, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@evscottevscottevscott approved these changes

@shivlaksshivlaksshivlaks approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ca-nguyen@StepFunctions-Bot@evscott@shivlaks

[8]ページ先頭

©2009-2025 Movatter.jp