# API inconsistent with UI?

**URL:** <https://forums.suse.com/t/api-inconsistent-with-ui/2154>\
**Category:** Rancher 1.x\
**Created:** [March 24, 2016, 6:20pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154 "2016-03-24T18:20:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![feniix](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/feniix/32/1008_2.png) [@feniix](https://forums.suse.com/u/feniix)\
**Post date:** [March 24, 2016, 6:20pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/1 "2016-03-24T18:20:48Z")

</div>

Hello people,

I am playing a bit with the rancher api to do continuous deployment and I got to the point where I can deploy an app but it looks like the api is not working as documented in [http://docs.rancher.com/rancher/api/api-resources/environment/](http://docs.rancher.com/rancher/api/api-resources/environment/) for the upgrade action, more clearly in the Output part it says: An updated copy of the environment resource

I have created this small example:

```auto
{
    "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: busybox\r\n stdin_open: true\r\n",
    "name": "myapp",
    "rancherCompose": "busybox:\r\n scale: 1\r\n",
    "startOnCreate": true,
    "type": "environment"
}

```

If I am understanding the documentation well, the output of a POST to `/environments/<id>?action=upgrade` with the following body

```auto
{
    "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: nginx:1.7.7\r\n stdin_open: true\r\n",
    "rancherCompose": "busybox:\r\n scale: 1\r\n"
}

```

Should return

```auto
{
  "id": "1e5",
( snip )
  "name": "myapp",
  "state": "upgrading",
  "accountId": "1a5",
  "created": "2016-03-24T17:55:27Z",
  "createdTS": 1458842127000,
  "description": null,
  "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: nginx:1.7.7\r\n stdin_open: true\r\n",
( snip )
  "transitioningMessage": "In Progress",
  "transitioningProgress": null,
  "uuid": "321f460e-de6f-4645-9190-33fe8fe300dd"
}

```

But it is returning:

```auto
{
  "id": "1e5",
( snip )
  "name": "myapp",
  "state": "upgrading",
  "accountId": "1a5",
  "created": "2016-03-24T17:55:27Z",
  "createdTS": 1458842127000,
  "description": null,
  "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: busybox\r\n stdin_open: true\r\n",
( snip )
  "transitioningMessage": "In Progress",
  "transitioningProgress": null,
  "uuid": "321f460e-de6f-4645-9190-33fe8fe300dd"
}

```

Even after doing the `action=finishupgrade` and then doing GET `/v1/environments?name=myapp` it shows the docker-compose field not updated with the new payload.

```auto
{
  "type": "collection",
  "resourceType": "environment",
  "links": {
    "self": "http://172.19.8.20:8081/v1/environments"
  },
  "createTypes": {},
  "actions": {},
  "data": [
    {
      "id": "1e5",
      "type": "environment",
      "links": {
        "self": "http://172.19.8.20:8081/v1/environments/1e5",
        "account": "http://172.19.8.20:8081/v1/environments/1e5/account",
        "services": "http://172.19.8.20:8081/v1/environments/1e5/services",
        "composeConfig": "http://172.19.8.20:8081/v1/environments/1e5/composeconfig"
      },
      "actions": {
        "upgrade": "http://172.19.8.20:8081/v1/environments/1e5/?action=upgrade",
        "update": "http://172.19.8.20:8081/v1/environments/1e5/?action=update",
        "remove": "http://172.19.8.20:8081/v1/environments/1e5/?action=remove",
        "addoutputs": "http://172.19.8.20:8081/v1/environments/1e5/?action=addoutputs",
        "activateservices": "http://172.19.8.20:8081/v1/environments/1e5/?action=activateservices",
        "deactivateservices": "http://172.19.8.20:8081/v1/environments/1e5/?action=deactivateservices",
        "exportconfig": "http://172.19.8.20:8081/v1/environments/1e5/?action=exportconfig"
      },
      "name": "myapp",
      "state": "active",
      "accountId": "1a5",
      "created": "2016-03-24T17:55:27Z",
      "createdTS": 1458842127000,
      "description": null,
      "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: busybox\r\n stdin_open: true\r\n",
      "environment": null,
      "externalId": "",
      "healthState": "healthy",
      "kind": "environment",
      "outputs": null,
      "previousExternalId": null,
      "rancherCompose": "busybox:\r\n scale: 1\r\n",
      "removed": null,
      "startOnCreate": true,
      "transitioning": "no",
      "transitioningMessage": null,
      "transitioningProgress": null,
      "uuid": "321f460e-de6f-4645-9190-33fe8fe300dd"
    }
  ],
  "sortLinks": {
    "accountId": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=accountId",
    "created": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=created",
    "description": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=description",
    "externalId": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=externalId",
    "healthState": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=healthState",
    "id": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=id",
    "kind": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=kind",
    "name": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=name",
    "removeTime": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=removeTime",
    "removed": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=removed",
    "state": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=state",
    "uuid": "http://172.19.8.20:8081/v1/environments?name=myapp&sort=uuid"
  },
  "pagination": {
    "first": null,
    "previous": null,
    "next": null,
    "limit": 100,
    "total": null,
    "partial": false
  },
  "sort": null,
  "filters": {
    "accountId": null,
    "created": null,
    "description": null,
    "externalId": null,
    "healthState": null,
    "id": null,
    "kind": null,
    "name": [
      {
        "modifier": "eq",
        "value": "myapp"
      }
    ],
    "removeTime": null,
    "removed": null,
    "state": null,
    "uuid": null
  },
  "createDefaults": {}
}

```

But here is the oddest part, the UI shows it updated:

 ![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/b/b4c5c23d474b6a4f1fb45651b9c1ac900779e8ce.png)

Any idea of what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [March 24, 2016, 6:51pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/2 "2016-03-24T18:51:35Z")

</div>

You’re not doing anything wrong, this is just a bug that the `{docker,rancher}Compose` fields aren’t updated on upgrade. The UI is looking at the actual services resources which are created as a result of the upgrade, it doesn’t parse and interpret YAML. Or that they exist t all… I don’t think anything we do actually reads those fields after the stack (`environment`) is created. The live config is in the `environment.links.composeConfig`

---

<div class="post-metadata">

**Author:** ![feniix](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/feniix/32/1008_2.png) [@feniix](https://forums.suse.com/u/feniix)\
**Post date:** [March 24, 2016, 7:03pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/3 "2016-03-24T19:03:59Z")

</div>

Is there a github tracking this bug that you can link me to? should I open one?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [March 24, 2016, 7:08pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/4 "2016-03-24T19:08:47Z")

</div>

Please [& thanks] open an issue.

I’m guessing we’ll probably just hide those fields. It’s already available in the `composeConfig` link (as a ZIP) or in the result of the `exportconfig` action (`POST ${environment.links.exportconfig}`) so you can use either one of those if you need the current YAML for a stack/environment.

---

<div class="post-metadata">

**Author:** ![feniix](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/feniix/32/1008_2.png) [@feniix](https://forums.suse.com/u/feniix)\
**Post date:** [March 24, 2016, 7:17pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/5 "2016-03-24T19:17:01Z")

</div>

I think (from my tests) both composeConfig and `POST ${environment.links.exportconfig}` return a zip file, it would be very helpful if one of those returned a string with the docker-compose yaml because otherwise if I want to use those two programatically I would have to use a zip library to store the zip in memory, unzip it, probably keep a temporary file on disk and so on and so forth.

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [March 24, 2016, 7:19pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/6 "2016-03-24T19:19:34Z")

</div>

The `exportconfig` action returns a JSON object with the 2 strings in it. It’s used for the YAML display in the UI.

---

<div class="post-metadata">

**Author:** ![feniix](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/feniix/32/1008_2.png) [@feniix](https://forums.suse.com/u/feniix)\
**Post date:** [March 24, 2016, 7:22pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/7 "2016-03-24T19:22:05Z")

</div>

Awesome, that will do \< strike that

 ![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/5/523f04eb5a778095075a400c15d3f0afeac4f9eb.png)

versus

```auto
http GET http://172.19.8.20:8081/v1/environments/1e5/?action=exportconfig
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 602
Content-Type: application/json; charset=utf-8
Date: Thu, 24 Mar 2016 19:22:56 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(9.2.11.v20150529)
Set-Cookie: PL=rancher;Path=/
Vary: Accept-Encoding, User-Agent
X-Api-Account-Id: 1a1
X-Api-Client-Ip: 172.19.8.1
X-Api-Schemas: http://172.19.8.20:8081/v1/schemas

{
    "accountId": "1a5",
    "actions": {
        "activateservices": "http://172.19.8.20:8081/v1/environments/1e5/?action=activateservices",
        "addoutputs": "http://172.19.8.20:8081/v1/environments/1e5/?action=addoutputs",
        "deactivateservices": "http://172.19.8.20:8081/v1/environments/1e5/?action=deactivateservices",
        "exportconfig": "http://172.19.8.20:8081/v1/environments/1e5/?action=exportconfig",
        "remove": "http://172.19.8.20:8081/v1/environments/1e5/?action=remove",
        "update": "http://172.19.8.20:8081/v1/environments/1e5/?action=update",
        "upgrade": "http://172.19.8.20:8081/v1/environments/1e5/?action=upgrade"
    },
    "created": "2016-03-24T17:55:27Z",
    "createdTS": 1458842127000,
    "data": {
        "fields": {
            "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: busybox\r\n stdin_open: true\r\n",
            "previousExternalId": null,
            "rancherCompose": "busybox:\r\n scale: 1\r\n",
            "startOnCreate": true
        }
    },
    "description": null,
    "dockerCompose": "busybox:\r\n labels:\r\n io.rancher.container.pull_image: always\r\n tty: true\r\n command:\r\n - sh\r\n - -c\r\n - while true; do echo bla; sleep 1; done\r\n image: busybox\r\n stdin_open: true\r\n",
    "environment": null,
    "externalId": "",
    "healthState": "healthy",
    "id": "1e5",
    "kind": "environment",
    "links": {
        "account": "http://172.19.8.20:8081/v1/environments/1e5/account",
        "composeConfig": "http://172.19.8.20:8081/v1/environments/1e5/composeconfig",
        "self": "http://172.19.8.20:8081/v1/environments/1e5",
        "services": "http://172.19.8.20:8081/v1/environments/1e5/services"
    },
    "name": "myapp",
    "outputs": null,
    "previousExternalId": null,
    "rancherCompose": "busybox:\r\n scale: 1\r\n",
    "removeTime": null,
    "removed": null,
    "startOnCreate": true,
    "state": "active",
    "transitioning": "no",
    "transitioningMessage": null,
    "transitioningProgress": null,
    "type": "environment",
    "uuid": "321f460e-de6f-4645-9190-33fe8fe300dd"
}

```

---

<div class="post-metadata">

**Author:** ![feniix](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/feniix/32/1008_2.png) [@feniix](https://forums.suse.com/u/feniix)\
**Post date:** [March 24, 2016, 7:31pm UTC](https://forums.suse.com/t/api-inconsistent-with-ui/2154/8 "2016-03-24T19:31:14Z")

</div>

> [@vincent](#):
>
> POST ${environment.links.exportconfig}

I have created this github issue [The rancher API does not keep an updated version of the docker-compose (and probably the rancher-compose) after an upgrade · Issue #4113 · rancher/rancher · GitHub](https://github.com/rancher/rancher/issues/4113)
