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

Refactor Eks Create Cluster Operator code #31960

Merged

Conversation

syedahsn
Copy link
Contributor

@syedahsn syedahsn commented Jun 16, 2023

The EksCreateClusterOperator is capable of creating a Fargate Profile or Nodegroup that is associated with the newly created cluster. The code for creating the Fargate Profile and Nodegroup is the same as the code in EksCreateFargateProfileOperator and EksCreateNodegroupOperator respectively.
This PR refactors the code to reuse some of the code to decrease code duplication. This step also simplifies adding deferrable mode to these operators.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:amazon-aws AWS/Amazon - related issues labels Jun 16, 2023
@syedahsn syedahsn marked this pull request as draft June 16, 2023 12:05
@syedahsn syedahsn marked this pull request as ready for review June 16, 2023 17:38
self.eks_hook = EksHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
super().__init__(**kwargs)

def create_compute(self):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def create_compute(self):
def create_compute(self) -> None:

And now Mypy would start to prompt you adding variable definitions on the class (which is good)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change, and it ended up having a bigger impact than I anticipated. I had to add a bunch of parameters used in the 3 child classes. I think I've got everything ready. I need to do some testing with how templating works here. Right now, _BaseEksCreateOperator doesn't have any templated fields, but because the child classes allow templating for some parameters, I think I have to do the same for _BaseEksCreateOperator.

@uranusjr what do you think?

@uranusjr
Copy link
Member

Looks like there’s a coverage error. Maybe caused by the base class name change?

Add waiter params to EksCreateClusterOperator and EksCreateNodegroupOperator
Update EksCreateFargateProfileTrigger and EksDeleteFargateProfileTrigger to use more consistent waiter names
Update unit tests for triggers and operators
…is meant to be a parent class to some of the Eks operators
Minor PR comment fixes
@syedahsn syedahsn force-pushed the syedahsn/eks-cluster-operator-refactor branch from e1c2a92 to 745c57a Compare June 23, 2023 16:39
@o-nikolas o-nikolas merged commit 5c88798 into apache:main Jun 23, 2023
42 checks passed
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 27, 2023
* Refactor EksCreateClusterOperator to reuse code being used in multiple places

* Update create_compute method to pass tests
Add waiter params to EksCreateClusterOperator and EksCreateNodegroupOperator
Update EksCreateFargateProfileTrigger and EksDeleteFargateProfileTrigger to use more consistent waiter names
Update unit tests for triggers and operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants