-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Add EC2HibernateInstanceOperator and EC2RebootInstanceOperator (#35703) #35770
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 EC2HibernateInstanceOperator and EC2RebootInstanceOperator (#35703) #35770
Conversation
cf52c49 to
f8e294e
Compare
|
|
||
| :param instance_id: id of the AWS EC2 instance | ||
| :param aws_conn_id: aws connection to use | ||
| :param region_name: (optional) aws region name associated with the client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bother marking just this one as optional but not the arg above and below? I'd either do it for all optional args or don't bother. Same for Hibernate operator below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I naively copied the EC2StartInstanceOperator setup. Switched to use the pattern established by more recent operators so there are no more optional args.
| self.log.info("Rebooting EC2 instance %s", self.instance_id) | ||
| instance = ec2_hook.get_instance(instance_id=self.instance_id) | ||
| instance.reboot() | ||
| ec2_hook.wait_for_state( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually wrap waits like this with a wait_for_completion arg for folks who prefer to just fire and forget. Do you mind adding that here? If you grep for that arg name you'll see lots of examples. Also same for the Hibernate operator below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think I was using an outdated pattern (copied the set-up of EC2StartInstanceOperator). Updated the operators to accept a wait_for_completion parameter, and to use waiters
b684a77 to
df69a5c
Compare
Adds two new operators to Amazon provider package:
EC2HibernateInstanceOperator, andEC2RebootInstanceOperatorcloses: #35703