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

vsphere-agents: reduce conflicts #879

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,16 @@ async fn create_vsphere_k8s_cluster(
serde_json::to_writer_pretty(&import_spec_file, &import_spec)
.context(*resources, "Failed to write out OVA import spec file")?;

// Delete any conflicting VM/template
let vm_template_name = format!("{}-eksa-vmtemplate", &config.name);
let _ = Command::new("govc")
.arg("vm.destroy")
.arg(&vm_template_name)
.status()
.context(*resources, "Failed to launch govc process")?;

// Import OVA and create a template out of it
info!("Importing OVA and creating a VM template out of it");
let vm_template_name = format!("{}-eksa-vmtemplate", &config.name);
let import_ova_output = Command::new("govc")
.arg("import.ova")
.arg("-options=/local/ova.importspec")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use std::process::Command;
use std::time::Duration;
use testsys_model::{Configuration, SecretName};
use toml::Value;
use uuid::Uuid;

/// The default number of VMs to spin up.
const DEFAULT_VM_COUNT: i32 = 2;
Expand Down Expand Up @@ -294,6 +295,14 @@ impl Create for VMCreator {
serde_json::to_writer_pretty(&import_spec_file, &import_spec)
.context(resources, "Failed to write out OVA import spec file")?;

// Delete any conflicting VM/template
let vm_template_name = format!("{}-node-vmtemplate", vsphere_cluster.name);
let _ = Command::new("govc")
.arg("vm.destroy")
.arg(&vm_template_name)
.status()
.context(resources, "Failed to launch govc process")?;

info!("Importing OVA");
memo.current_status = "Importing OVA".to_string();
client
Expand All @@ -302,7 +311,6 @@ impl Create for VMCreator {
.context(resources, "Error sending cluster creation message")?;
// Import OVA and create a template out of it
info!("Importing OVA and creating a VM template out of it");
let vm_template_name = format!("{}-node-vmtemplate", vsphere_cluster.name);
let import_ova_output = Command::new("govc")
.arg("import.ova")
.arg("-options=/local/ova.importspec")
Expand Down Expand Up @@ -377,8 +385,10 @@ impl Create for VMCreator {
.await
.context(resources, "Error sending cluster creation message")?;
info!("Launching {} Bottlerocket worker nodes", vm_count);
for i in 0..vm_count {
let node_name = format!("{}-node-{}", vsphere_cluster.name, i + 1);
for _ in 0..vm_count {
let mut vm_uuid = Uuid::new_v4().simple().to_string();
vm_uuid.truncate(8);
let node_name = format!("{}-node-{}", vsphere_cluster.name, vm_uuid);
info!("Cloning VM for worker node '{}'", node_name);
let vm_clone_output = Command::new("govc")
.arg("vm.clone")
Expand Down