0

在部署了一个新的马拉松应用程序组后,其层次结构如下(注意显示为 yaml 而不是 json 以提高可读性):

id: root_id
groups: 
- id: data_center_id
  groups:
  - id: category_id
    groups:
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....

我现在想在类别级别添加一个额外的子组,所以现在它看起来像这样:

id: root_id
groups: 
- id: data_center_id
  groups:
  - id: category_id
    groups:
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....
  # this is the new subgroup to add
  - id: category_id
    groups:
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....
    - id: app_or_svc_type_id
      apps
      - id: app_id
        ....
      - id: app_id
        ....
      - id: app_id
        ....

当我使用 Marathon REST API 通过 PUT 尝试此操作时,现有组被破坏并创建新的子组。也许我在这里遗漏了一些东西,但是要添加新的微服务,例如,添加到现有的应用程序组层次结构中,这个功能是至关重要的。

任何帮助表示赞赏

4

2 回答 2

1

我不太确定你到底做了什么。告诉我们您的确切 HTTP 请求可能会有所帮助。

您的问题可能是您的组和应用程序的 ID 不正确。有时,这会导致被忽略的组/应用程序显然没有任何错误:https ://github.com/mesosphere/marathon/issues/1890

以下 HTTP 请求对我有用。

使用一个子组创建初始组:

PUT /v2/groups/group HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 185
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.2

{
    "groups": [
        {
            "apps": [
                {
                    "cmd": "python -m SimpleHTTPServer $PORT",
                    "id": "/group/subgroup1/app"
                }
            ],
            "id": "/group/subgroup1"
        }
    ],
    "id": "/group"
}

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache
Server: Jetty(8.1.15.v20140411)
Transfer-Encoding: chunked
X-Marathon-Leader: http://localhost:8080

{
    "deploymentId": "6c59b425-49e2-4db8-8de0-a29020a34be7",
    "version": "2015-07-28T12:00:01.171Z"
}

使用包含附加子组的新定义更新组:

PUT /v2/groups/group HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 335
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.2

{
    "groups": [
        {
            "apps": [
                {
                    "cmd": "python -m SimpleHTTPServer $PORT",
                    "id": "/group/subgroup1/app"
                }
            ],
            "id": "/group/subgroup1"
        },
        {
            "apps": [
                {
                    "cmd": "python -m SimpleHTTPServer $PORT",
                    "id": "/group/subgroup2/app"
                }
            ],
            "id": "/group/subgroup2"
        }
    ],
    "id": "/group"
}

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache
Server: Jetty(8.1.15.v20140411)
Transfer-Encoding: chunked
X-Marathon-Leader: http://localhost:8080

{
    "deploymentId": "b72801f7-8a18-434e-bebb-81d55e698ef1",
    "version": "2015-07-28T12:03:17.109Z"
}

已经存在的应用程序/组保持不变。

或者,您也可以使用仅包含该子组定义的PUT请求。/v2/groups/group/subgroup2

于 2015-07-28T12:07:14.750 回答
0

在您的情况下,要添加一个子组,PUT或者POST是完全指定其 ID 的子组/root_id/data_center_id/category_id

于 2015-07-26T16:24:17.477 回答