From 580981750d8fd4f0354746ce31694750f6b4b951 Mon Sep 17 00:00:00 2001 From: James Evans Date: Thu, 16 May 2024 09:55:58 -0500 Subject: [PATCH 1/2] Convert the unique name from time to a random suffix. Collisions in CI pipelines were common. --- lib/beaker/hypervisor/google_compute.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/beaker/hypervisor/google_compute.rb b/lib/beaker/hypervisor/google_compute.rb index 551d7cf..7ed50fd 100644 --- a/lib/beaker/hypervisor/google_compute.rb +++ b/lib/beaker/hypervisor/google_compute.rb @@ -1,13 +1,10 @@ -require 'time' +require 'securerandom' module Beaker # Beaker support for the Google Compute Engine. class GoogleCompute < Beaker::Hypervisor SLEEPWAIT = 5 - # Hours before an instance is considered a zombie - ZOMBIE = 3 - # Do some reasonable sleuthing on the SSH public key for GCE ## @@ -87,8 +84,7 @@ def initialize(google_hosts, options) # Create and configure virtual machines in the Google Compute Engine, # including their associated disks and firewall rules def provision - start = Time.now - test_group_identifier = "beaker-#{start.to_i}" + test_group_identifier = "beaker-${SecureRandom.hex(4)}" # set firewall to open pe ports network = @gce_helper.get_network @@ -97,7 +93,7 @@ def provision # Always allow ssh from anywhere as it's needed for Beaker to run @gce_helper.create_firewall(@external_firewall_name, network, allow: @options[:gce_ports] + ['22/tcp'], source_ranges: ['0.0.0.0/0'], target_tags: [test_group_identifier]) - + @logger.debug("Created External Google Compute firewall #{@external_firewall_name}") # Create a firewall that opens everything between all the hosts in this test group @@ -105,7 +101,7 @@ def provision internal_ports = ['1-65535/tcp', '1-65535/udp', '-1/icmp'] @gce_helper.create_firewall(@internal_firewall_name, network, allow: internal_ports, source_tags: [test_group_identifier], target_tags: [test_group_identifier]) @logger.debug("Created test group Google Compute firewall #{@internal_firewall_name}") - + @hosts.each do |host| machine_type_name = ENV.fetch('BEAKER_gce_machine_type', host['gce_machine_type']) raise "Must provide a machine type name in 'gce_machine_type'." if machine_type_name.nil? @@ -194,7 +190,7 @@ def provision value: 'FALSE' }, ] - + # Check for google's default windows images and turn on ssh if found if image_project == "windows-cloud" || image_project == "windows-sql-cloud" # Turn on SSH on GCP's default windows images From 42d4404f6917060d3994479a225a61b1be350472 Mon Sep 17 00:00:00 2001 From: James Evans Date: Thu, 16 May 2024 11:26:30 -0500 Subject: [PATCH 2/2] Fix typo --- lib/beaker/hypervisor/google_compute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beaker/hypervisor/google_compute.rb b/lib/beaker/hypervisor/google_compute.rb index 7ed50fd..a1bc589 100644 --- a/lib/beaker/hypervisor/google_compute.rb +++ b/lib/beaker/hypervisor/google_compute.rb @@ -84,7 +84,7 @@ def initialize(google_hosts, options) # Create and configure virtual machines in the Google Compute Engine, # including their associated disks and firewall rules def provision - test_group_identifier = "beaker-${SecureRandom.hex(4)}" + test_group_identifier = "beaker-#{SecureRandom.hex(4)}" # set firewall to open pe ports network = @gce_helper.get_network