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

未关闭
#214 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Wompipomp 已经在做这个了。

开始于 2026年11月28日。

  • #215 来自 @Wompipomp —— 未关闭

评估

难度
4/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
go, kubernetes

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Go
星标
25
派生
35
平均合并
3 天 19 小时
30 天内合并 PR
18

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

kcp-dev/api-syncagent 的其他 Issue

查看 kcp-dev/api-syncagent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。