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/ 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:
{
"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
{
"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
{
"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:
{
"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.
{
"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:
Any idea of what am I doing wrong?