Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action 515 #516

Merged
merged 9 commits into from
Aug 16, 2024
Merged
Prev Previous commit
Next Next commit
fixed multiple workers due to faulty update
  • Loading branch information
XaverStiensmeier committed Aug 6, 2024
commit fc45d8b47bea9cce2bc3527f56f25a4168291e3f
13 changes: 11 additions & 2 deletions bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
@@ -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)")
@@ -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}
@@ -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)
@@ -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

2 changes: 1 addition & 1 deletion bibigrid/core/actions/update.py
Original file line number Diff line number Diff line change
@@ -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...")
Loading