Skip to content

feat(mongodb): adapt shard lifecycle to syncer APIs - #3282

Draft
gnolong wants to merge 1 commit into
release-1.1from
feature/mongodb-shard-operations-addon
Draft

feat(mongodb): adapt shard lifecycle to syncer APIs#3282
gnolong wants to merge 1 commit into
release-1.1from
feature/mongodb-shard-operations-addon

Conversation

@gnolong

@gnolong gnolong commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • invoke Syncer's asynchronous add-shard API from the MongoDB shard postProvision lifecycle
  • invoke Syncer's asynchronous remove-shard API from the sharding shardRemove lifecycle
  • replace credential-bearing mongosh orchestration with a thin script that only polls syncerctl
  • use explicit 10-minute add / 1-hour remove bounds and fail fast for permanent conditions such as jumbo chunks
  • set lifecycle timeoutSeconds: -1 because draining can exceed KubeBlocks' default action timeout

KubeBlocks 1.1.0-beta.8 action retries use coarse/exponential backoff and terminated a real remove operation before Syncer reached Succeeded; keeping the bounded polling loop inside the lifecycle action avoids that mismatch while preserving Syncer as the sole shard-operation owner.

Dependency

Requires the Syncer shard operation implementation from apecloud/syncer branch feature/mongodb-shard-operations (commit 0d4de47 or a descendant) in the configured Syncer image.

Validation

  • shellspec ... shard_manage_spec.sh: 3 examples, 0 failures
  • helm lint addons/mongodb
  • helm template mongodb addons/mongodb --namespace kb-system
  • bash -n addons/mongodb/scripts/mongodb-shard-manage.sh
  • git diff --check
  • live MongoDB 8.0.17 E2E: PASS in 466.37s with KubeBlocks/DataProtection 1.1.0-beta.8
    • sharding scale 1 -> 2 -> 1
    • database primary and records placed on the actual scale-in victim
    • victim Component and Pod deleted; one shard Component remained
    • data and database primary migrated to the survivor
    • balancer disabled before removal and verified disabled afterward
    • Syncer 0d4de47, companion Syncer-test 8f1a3e7

Companion test: https://github.com/apecloud/syncer-test/pull/3

@gnolong
gnolong requested review from a team, leon-ape and xuriwuyun as code owners July 29, 2026 10:07
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (cd5c4ee) to head (fe994e3).

Files with missing lines Patch % Lines
...ddons/mongodb/scripts-ut-spec/shard_manage_spec.sh 0.00% 38 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           release-1.1   #3282   +/-   ##
===========================================
  Coverage         0.00%   0.00%           
===========================================
  Files               76      77    +1     
  Lines             9886    9924   +38     
===========================================
- Misses            9886    9924   +38     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@weicao weicao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found four release-blocking issues:

  • Default Syncer image lacks the invoked shard commands. The chart still renders apecloud/syncer:0.7.7, whose syncerctl exposes neither add-shard nor remove-shard, while this change invokes both. Default shard post-provision and shard removal therefore fail before the new lifecycle behavior can run, leaving creation and scale workflows stuck.

  • Released KubeBlocks does not enforce the declared polling budgets. The new flow relies on maxRetries and retryInterval, but the supported released Core baselines serialize and ignore ActionRequest.RetryPolicy. A Running or persistently failing Syncer operation is governed by controller reconciliation rather than these bounds and can churn or block creation and scale workflows indefinitely.

  • Shard removal no longer restores an initially disabled balancer. The declared Syncer implementation unconditionally runs balancerStart and never restores the prior state, whereas the deleted script did. Automatic migrations and MongoDB 7+ AutoMerger can remain enabled after removal and interfere with administrator-selected maintenance or manual-backup windows.

  • The destructive cross-repository workflow lacks exact-head runtime evidence. The available checks do not demonstrate a live 1→2→1 shard cycle with data movement, database-primary movement, primary changes, Syncer restart/resume, or the materially different supported MongoDB versions. Scale-in can therefore merge without evidence that it preserves data and resumes safely on the real runtime path.

@gnolong
gnolong force-pushed the feature/mongodb-shard-operations-addon branch from 53e6726 to fe994e3 Compare July 29, 2026 10:39
@gnolong
gnolong marked this pull request as draft July 29, 2026 10:40
@gnolong gnolong added the nopick Not auto cherry-pick when PR merged label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nopick Not auto cherry-pick when PR merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants