Skip to content

Commit

Permalink
Fix name conflicts (#48)
Browse files Browse the repository at this point in the history
* Convert the unique name from time to a random suffix. Collisions in CI pipelines were common.

---------

Co-authored-by: Tim Meusel <[email protected]>
  • Loading branch information
jaevans and bastelfreak authored May 20, 2024
1 parent f4f7721 commit dd14afe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/beaker/hypervisor/google_compute.rb
Original file line number Diff line number Diff line change
@@ -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

##
Expand Down Expand Up @@ -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
Expand All @@ -97,15 +93,15 @@ 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
@internal_firewall_name = test_group_identifier + '-internal'
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?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dd14afe

Please sign in to comment.