Skip to content

Commit

Permalink
fixed multiple workers due to faulty update
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Aug 6, 2024
1 parent 2bfe50b commit fc45d8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ def prepare_configurations(self):
configuration["subnet"]]
configuration["sshUser"] = self.ssh_user # is used in ansibleConfigurator

def upload_data(self, private_key):
def upload_data(self, private_key, clean_playbook=False):
"""
Configures ansible and then uploads the modified files and all necessary data to the master
@return:
"""
self.log.debug("Uploading ansible Data")
self.log.debug("Running upload_data")
if not os.path.isfile(a_rp.HOSTS_FILE):
with open(a_rp.HOSTS_FILE, 'a', encoding='utf-8') as hosts_file:
hosts_file.write("# placeholder file for worker DNS entries (see 003-dns)")
Expand All @@ -360,6 +360,13 @@ def upload_data(self, private_key):
self.log.debug(f"Starting playbook with {ansible_start}.")
commands = [ssh_handler.get_ac_command(self.providers, AC_NAME.format(
cluster_id=self.cluster_id))] + ssh_handler.ANSIBLE_START
if clean_playbook:
self.log.info("Cleaning Playbook")
ssh_data = {"floating_ip": self.master_ip, "private_key": private_key, "username": self.ssh_user,
"commands": [("rm -rf ~/playbook/*", "Remove Playbook")], "filepaths": [],
"gateway": self.configurations[0].get("gateway", {}), "timeout": self.ssh_timeout}
ssh_handler.execute_ssh(ssh_data=ssh_data, log=self.log)
self.log.info("Uploading Data")
ssh_data = {"floating_ip": self.master_ip, "private_key": private_key, "username": self.ssh_user,
"commands": commands, "filepaths": FILEPATHS, "gateway": self.configurations[0].get("gateway", {}),
"timeout": self.ssh_timeout}
Expand All @@ -370,6 +377,7 @@ def start_start_server_threads(self):
Starts for each provider a start_instances thread and joins them.
@return:
"""
self.log.debug("Running start_start_server_threads")
start_server_threads = []
worker_count = 0
ansible_configurator.write_yaml(a_rp.HOSTS_FILE, {"host_entries": {}}, self.log)
Expand Down Expand Up @@ -397,6 +405,7 @@ def extended_network_configuration(self):
Configure master/vpn-worker network for a multi/hybrid cloud
@return:
"""
self.log.debug("Running extended_network_configuration")
if len(self.providers) == 1:
return

Expand Down
2 changes: 1 addition & 1 deletion bibigrid/core/actions/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update(creator, log):
creator.configurations[0]["volumes"] = server["volumes"]
creator.prepare_configurations()
log.log(42, f"Uploading data and executing BiBiGrid's Ansible playbook to {creator.cluster_id}")
creator.upload_data(used_private_key)
creator.upload_data(used_private_key, clean_playbook=True)
log.log(42, f"Successfully updated cluster {creator.cluster_id}")
return 0
log.warning("One or more among master_ip, ssh_user and used_private_key are none. Aborting...")
Expand Down

0 comments on commit fc45d8b

Please sign in to comment.