-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
Handle transient state errors in RedshiftResumeClusterOperator
and RedshiftPauseClusterOperator
#27276
Handle transient state errors in RedshiftResumeClusterOperator
and RedshiftPauseClusterOperator
#27276
Changes from all commits
4fc7e7f
82b1d3a
c03652b
2fea0bc
630a81a
07e88b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
# under the License. | ||
from __future__ import annotations | ||
|
||
import warnings | ||
from typing import Any, Sequence | ||
|
||
from botocore.exceptions import ClientError | ||
|
@@ -157,16 +158,24 @@ def create_cluster_snapshot( | |
) | ||
return response["Snapshot"] if response["Snapshot"] else None | ||
|
||
def get_cluster_snapshot_status(self, snapshot_identifier: str, cluster_identifier: str): | ||
def get_cluster_snapshot_status(self, snapshot_identifier: str, cluster_identifier: str | None = None): | ||
""" | ||
Return Redshift cluster snapshot status. If cluster snapshot not found return ``None`` | ||
|
||
:param snapshot_identifier: A unique identifier for the snapshot that you are requesting | ||
:param cluster_identifier: The unique identifier of the cluster the snapshot was created from | ||
:param cluster_identifier: (deprecated) The unique identifier of the cluster | ||
the snapshot was created from | ||
""" | ||
if cluster_identifier: | ||
warnings.warn( | ||
"Parameter `cluster_identifier` is deprecated." | ||
"This option will be removed in a future version.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
|
||
try: | ||
response = self.get_conn().describe_cluster_snapshots( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change, I think the purpose of this hook method is to get the snapshot of a cluster WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above comment. Basically, the |
||
ClusterIdentifier=cluster_identifier, | ||
SnapshotIdentifier=snapshot_identifier, | ||
) | ||
snapshot = response.get("Snapshots")[0] | ||
|
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.
Can you please share some context?
The PR description says the motivation is issues with system tests but there should be more to it?
Why are we deprecating this parameter? If boto3 accept this as valid input why should we prevent users from using it?
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.
The change was made as a result of debugging during testing for the redshift system test. It was not originally in scope of the refactoring of the
RedshiftResumeClusterOperator
andRedshiftPauseClusterOperator
. I included it in this PR because theget_cluster_snapshot_status
function does not work as written.Boto3 does not accept both inputs at the same time. If both are provided, we get an
InvalidParameterCombination
exception.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.
In that case, maybe leave the parameter in and add a block at the beginning of the method along the lines of
The ^ is an XOR operator, which returns true if one and only one of those exists.