-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Stop replication task before applying changes that require the task to be stopped. #24047
Stop replication task before applying changes that require the task to be stopped. #24047
Conversation
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.
Welcome @fermezz 👋
It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.
Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.
Thanks again, and welcome to the community! 😃
1bcbdc8
to
0cc6828
Compare
startReplicationTaskType := dms.StartReplicationTaskTypeValueStartReplication | ||
if fromStatus != replicationTaskStatusReady { | ||
startReplicationTaskType = dms.StartReplicationTaskTypeValueResumeProcessing | ||
} | ||
|
||
_, err = conn.StartReplicationTask(&dms.StartReplicationTaskInput{ | ||
ReplicationTaskArn: task.ReplicationTaskArn, | ||
StartReplicationTaskType: aws.String(dms.StartReplicationTaskTypeValueStartReplication), | ||
StartReplicationTaskType: aws.String(startReplicationTaskType), |
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.
Author's note: This change is necessary because for tasks of type full-load
and full-load-and-cdc
you can only use start-replication
when it's the first time the task is run. Afterwards, you have to use resume-processing
, otherwise it will fail.
Proof of it, is the following error while running the acceptance tests without this change:
replication_task_test.go:100: Step 4/4 error: Error running apply: exit status 1
Error: error starting DMS Replication Task (tf-acc-test-748333755630122031): InvalidParameterCombinationException: Start Type : START_REPLICATION, valid only for tasks running for the first time status code: 400, request id: af7935aa-89d8-49de-b835-8d6a87addc65
with aws_dms_replication_task.test, on terraform_plugin_test.tf line 176, in resource "aws_dms_replication_task" "test":
176: resource "aws_dms_replication_task" "test" {
--- FAIL: TestAccDMSReplicationTask_startReplicationTask (1373.44s)
This way, we only use start-replication
after the task is on status ready
, which only happens right after the task has been created.
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.
Thank you for jumping on this so quick, especially the update to fix StartReplicationTaskTypeValueStartReplication
being the only start replication task type! LGTM!
LGTM 🚀 % make testacc TESTS=TestAccReplicationTask_ PKG=dms
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/dms/... -v -count 1 -parallel 20 -run='TestAccReplicationTask_' -timeout 180m
=== RUN TestAccReplicationTask_basic
=== PAUSE TestAccReplicationTask_basic
=== RUN TestAccReplicationTask_cdcStartPosition
=== PAUSE TestAccReplicationTask_cdcStartPosition
=== RUN TestAccReplicationTask_startReplicationTask
=== PAUSE TestAccReplicationTask_startReplicationTask
=== RUN TestAccReplicationTask_disappears
=== PAUSE TestAccReplicationTask_disappears
=== CONT TestAccReplicationTask_basic
=== CONT TestAccReplicationTask_startReplicationTask
=== CONT TestAccReplicationTask_disappears
=== CONT TestAccReplicationTask_cdcStartPosition
--- PASS: TestAccReplicationTask_basic (520.30s)
--- PASS: TestAccReplicationTask_cdcStartPosition (520.82s)
--- PASS: TestAccReplicationTask_disappears (552.30s)
--- PASS: TestAccReplicationTask_startReplicationTask (1388.83s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/dms 1391.129s |
@fermezz thanks for the contribution 🎉 👏🏾 I made a few changes for more accurate status feedback and testing
|
Thank you! Good changes :) |
This functionality has been released in v4.12.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Previous attempt to fix this issue relied on a new
handle_task_lifecycle
parameter. We do not do this in this PR because that attempt was beforestart_replication_task
existed, so I think it's a good idea to manage the entire lifecycle through the one parameter.I missed the branch-prefix convention. Let me know if it's important enough and I can re-create the PR with a new branch.
Community Note
Closes #2236.
Closes #16092 (dup).
Output from acceptance testing:
Existing acceptance tests pass:
Result from adapted acceptance tests: