带有两个git repos的复合配置的Spring cloud config服务器没有这样的标签错误

问题描述 投票:0回答:1

我们有一个具有这样的复合配置的Spring Cloud配置服务器:

spring:
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
        -
          type: git
          uri: "https://github.comcast.com/config-org/{application}"
          username: "mainUsername"
          password: "mainPassword"
          searchPaths: "*"
        -
          type: git
          uri: "https://github.comcast.com/config-org/shared-repo"
          username: "sharedUsername"
          password: "sharedPassword"
          searchPaths: "*"
        health:
          enabled: false

这是我们遇到的问题。假设有一个名为xsp-reference-service的存储库,则当云配置客户端向配置服务器发出请求时,该请求带有标签的标签,该标签存在于应用程序(xsp-reference-service)存储库中,但不存在于共享的[shared-repo )存储库,我们得到以下信息:

{
    "timestamp": "2019-12-04T16:18:43.886+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No such label: schrodingers_branch",
    "path": "/xsp-reference-service/dev/schrodingers_branch"
}

有没有一种方法可以让Spring Cloud Config Server不必担心共享存储库中缺少分支(正常失败)?如果没有,如果提供的标签不存在,是否可以强制云配置服务器使用默认标签(分支名称)?我什至会就可能会更好地满足我们使用情况的其他设置提出建议。欢迎任何评论。

spring git spring-cloud-config
1个回答
0
投票

我没有必要的代表发表评论,我也不知道如何告诉Spring Cloud Config Server正常失败。话虽如此,我能够找到一些信息here [1]。

上述文档中的两个要点:

  • 从环境中检索值时发生的任何类型的故障存储库会导致整个组合环境失败。
  • 使用复合环境时,所有存储库包含相同的标签。如果你有环境与前面的示例类似,您需要具有主标签但Subversion存储库的配置数据不包含一个称为master的分支,整个请求将失败。

通过共享存储库重新访问您的设计可能是您的最大利益。一种替代方法是使用Spring Vault [2]。然后(取自上述相同链接),您可以定义不同类型的存储库,而不再遇到此复合标签问题。

spring:
  profiles:
    active: git, vault
  cloud:
    config:
      server:
        git:
          uri: file:///path/to/git/repo
          order: 2
        vault:
          host: 127.0.0.1
          port: 8200
          order: 1 

1:https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#composite-environment-repositories

2:https://spring.io/projects/spring-vault

© www.soinside.com 2019 - 2024. All rights reserved.