Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为 Kuscia 增加 stop 和 uninstall 脚本 #50

Closed
Candicepan opened this issue Jul 31, 2023 · 4 comments · Fixed by #61
Closed

为 Kuscia 增加 stop 和 uninstall 脚本 #50

Candicepan opened this issue Jul 31, 2023 · 4 comments · Fixed by #61
Assignees
Labels
deploy deployment enhancement New feature or request OSCP SecretFlow Open Source Contribution Plan

Comments

@Candicepan
Copy link

此 ISSUE 为 隐语开源共建计划(SecretFlow Open Source Contribution Plan,简称 SF OSCP)第二期任务 ISSUE,欢迎社区开发者参与共建~
若有感兴趣想要认领的任务,但还未报名,辛苦先完成报名进行哈~

任务介绍

  • 任务名称:为 Kuscia 增加 stop 和 uninstall 脚本
  • 技术方向:节点部署
  • 任务难度:进阶🌟🌟

详细要求

  • 功能性:
  • 为 Kuscia 增加 stop 脚本,将已运行的 kuscia 容器停止。需要支持可以停止不同模式部署的容器,也需要支持停止所有的 kuscia 容器。
  • 为 Kuscia 增加 uninstall 脚本,将已停止的 kuscia 容器清除。需要支持可以清除不同模式部署的容器和 volume 等,也需要支持一键清除所有的 kuscia 容器、volume 和 network。
  • 正确性:
    • uninstall 脚本只能清除已停止的 kuscia 容器。如果容器没有被手动停止,需要停止清除逻辑并提示用户先停止容器。
  • 代码规范:https://github.com/uber-go/guide/blob/master/style.md
  • 提交说明:
    • 关联该 ISSUE 并先准备详细的设计方案文档,请在 ISSUE 下评论提交方案,经过确认后进行开发。
    • 功能开发完成后,关联该 ISSUE 并提交代码至 https://github.com/secretflow/kuscia

能力要求

  • 熟悉 docker
  • 熟悉 shell 语法

操作说明

@Candicepan Candicepan added OSCP SecretFlow Open Source Contribution Plan enhancement New feature or request labels Jul 31, 2023
@BeaCox
Copy link
Contributor

BeaCox commented Aug 3, 2023

BeaCox Give it to me

@BeaCox
Copy link
Contributor

BeaCox commented Aug 3, 2023

方案:

  • stop

    接受4种参数:

    • center

      停止中心化组网模式部署的容器

    • p2p

      停止点对点组网模式部署的容器

    • all

      停止所有kuscia容器

    • -h

      展示帮助信息

    其他参数将会展示帮助信息。

    具体方法:

    参考start_standalone.sh中如果已有容器则需用户确认是否重新创建容器的逻辑,可知用户的所有kuscia容器的名称都是在已知范围内的,可以通过以下方式进行筛选kuscia容器:

    • center

      docker ps --format '{{.Names}}' -f name=^${P2P_PREFIX}
    • p2p

      docker ps --format '{{.Names}}' -f name=^${CTR_PREFIX} | grep -v ^${P2P_PREFIX}
    • all

      docker ps --format '{{.Names}}' -f name=^${CTR_PREFIX}
  • uninstall

    接受4种参数:

    • center

      移除中心化组网模式部署的容器、卷和网络(如果没有 p2p 容器,包括未运行的)

    • p2p

      移除点对点组网模式部署的容器、卷和网络(如果没有 center 容器,包括未运行的)

    • all

      移除所有kuscia容器、volume、network

    • -h

      展示帮助信息

    其他参数将会展示帮助信息。

    uninstall脚本在筛选容器、volume时与stop脚本逻辑一致。

    其中网络比较特殊——两种模式共用同一个kuscia-exchange网络,那么只有在两种模式的容器都将被移除时,才应该删除这个网络。因此在删除某一模式的容器的最后一步——删除网络之前需要先检查另一种模式的容器是否存在。如果传入all,删除全部则不需要考虑此种情况,全部删除即可。

  • 正确性要求

    在函数remove_container的开头调用check_running_containers函数

    check_running_containers接受一个网络模式类型参数,查找是否有正在运行的该类容器。如果有,提示用户并退出脚本;如果没有,该函数正常返回,remove_container得以继续执行。

@santiago-wjq
Copy link
Contributor

1、如果有其他容器在使用kuscia- exchange的话,那使用docker network rm kuscia-exchange会返回报错。
2、考虑到后续如果用户要在节点上要使用其他的容器,比如要部署一个mysql,此时mysql也是要加入kuscia- exchange的,但是脚本不应该清除mysql,因此kuscia- exchange也无法清除。

基于以上两点,可以认为kuscia-exchange不删除也不是很严重的问题。我建议只要尝试删除一下,并不需要关心是否成功。


其中网络比较特殊——两种模式共用同一个kuscia-exchange网络,那么只有在两种模式的容器都将被移除时,才应该删除这个网络。因此在删除某一模式的容器的最后一步——删除网络之前需要先检查另一种模式的容器是否存在。如果传入all,删除全部则不需要考虑此种情况,全部删除即可。

@BeaCox
Copy link
Contributor

BeaCox commented Aug 4, 2023

哦哦,收到,这点确实没有考虑清楚。感谢建议

@longshan-ant longshan-ant linked a pull request Aug 15, 2023 that will close this issue
@longshan-ant longshan-ant added the deploy deployment label Aug 15, 2023
AgravicCastle pushed a commit to AgravicCastle/kuscia that referenced this issue Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy deployment enhancement New feature or request OSCP SecretFlow Open Source Contribution Plan
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants