diff --git a/src/communication.py b/src/communication.py index 4d3e9ad..e6788fc 100644 --- a/src/communication.py +++ b/src/communication.py @@ -48,7 +48,6 @@ class ClusterCommunicationModule(): token = self.node_manager.docker_client.swarm.attrs['JoinTokens']['Worker'] conn.send(f'[DOCKER_TOKEN] {token}'.encode()) print(f"Send token: {token} to the worker.") - time.sleep(3) self.worker_conns.append(conn) continue @@ -63,8 +62,12 @@ class ClusterCommunicationModule(): self.client_sock.send('[CHECK]'.encode()) # join docker swarm cluster - docker_token = self.client_sock.recv(1024).decode().split()[-1] - print("Receive Docker Swarm Join_Token=", docker_token) + token = self.client_sock.recv(1024).decode().split()[-1] + print("Receive Docker Swarm Join_Token=", token) + status = self.node_manager.docker_client.swarm.join(remote_addrs=[f'{addr[0]}:2377'], join_token=token) + + if not status: + print("Some Errors!") # remove 'add node' self.node_manager.actions = self.node_manager.actions[1:]