Skip to content

Commit

Permalink
Mesos api server not responing to 127.0.0.1 ip
Browse files Browse the repository at this point in the history
Setting api server ip to be accessed through the node ip
Closes-Bug: #1807302

Change-Id: If68fc0fbd9813f57666e7e6730520b3018f02d2d
  • Loading branch information
aniketgawade committed Dec 18, 2018
1 parent 51c5601 commit 6978dda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def cleanup_json(data):
return data

@staticmethod
def api_req_raw(method, path, auth=None, body=None, **kwargs):
path_str = 'http://127.0.0.1:5051'
def api_req_raw(method, ip_addr, port, path, auth=None, body=None, **kwargs):
path_str = 'http://%s:%s' % (ip_addr, port)
payload = { 'type': 'GET_CONTAINERS' }
for path_elem in path:
path_str = path_str + "/" + path_elem
Expand Down Expand Up @@ -73,25 +73,27 @@ def api_req_raw(method, path, auth=None, body=None, **kwargs):
return response

@staticmethod
def get_task():
data = PodTaskMonitor.api_req_raw('POST', ['api', 'v1']).json()
def get_task(node_ip):
data = PodTaskMonitor.api_req_raw('POST', node_ip, '5051',
['api', 'v1']).json()
return PodTaskMonitor.cleanup_json(data)

@staticmethod
def get_task_pod_name_from_cid(cid):
result = PodTaskMonitor.get_task()
def get_task_pod_name_from_cid(cid, node_ip):
result = PodTaskMonitor.get_task(node_ip)
for container_info in result['get_containers']['containers']:
if container_info['container_id']['value'] == cid:
return container_info['executor_id']['value']
return None

def process_event(self, event):
event_type = event['event_type']
node_ip = event['labels']['node-ip']
found = True;
while found:
#Fix me: Get this as parameter
time.sleep(2)
result = PodTaskMonitor.get_task()
result = PodTaskMonitor.get_task(node_ip)
for container_info in result['get_containers']['containers']:
if container_info['container_id']['value'] == event_type.encode('utf-8'):
task_name = container_info['executor_id']['value']
Expand Down
7 changes: 4 additions & 3 deletions src/container/mesos-manager/mesos_manager/vnc/vnc_pod_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def _create_vmi(self, pod_task_id, vm_obj, vn_obj):
VirtualMachineInterfaceMM.locate(vmi_uuid)
return vmi_uuid

def _create_vm(self, pod_task_id):
pod_task_name = PodTaskMonitor.get_task_pod_name_from_cid(pod_task_id)
def _create_vm(self, pod_task_id, node_ip):
pod_task_name = PodTaskMonitor.get_task_pod_name_from_cid(pod_task_id,
node_ip)
if pod_task_name is None:
vm_obj = VirtualMachine(name=pod_task_id)
else:
Expand Down Expand Up @@ -177,7 +178,7 @@ def vnc_pod_task_add(self, obj_labels):
if not vn_obj:
return

vm_obj = self._create_vm(obj_labels.pod_task_uuid)
vm_obj = self._create_vm(obj_labels.pod_task_uuid, node_ip)
vmi_uuid = self._create_vmi(obj_labels.pod_task_uuid, vm_obj, vn_obj)
vmi = VirtualMachineInterfaceMM.get(vmi_uuid)

Expand Down

0 comments on commit 6978dda

Please sign in to comment.