Skip to content

Commit

Permalink
fix: upscale private nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and jacderida committed Jan 13, 2025
1 parent 1a762a8 commit 2a9200e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 68 deletions.
2 changes: 1 addition & 1 deletion resources/ansible/roles/nat_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
- name: Add eth1 of node VM to the NAT gateway with random parameter
command: >
iptables -t nat -A POSTROUTING -s {{ item }} -o eth0 -j MASQUERADE --random
loop: "{{ node_private_ips_eth1 }}"
when: nat_gateway_output.stdout.find(item) == -1
with_items: "{{ node_private_ips_eth1 }}"
3 changes: 0 additions & 3 deletions src/ansible/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ pub fn generate_private_node_static_environment_inventory(
AnsibleInventoryType::PrivateNodesStatic
.get_inventory_path(environment_name, "digital_ocean"),
);
if dest_path.exists() {
return Ok(());
}
debug!("Generating private node static inventory at {dest_path:?}",);

let mut file = File::create(&dest_path)?;
Expand Down
7 changes: 3 additions & 4 deletions src/ansible/provisioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,12 @@ impl AnsibleProvisioner {
return Err(Error::EmptyInventory(AnsibleInventoryType::PrivateNodes));
}

let vars = extra_vars::build_nat_gateway_extra_vars_doc(&options.name, private_ips);
debug!("Provisioning NAT Gateway with vars: {vars}");
self.ansible_runner.run_playbook(
AnsiblePlaybook::NatGateway,
AnsibleInventoryType::NatGateway,
Some(extra_vars::build_nat_gateway_extra_vars_doc(
&options.name,
private_ips,
)),
Some(vars),
)?;

print_duration(start.elapsed());
Expand Down
120 changes: 60 additions & 60 deletions src/upscale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl TestnetDeployer {
return Ok(());
}

let provision_options = ProvisionOptions {
let mut provision_options = ProvisionOptions {
binary_option: options.current_inventory.binary_option.clone(),
chunk_size: None,
downloaders_count: 0,
Expand Down Expand Up @@ -261,67 +261,67 @@ impl TestnetDeployer {
if should_provision_private_nodes {
println!("Private node provisioning will be skipped during upscale");
// TODO: Reenable this after examining and fixing the problems.
// let private_nodes = self
// .ansible_provisioner
// .ansible_runner
// .get_inventory(AnsibleInventoryType::PrivateNodes, true)
// .map_err(|err| {
// println!("Failed to obtain the inventory of private node: {err:?}");
// err
// })?;
// provision_options.private_node_vms = private_nodes;

// self.wait_for_ssh_availability_on_new_machines(
// AnsibleInventoryType::NatGateway,
// &options.current_inventory,
// )?;
// self.ansible_provisioner
// .print_ansible_run_banner("Provision NAT Gateway");
// self.ansible_provisioner
// .provision_nat_gateway(&provision_options)
// .map_err(|err| {
// println!("Failed to provision NAT gateway {err:?}");
// err
// })?;

// self.wait_for_ssh_availability_on_new_machines(
// AnsibleInventoryType::PrivateNodes,
// &options.current_inventory,
// )?;
// self.ansible_provisioner
// .print_ansible_run_banner("Provision Private Nodes");
// match self.ansible_provisioner.provision_private_nodes(
// &mut provision_options,
// Some(initial_multiaddr),
// Some(initial_network_contacts_url),
// ) {
// Ok(()) => {
// println!("Provisioned private nodes");
// }
// Err(err) => {
// log::error!("Failed to provision private nodes: {err}");
// node_provision_failed = true;
// }
// }
// }

// TODO: Uncomment when EVM-based payments are supported for the uploader upscale.
// if !is_bootstrap_deploy {
// self.wait_for_ssh_availability_on_new_machines(
// AnsibleInventoryType::Uploaders,
// &options.current_inventory,
// )?;
// self.ansible_provisioner
// .print_ansible_run_banner(n, total, "Provision Uploaders");
// self.ansible_provisioner
// .provision_uploaders(&provision_options, &initial_multiaddr)
// .await
// .map_err(|err| {
// println!("Failed to provision uploaders {err:?}");
// err
// })?;
let private_nodes = self
.ansible_provisioner
.ansible_runner
.get_inventory(AnsibleInventoryType::PrivateNodes, true)
.map_err(|err| {
println!("Failed to obtain the inventory of private node: {err:?}");
err
})?;
provision_options.private_node_vms = private_nodes;

self.wait_for_ssh_availability_on_new_machines(
AnsibleInventoryType::NatGateway,
&options.current_inventory,
)?;
self.ansible_provisioner
.print_ansible_run_banner("Provision NAT Gateway");
self.ansible_provisioner
.provision_nat_gateway(&provision_options)
.map_err(|err| {
println!("Failed to provision NAT gateway {err:?}");
err
})?;

self.wait_for_ssh_availability_on_new_machines(
AnsibleInventoryType::PrivateNodes,
&options.current_inventory,
)?;
self.ansible_provisioner
.print_ansible_run_banner("Provision Private Nodes");
match self.ansible_provisioner.provision_private_nodes(
&mut provision_options,
Some(initial_multiaddr),
Some(initial_network_contacts_url),
) {
Ok(()) => {
println!("Provisioned private nodes");
}
Err(err) => {
log::error!("Failed to provision private nodes: {err}");
node_provision_failed = true;
}
}
}

// // TODO: Uncomment when EVM-based payments are supported for the uploader upscale.
// if !is_bootstrap_deploy {
// self.wait_for_ssh_availability_on_new_machines(
// AnsibleInventoryType::Uploaders,
// &options.current_inventory,
// )?;
// self.ansible_provisioner
// .print_ansible_run_banner(n, total, "Provision Uploaders");
// self.ansible_provisioner
// .provision_uploaders(&provision_options, &initial_multiaddr)
// .await
// .map_err(|err| {
// println!("Failed to provision uploaders {err:?}");
// err
// })?;
// }

if node_provision_failed {
println!();
println!("{}", "WARNING!".yellow());
Expand Down

0 comments on commit 2a9200e

Please sign in to comment.