bug: engaging a workspace can fail while a sync controller is stopping, and the workspace is dropped for all controllers

Đang mở
#214 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Wompipomp đang làm issue này rồi.

Từ ngày 28/11/2026.

  • #215 của @Wompipomp — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go, kubernetes

Hướng nghiên cứu

Start with the DynamicMultiClusterManager and clusterTracker.Engage() code paths that forward engagements to sync controllers, and check how a controller is removed while its Start() has not yet returned. The test TestEngageWhileControllerIsStopping, described in the issue, is the reproduction to run; a fix is done when it passes and an engagement during controller shutdown no longer fails for healthy controllers.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

When a sync controller is stopped, its context is cancelled, but it stays registered in the
DynamicMultiClusterManager until its Start() has returned (for example while a worker finishes
its current reconcile). If a workspace is engaged during that window, clusterTracker.Engage()
forwards the engagement to the stopping controller as well. Its per-cluster watch cannot sync with
the cancelled context, so Engage() can fail with

failed to watch for cluster "<workspace>": context canceled

clusterTracker.Engage() returns that error to multicluster-runtime, which removes the cluster
again (clusters.Clusters.Add calls Remove when Engage fails). The workspace is then not
served by any sync controller, including the healthy ones, until the next APIBinding event for that
workspace makes the provider engage it again, or the agent restarts.

On current main this is latent, since running sync controllers are not stopped deliberately. The
fix for #182 (#211) stops the running controller on every PublishedResource update, which makes
this reachable.

Steps To Reproduce
  1. Run the agent with a PublishedResource whose sync controller takes a moment to finish a
    reconcile.
  2. Stop that sync controller (e.g. delete or update the PublishedResource with #211 applied)
    and, while it is shutting down, bind the APIExport in a new workspace.
  3. The engagement of the new workspace fails with the error above (timing-dependent, not on every
    attempt) and objects in it are not synced, also not for other PublishedResources.

The unit test in the PR (TestEngageWhileControllerIsStopping) reproduces this without a cluster:
it keeps a stopped controller inside a reconcile and engages a new cluster in the meantime. It
fails without the fix with the error above; adapted to main's types it fails there in the same
way.

Expected Behaviour

A controller that is shutting down does not affect the engagement of a workspace for the other
controllers.

Additional Context

No response

Ngôn ngữ chính
Go
Star
25
Fork
35
Merge trung bình
3 ngày 19 giờ
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kcp-dev/api-syncagent

Tất cả issue của kcp-dev/api-syncagent

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.