apolloconfig / apollo

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

apollo删除某个私有namespace之后,再创建同名的namespace会提示该名称的namespace已存在 #5076

Closed guofuzheng closed 4 months ago

guofuzheng commented 5 months ago

如标题所述,apollo删除某个私有namespace之后,再创建同名的namespace会提示该名称的namespace已存在,这个问题该怎么处理呢?

dosubot[bot] commented 5 months ago

🤖

你好,@guofuzheng!我是Dosu,一个可以帮助你解决bugs,回答问题并成为贡献者的机器人。在等待人类维护者的同时,我在这里为你提供帮助。让我们一起解决你的问题吧!

在Apollo中,如果你删除了一个私有的namespace,然后试图创建一个同名的namespace,但是系统提示该名称的namespace已经存在,这可能是因为在删除namespace时,它并没有从数据库中完全删除,而是将其标记为已删除。

你可以通过以下步骤来解决这个问题:

  1. 首先,你需要找到这个被标记为已删除的namespace。你可以在NamespaceService类中使用findOne方法来查找这个namespace。例如:
Namespace deletedNamespace = namespaceService.findOne(appId, clusterName, namespaceName);
  1. 然后,你需要将这个namespace的删除标记取消。你可以在NamespaceService类中使用update方法来更新这个namespace。例如:
deletedNamespace.setDeleted(false);
namespaceService.update(deletedNamespace);

请注意,这些代码需要在一个事务中执行,以确保数据的一致性。同时,你需要确保你有足够的权限来执行这些操作。

这个解决方案是基于我在Apollo的代码库中对删除namespace的过程的理解。在NamespaceService类的deleteNamespace方法中,它首先删除与namespace关联的所有项目,然后删除所有的提交,如果namespace不是子namespace,它会删除所有的发布,如果namespace有一个子namespace,它会删除子namespace及其发布,然后删除所有与namespace关联的发布历史,删除所有与namespace关联的实例配置,解锁namespace,将namespace标记为已删除并更新最后修改者字段,审计删除操作,保存对namespace的更改,最后,它会向Apollo发布主题发送一条消息,以便在配置服务中进行一些清理,例如更新缓存。

如果你需要更多的帮助,或者有其他的问题,欢迎随时向我提问。

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

nobodyiam commented 5 months ago

可以用管理员工具中的 删除 AppNamespace 功能

image

stale[bot] commented 4 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 4 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.