{"action":"opened","issue":{"url":"https://api.github.com/repos/appcelerator/amp/issues/314","repository_url":"https://api.github.com/repos/appcelerator/amp","labels_url":"https://api.github.com/repos/appcelerator/amp/issues/314/labels{/name}","comments_url":"https://api.github.com/repos/appcelerator/amp/issues/314/comments","events_url":"https://api.github.com/repos/appcelerator/amp/issues/314/events","html_url":"https://github.com/appcelerator/amp/issues/314","id":183029708,"number":314,"title":"Stack startup with regard to services dependencies","user":{"login":"freignat91","id":11798891,"avatar_url":"https://avatars.githubusercontent.com/u/11798891?v=3","gravatar_id":"","url":"https://api.github.com/users/freignat91","html_url":"https://github.com/freignat91","followers_url":"https://api.github.com/users/freignat91/followers","following_url":"https://api.github.com/users/freignat91/following{/other_user}","gists_url":"https://api.github.com/users/freignat91/gists{/gist_id}","starred_url":"https://api.github.com/users/freignat91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freignat91/subscriptions","organizations_url":"https://api.github.com/users/freignat91/orgs","repos_url":"https://api.github.com/users/freignat91/repos","events_url":"https://api.github.com/users/freignat91/events{/privacy}","received_events_url":"https://api.github.com/users/freignat91/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-14T11:43:48Z","updated_at":"2016-10-14T11:43:48Z","closed_at":null,"body":"I known@Tony is working on it, but i was thinking on it for a while and I just wanted to put down some thoughts:\r\n\r\nFor now stack start all services in the stack file order and we suppose that if a service starts and one of its dependency service is not there, it just crash and try to start again. This way all services actually start \"naturally\" in order after a good number of crashes.\r\n\r\nWe want to be more efficient considering we are able to know by advance which service depends on which.\r\n\r\nTo do that in addition to new 'depends-on' item in the stack file, we have to retrieve the services status to know if a given service is ready or not.\r\n\r\nA service can be started but not ready, it's typically the case for kafka, which need to create some topics to be ready to be used by other services. Be ready should be understand as 'be ready to be used by the other service it depends on\", not be ready by it-self.\r\n\r\nFor that we use HEALTHCHECK command in Dockerfile which execute a specific command inside a container on regular basis. If the command failed the container is set as unhealthy (unless it's started), if the command success the container is set to Healthy.\r\nThen, first, up to the container developer to defined the right HEALTHCHECK command for its service considering what the other service are waiting for it.\r\n\r\nNow, the status of a service is related to the status of all its containers. If one container is not ready, even if the order containers are, the service is not ready. We have no way to get the status of a container using Docker API than to connect to its local docker and inspect the container.\r\nUnfortunately, we have a task associated to each container and this tack reflect the status of the container included its health. If a task has as status \"starting\", the meaning is that the container is not healthy, it can starting itself or be started but not healthy. if the task status is \"running\" then we can be sure that the container is started and healthy.\r\n\r\nWe can get list of all the swarm tasks (related to all containers on all swam nodes) using docker api from a manager node. So we have a way using Docker api to get service status connecting only to the local docker of the manager node and then to manager service startup regarding their dependencies.\r\n\r\nStay that, for now the stack status is describe using only one parameter: its \"state\"\r\nWe should add a second parameter that docker usually use and which is very interesting: the \"desired state\" in order to know what action is currently in progress and when desired state and state and equal, when the action is done.\r\n\r\nOther topics related to service dependencies and startup. We could concidere that the amp infractructure components are a stack: the amp infracstructure stack, which could be describe as any of other amp stack with some specific constraint:\r\n- ETCD and amplifier should be started out of the stack manager considering they are used for the stack management.\r\n- Then amplifier should depends only on ETCD and try to connect/reconnect to kafka, elasticsearch, Influxdb on regular basis out of the services dependencies management describe above\r\nthen for the rest of the component we could treat the amp infrastructure as a normal stack started first.\r\nHere come another topic for later, do we need stack dependencies, meaning a stack could start only if another given stack(s) is/are already started.\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"freignat91"}}