style95 commented on a change in pull request #2248: Make invoker be scaled-out 
via ansible. (#2247)
URL: 
https://github.com/apache/incubator-openwhisk/pull/2248#discussion_r116687196
 
 

 ##########
 File path: ansible/roles/invoker/tasks/deploy.yml
 ##########
 @@ -31,6 +31,24 @@
     linuxOptions: "-v 
/usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1"
   when: whisk_version_name != "mac"
 
+- name: get running invoker information
+  shell: >
+        curl -Gs http://{{ inventory_hostname }}:{{ docker.port 
}}/containers/json --data-urlencode 'filters={"name":[ "invoker" ]}'
+  register: results
+
+- name: register invoker infomation from curl results
+  set_fact: invokerInfo="{{results.stdout|from_json}}"
+
+- name: determine if more than one invokers are running
+  fail: msg="more than one invokers are running"
+  with_items: {invokerInfo.stdout_lines}
+  when: "{{ invokerInfo|length > 1 }}"
+
+- name: determine if index of invoker is same with index of inventory host
+  fail: msg="invoker index is invalid {{item.Names}} 
/invoker{{play_hosts.index(inventory_hostname)}}"
+  with_items: "{{ invokerInfo }}"
+  when: '"{{ item.Names[0] }}" != 
"/invoker{{play_hosts.index(inventory_hostname)}}"'
 
 Review comment:
   This is for the case that, if user add new host at the front of inventory 
file.
    
   For example, if there were two invokers running.
   
   ```
   [invokers]
   10.10.10.2  ; index 0
   10.10.10.3  ; index 1
   ```
   
   And user want to add a new invoker, but if he added it at the front of 
inventory file:
   
   ```
   [invokers]
   10.10.10.4 ; index 0
   10.10.10.2 ; index 0 -> index 1
   10.10.10.3 ; index 1 -> index 2
   ```
   
   It will run new invokers in all the hosts with new index.
   Since existing invokers will not be killed, there will be problem in service 
discovery.
   
   If we assumes user will always add a new host at the end of inventory file, 
that lines might not be required.
   
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to