apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
29.08k stars 10.2k forks source link

在配置了多个集群的情况下,某个namespace初次发布后,想取消发布,想让程序读取配置走default集群的namespace,这种目前貌似没有取消发布的操作? #5025

Closed hezhaoye closed 8 months ago

hezhaoye commented 10 months ago

在配置了多个集群的情况下,某个namespace初次发布后,想取消发布,想让程序读取配置走default集群的namespace,这种目前貌似没有取消发布的操作?

dosubot[bot] commented 10 months ago

🤖

Hello @hezhaoye,

Nice to meet you! I'm Dosu, a bot here to help you with any bugs, questions, or contributions you have related to the Apollo repository while we wait for a human maintainer to help. Don't hesitate to ask if you need anything!

对于您的问题,Apollo并不直接支持取消发布的操作。一旦配置被发布,它就会被应用实际使用。如果你想让程序读取配置走default集群的namespace,你需要手动回滚到default集群的namespace的配置版本。

根据Apollo的文档,如果发现已发布的配置有问题,可以通过点击『回滚』按钮来将客户端读取到的配置回滚到上一个发布版本。这里的回滚机制类似于发布系统,发布系统中的回滚操作是将部署到机器上的安装包回滚到上一个部署的版本,但代码仓库中的代码是不会回滚的,从而开发可以在修复代码后重新发布。Apollo中的回滚也是类似的机制,点击回滚后是将发布到客户端的配置回滚到上一个已发布版本,也就是说客户端读取到的配置会恢复到上一个版本,但页面上编辑状态的配置是不会回滚的,从而开发可以在修复配置后重新发布。

所以,如果你想在某个namespace初次发布后取消发布,并让程序读取配置走default集群的namespace,你需要在default集群的namespace中设置你想要的配置,然后在你的程序中指定使用default集群的namespace。

这些信息可以在Apollo的用户指南中找到。

另外,Apollo确实提供了在集群内切换不同namespace的功能。例如,findNamespaceBOs方法可以检索特定集群内的所有namespace信息。findNamespaces方法也可以检索特定集群内的所有namespace。此外,loadNamespaceBO方法可以加载集群内的特定namespace。这些方法都表明Apollo允许在集群内管理和切换不同的namespace。

这些方法的签名如下:

public List<NamespaceBO> findNamespaceBOs(String appId, Env env, String clusterName, boolean includeDeletedItems)
public List<NamespaceDTO> findNamespaces(String appId, Env env, String clusterName)
public NamespaceBO loadNamespaceBO(String appId, Env env, String clusterName, String namespaceName, boolean includeDeletedItems)

这些方法的源代码可以在Apollo的源代码中找到。

希望这些信息对您有所帮助。如果您有其他问题,欢迎继续提问。

Sources

nobodyiam commented 10 months ago

如果确信这个集群的 namespace 是误发布,可以删除该 namespace

hezhaoye commented 10 months ago

如果确信这个集群的 namespace 是误发布,可以删除该 namespace

嗯,删除是可以,不过如果后续再想使用这个namespace就没有恢复此namespace的功能了,也是比较麻烦的。可能做一个单独的功能来撤销首次发布的会更好点?

nobodyiam commented 10 months ago

如果后续再想使用这个namespace就没有恢复此namespace的功能了

可以再次创建

可能做一个单独的功能来撤销首次发布的会更好点?

目前 apollo 的回滚功能只支持回滚到一个已发布的版本,这个 case 的诉求本质是把已发布的版本都删除掉,差异较大,考虑到这个 case 的场景比较少,可以先用删除 namespace 的方式来满足

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

stale[bot] commented 8 months ago

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.