Skip to content

openapi(dm): support task timezone - #12777

Closed
OliverS929 wants to merge 1 commit into
pingcap:masterfrom
OliverS929:dm-openapi-task-timezone-public
Closed

openapi(dm): support task timezone#12777
OliverS929 wants to merge 1 commit into
pingcap:masterfrom
OliverS929:dm-openapi-task-timezone-public

Conversation

@OliverS929

@OliverS929 OliverS929 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #12756

DM task configuration supports timezone, but this option is not available
through OpenAPI.

What is changed and how it works?

  • Add an optional timezone field to the OpenAPI task schema.
  • Validate it with DM's existing time-zone parser.
  • Preserve it when converting between OpenAPI tasks and subtask configurations.
  • Keep the existing downstream database time zone behavior when the field is
    omitted or empty.

The DST fall-back repeated-hour behavior observed during testing is an existing
DM runtime limitation, not introduced by OpenAPI. This PR only aligns the
OpenAPI capability, and changing the runtime behavior is out of scope.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Manual testing with DM, MySQL 8.4, and TiDB covered valid, invalid, and omitted
time zones, create and readback, update rejection, downstream-default behavior,
and full and incremental replication.

Questions

Will it cause performance regression or break compatibility?

No. The field is optional, and omitted or empty values preserve the existing
behavior.

Do you need to update user documentation, design documentation or monitoring documentation?

No additional documentation update is needed.

Release note

Support configuring the DM task time zone through OpenAPI.

Summary by CodeRabbit

  • New Features

    • Tasks now support an optional timezone setting through the API.
    • Configured timezones are preserved when creating, listing, retrieving, and converting tasks and subtasks.
    • When no timezone is provided, the downstream database timezone is used by default.
  • Bug Fixes

    • Invalid timezone values are rejected with a clear configuration error.
    • Attempts to change a task or syncer timezone after creation are rejected, preserving the existing configuration.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 31, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joechenrh for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added area/dm Issues or PRs related to DM. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 083d5624-dfae-4023-8d85-484465202ca6

📥 Commits

Reviewing files that changed from the base of the PR and between 4880637 and 67c0347.

📒 Files selected for processing (11)
  • dm/config/task_converters.go
  • dm/config/task_converters_test.go
  • dm/master/openapi_controller_test.go
  • dm/master/openapi_view_test.go
  • dm/openapi/fixtures/task.go
  • dm/openapi/gen.server.go
  • dm/openapi/gen.types.go
  • dm/openapi/spec/dm.yaml
  • dm/openapi/task.go
  • dm/openapi/task_test.go
  • dm/syncer/syncer_test.go

📝 Walkthrough

Walkthrough

Changes

Task timezone support

Layer / File(s) Summary
Timezone contract and validation
dm/openapi/spec/dm.yaml, dm/openapi/gen.types.go, dm/openapi/gen.server.go, dm/openapi/task.go, dm/openapi/task_test.go, dm/openapi/fixtures/task.go, dm/master/openapi_controller_test.go
The OpenAPI task contract and generated type add an optional timezone. Task.Adjust validates non-empty values. Tests cover valid, empty, and invalid values.
Timezone conversion and fallback
dm/config/task_converters.go, dm/config/task_converters_test.go
Task conversion copies timezones to subtask configurations and returns non-empty subtask timezones. Omitted and empty values use downstream defaults.
API propagation and immutable updates
dm/master/openapi_controller_test.go, dm/master/openapi_view_test.go, dm/syncer/syncer_test.go
API tests verify timezone preservation across task and template operations. Timezone changes during updates are rejected, and the stored timezone remains unchanged.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant TaskAPI
  participant TaskAdjust
  participant TaskConverter
  participant Syncer
  Client->>TaskAPI: create task with timezone
  TaskAPI->>TaskAdjust: validate task timezone
  TaskAdjust-->>TaskAPI: adjusted task
  TaskAPI->>TaskConverter: convert task to subtask configuration
  TaskConverter->>Syncer: create subtask with timezone
  Syncer-->>TaskAPI: subtask configuration
  TaskAPI-->>Client: task and timezone response
Loading

Poem

I’m a rabbit with a timezone to spare,
Asia/Shanghai hops through the air.
Empty fields follow downstream time,
Bad zones stop before they climb.
Updates stay still, as rules decree.
Hop, hop, tested carefully!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding task timezone support to the DM OpenAPI.
Description check ✅ Passed The description covers the issue, implementation, tests, compatibility, documentation, and release note requirements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OliverS929 OliverS929 closed this Jul 31, 2026
@OliverS929
OliverS929 deleted the dm-openapi-task-timezone-public branch July 31, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dm Issues or PRs related to DM. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant