Skip to content

feat(vm): migrate legacy containers for service-only Go updates - #605

Merged
dofastted merged 5 commits into
mainfrom
fix/remote-services-migration-pr
Oct 19, 2026
Merged

dofastted merged 5 commits into
mainfrom
fix/remote-services-migration-pr

Conversation

@dofastted

@dofastted dofastted commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

变更

  • 将旧集群 slot / egress 容器迁移到持久化 /opt/kin-live Go 二进制挂载;保留停止的 *-legacy-* 容器用于回滚,不重建 VM、不触碰 VM 凭证。
  • 一键升级刷新 Go 服务;旧二进制 inode 或遗留 PID 占用端口时,等待旧 egress 退出并对失败升级明确报错。
  • 提供 scripts/migrate-legacy-cluster-slots.mjs 手动入口,支持传 VM ID 定向操作;修复远端服务刷新传递 binary digest 的运行时错误。

验证

  • npm run build:worker、npm run build:egress:通过(仅本地构建产物,未提交)。
  • 定向迁移/egress/fleet/升级脚本测试:52/52 通过。
  • 全量 npm run test:unit 首轮:仅 2 个 OAuth 文件因隔离工作树缺少本地专有 kin-oauth-auth 而失败;显式设置 KIN_OAUTH_AUTH_BIN=/mnt/x/vm2api/bin/kin-oauth-auth 重跑该 2 文件:16 通过、6 按设计跳过。
  • Biome 仅格式化本次相关文件;shell/Node 语法及 git diff --check 通过。

未部署到 HostDzire 或远端 VM;容器迁移会改变容器 ID,请先按节点/VM 定向验证再全量滚动。


Note

High Risk
Changes cluster container identity and SOCKS egress process management during upgrades; mis-rollout could leave slots on old binaries or briefly disrupt proxy traffic despite rollback containers.

Overview
Adds a one-time migration for cluster slots that still bind Go binaries under /usr/local/bin instead of the persistent slot-bin → /opt/kin-live mount. On telemetry/service refresh, legacy slot and *-egress containers are stopped, renamed to *-legacy-<timestamp> (kept stopped for rollback), and recreated with the same image, network IP, and settings—without rebuilding VMs or touching credentials/vms/.

kin-egress lifecycle is tightened so upgrades cannot silently succeed while an old helper still holds ports: processes running a deleted binary are no longer reused, orphan/stale PIDs are discovered and stopped before spawn, and listen readiness can require the new process to own the socket.

Operator entry points: scripts/migrate-legacy-cluster-slots.mjs (scoped VM IDs + concurrency), TELEMETRY docs, and stricter install.sh / panel-upgrade.sh behavior around fleet-services.mjs (install fails if refresh cannot run; panel upgrade tolerates missing helper on older images). Remote refresh now passes binary digest through migration into egress reconciliation.

Reviewed by Cursor Bugbot for commit 080ddf8. Configure here.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 080ddf8. Configure here.

},
},
}
}

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.

Legacy slot keeps network IP

High Severity

Replacement slot bodies pin the old IPv4Address and Aliases while the renamed *-legacy-* container stays on the same user-defined network. Docker still holds that endpoint until the backup is disconnected or removed, so create fails with address or alias already in use and the one-time slot migration cannot finish.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 080ddf8. Configure here.


export function needsLegacyServiceMigration(info, { sourceDir = '' } = {}) {
return !!info && !hasBindDestination(info, LIVE_BIN, sourceDir)
}

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.

KVM slots migrate on Go update

High Severity

needsLegacyServiceMigration only looks for /opt/kin-live. KVM guests already bind slot-bin at /opt/kin-guest/opt/kin-live, so every telemetry or Go-only fleet update treats them as legacy, stops the runner, and recreates the VM container. That bounces the kernel instead of restarting only Go services.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 080ddf8. Configure here.

'Tmpfs',
'VolumesFrom',
'CgroupnsMode',
])

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.

Migration drops capability settings

Medium Severity

The copied HostConfig allowlist omits CapDrop and CapAdd. Recreated slots therefore lose CapDrop: ['ALL'], and KVM runners lose CapAdd for /dev/kvm. Migrated docker guests regain default capabilities such as NET_RAW; KVM guests can fail hardware acceleration.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 080ddf8. Configure here.

cursor Bot pushed a commit that referenced this pull request Oct 19, 2026
Include capability fields in MIGRATION_HOST_CONFIG_KEYS so recreated
egress containers keep the same hardening when canReuse skips rebuild.
Document #605 in CHANGELOG.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
@cursor
cursor Bot force-pushed the fix/remote-services-migration-pr branch from 080ddf8 to f68a465 Compare October 19, 2026 12:14
cursor Bot pushed a commit that referenced this pull request Oct 19, 2026
Include capability fields in MIGRATION_HOST_CONFIG_KEYS so recreated
egress containers keep the same hardening when canReuse skips rebuild.
Document #605 in CHANGELOG.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
@cursor
cursor Bot force-pushed the fix/remote-services-migration-pr branch from 92fdd14 to 5532d33 Compare October 19, 2026 14:18
dofastted and others added 5 commits October 19, 2026 14:36
Co-authored-by: ted <kuhlmangarry24@gmail.com>
Include capability fields in MIGRATION_HOST_CONFIG_KEYS so recreated
egress containers keep the same hardening when canReuse skips rebuild.
Document #605 in CHANGELOG.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
…gration

Disconnect renamed legacy containers from user-defined networks before
recreating with the same static address. Treat /opt/kin-guest/opt/kin-live
as an already-migrated service mount.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
Co-authored-by: ted <kuhlmangarry24@gmail.com>
@cursor
cursor Bot force-pushed the fix/remote-services-migration-pr branch 2 times, most recently from 5ed423e to 2002263 Compare October 19, 2026 14:42
@dofastted
dofastted merged commit beb8027 into main Oct 19, 2026
7 checks passed
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.

2 participants