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

feat: bcs-common mongodb client支持配置replicaset #3632

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

yuyudeqiu
Copy link
Contributor

当前,bcs 代码层面不支持配置副本集名称。在连接副本集模式下的 MongoDB 时,若副本集名称为默认的 rs0,连接正常;但当副本集名称为其他值时,连接会出现异常,报认证失败的错误。

其他服务都依赖bcs-common下的mongodb client,需要先在client支持配置。

修改如下:

  • bcs-common/pkg/odm/drivers/mongo/mongo.go

    • Options 中增加 ReplicaSet 字段。
    • bcs-common 中的 NewDB 函数中,增加兼容性处理。当 Replicaset 字段为空字符串时,客户端在创建时不指定 replicaset,与原先未配置 replicaset 字段时的行为保持一致,这样可以确保,在最小改动各个模块代码的同时,现有配置不会受到影响。
    if opt.ReplicaSet != "" {
        mCliOpt.ReplicaSet = &opt.ReplicaSet
    }

@evanlixin evanlixin merged commit 8ecf67f into TencentBlueKing:master Dec 12, 2024
14 checks passed
@yuyudeqiu yuyudeqiu deleted the feat_common_mongo branch December 17, 2024 03:17
evanlixin added a commit that referenced this pull request Dec 18, 2024
* github-bk-bcs/master:
  feat: helm-manager支持配置mongodb副本集名称 (#3637)
  feat: cluster-resources支持配置mongodb副本集名称 (#3636)
  feat: project-manager支持配置mongodb副本集名称 (#3638)
  feat: 更新bcs-ops (#3631)
  feat: cluster-manager 支持mongodb配置replicaset (#3633)
  feat: bcs-common mongodb支持配置replicaset (#3632)
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