📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

适用版本: 8.8-8.9

1. 错误异常的基本描述 #

Both an endpoint suffix as well as a secondary endpoint were set 表示 Elasticsearch 在构造 Azure 客户端配置时,检测到 endpoint_suffixsecondary endpoint 同时存在,因此拒绝继续初始化。

常见现象 #

  • Azure 仓库初始化失败,日志中直接出现 SettingsException
  • 常见于多区域 Azure 存储、RA-GRS 或自定义网络环境配置切换时。
  • 可能在清理主 endpoint 冲突后,又继续暴露这个 secondary endpoint 冲突。

典型报错与异常栈 #

SettingsException: Both an endpoint suffix as well as a secondary endpoint were set

2. 为什么会发生这个错误 #

源码里先判断 endpoint_suffixendpointsecondary_endpoint 三个值是否存在。只要 endpoint_suffixsecondary_endpoint 同时非空,就抛出该异常。

其核心原因是:

  • 使用 endpoint_suffix 时,secondary endpoint 应由标准规则推导。
  • 如果又手工指定了 secondary endpoint,系统就同时拥有“自动推导”和“手工指定”两套来源。

3. 如何排查和解决这个异常和解决这个异常 #

  1. 检查 Azure client 的最终配置来源。
  2. 确认同一个 client 下是否同时存在 endpoint_suffixsecondary_endpoint
  3. 如果要使用标准 Azure endpoint 规则,删除 secondary_endpoint
  4. 如果确实需要手工指定辅助 endpoint,通常应连同 endpoint_suffix 一起移除,并明确设置主 endpoint。

排查时需要注意的问题 #

  • 如果保留 secondary endpoint,还必须确认是否也正确设置了 primary endpoint。
  • 不要只改仓库配置,client 级配置残留同样会触发此异常。

4. 如何解决这个错误 #

常用修复思路 #

  • endpoint_suffix 与显式 endpoint 配置二选一。
  • 需要手工控制主辅 endpoint 时,使用显式 endpoint + secondary_endpoint 组合。
  • 使用标准 Azure 公有云时,通常只保留 endpoint_suffix

后续注意事项与推荐建议 #

  • 为 Azure client 配置增加互斥测试。
  • 迁移云环境时,先清理旧参数,再导入新参数。

借助 INFINI 产品提升排障效率 #

  • INFINI Console 适合快速比对不同环境的 Azure client 参数。
  • INFINI Gateway 适合审计配置变更,定位 secondary endpoint 是何时被引入的。

5. 小结 #

Both an endpoint suffix as well as a secondary endpoint were set 本质上是 Azure endpoint 生成方式冲突。只要明确采用“自动推导”还是“手工指定”其中一种,问题就能消除。

相关错误 #

附:日志上下文 #

if (hasEndpointSuffix && hasEndpoint) {
throw new SettingsException("Both an endpoint suffix as well as a primary endpoint were set");
}  if (hasEndpointSuffix && hasSecondaryEndpoint) {
throw new SettingsException("Both an endpoint suffix as well as a secondary endpoint were set");
}  if (hasEndpoint == false && hasSecondaryEndpoint) {
throw new SettingsException("A primary endpoint is required when setting a secondary endpoint");
}