Skip to content

fix(dts): [173335400] pause running sync job before isolation on delete#4314

Open
Rajendraladkat1919 wants to merge 1 commit into
tencentcloudstack:masterfrom
Rajendraladkat1919:fix/dts-sync-job-delete-lifecycle
Open

fix(dts): [173335400] pause running sync job before isolation on delete#4314
Rajendraladkat1919 wants to merge 1 commit into
tencentcloudstack:masterfrom
Rajendraladkat1919:fix/dts-sync-job-delete-lifecycle

Conversation

@Rajendraladkat1919

Copy link
Copy Markdown

What
Fix tencentcloud_dts_sync_job to pause a running job before attempting isolation on delete, and return nil instead of an error when the job is not found during Read.

Why
Delete bug: The Delete function calls IsolateSyncJobs directly regardless of the job's current state. Tencent rejects isolation on a running or syncing job with:

UnsupportedOperation.UnsupportedOperationError: Current job is temporarily unable to respond to isolation events
This makes it impossible to destroy a tencentcloud_dts_sync_job resource through Terraform while the job is actively syncing — which is the normal production state. Every terraform destroy or config removal requires manual console intervention to pause the job first.

Read bug: When a job is not found, the Read function calls d.SetId("") correctly but then returns fmt.Errorf(...) instead of nil. The error overrides the state ID clear, so Terraform fails every subsequent plan with resource syncJob sync-xxx does not exist rather than automatically removing the stale entry from state. This breaks pipelines whenever a job is deleted outside Terraform.

Type of change
Bug fix
Changes
resource_tc_dts_sync_job.go — Delete:
Added a pre-isolation status check. If the job is in a running/syncing state, PauseSyncJob is called first and the function waits for Paused status before proceeding with isolation. Jobs already in NotBilledByInternational or NotBilled trade status are treated as gone and return nil immediately.

resource_tc_dts_sync_job.go — Read:
Changed return fmt.Errorf(...) to return nil after d.SetId("") so Terraform gracefully removes missing resources from state instead of erroring.

service_tencentcloud_dts.go:
Added PauseDtsSyncJobById helper following the same pattern as the existing IsolateDtsSyncJobById.

Checklist
make build succeeds locally
make fmt produces no diff
make lint passes
make check-mux passes
Acceptance tests added or updated
Changelog entry added under .changelog/.txt

Notes for reviewers
The delete sequence is now: check status → pause if running → wait for Paused → isolate → wait for Isolated/NotBilled → destroy → wait for Offlined. This mirrors the manual steps required to delete a DTS sync job via the Tencent Cloud Console and follows the same polling pattern already used elsewhere in this file.

The NotBilledByInternational early-exit path (lines 329–331 in the original) is preserved — PostPay jobs that enter this state after isolation are auto-removed by Tencent and do not need an explicit destroy call.

…tion on delete

The Delete function called IsolateSyncJobs directly on running jobs, which
Tencent rejects with UnsupportedOperation. Added a pre-isolation status check
that pauses the job first if it is still running, then proceeds with isolation.

Also fixed the Read function to return nil (not an error) when the job is not
found, allowing Terraform to remove stale state entries gracefully instead of
failing every subsequent plan.

Fixes: UnsupportedOperation.UnsupportedOperationError on destroy
Fixes: "resource syncJob sync-xxx does not exist" breaking plan after out-of-band deletion
@Rajendraladkat1919
Rajendraladkat1919 force-pushed the fix/dts-sync-job-delete-lifecycle branch from 7a6f8aa to c591e52 Compare July 16, 2026 07:02
@Rajendraladkat1919 Rajendraladkat1919 changed the title fix(dts): pause sync job before isolation to prevent UnsupportedOpera… fix(dts): pause running sync job before isolation on delete Jul 16, 2026
@Rajendraladkat1919

Copy link
Copy Markdown
Author

Im an external contributor and don't have access to an internal Tencent ticket ID required by the PR title format ([{9-digit-id}]). Could a maintainer assign one and update the title before merging?

@Rajendraladkat1919 Rajendraladkat1919 changed the title fix(dts): pause running sync job before isolation on delete fix(dts): pause running sync job before isolation on delete. Jul 16, 2026
@Rajendraladkat1919 Rajendraladkat1919 changed the title fix(dts): pause running sync job before isolation on delete. [#4315]fix(dts): pause running sync job before isolation on delete. Jul 16, 2026
@Rajendraladkat1919 Rajendraladkat1919 changed the title [#4315]fix(dts): pause running sync job before isolation on delete. fix(dts): [173335400] pause running sync job before isolation on delete Jul 16, 2026
@Rajendraladkat1919
Rajendraladkat1919 force-pushed the fix/dts-sync-job-delete-lifecycle branch from a867a6f to c591e52 Compare July 16, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant