Skip to content

Commit

Permalink
Merge pull request #20951 from mloviska/chost_no_regionsrv
Browse files Browse the repository at this point in the history
CHOSTs do not container cloud-regionsrv-client
  • Loading branch information
mloviska authored Jan 14, 2025
2 parents 6bd780f + 5d4eb3f commit 8b8e2d1
Showing 1 changed file with 50 additions and 47 deletions.
97 changes: 50 additions & 47 deletions lib/publiccloud/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,45 @@ our @EXPORT = qw(
ssh_update_transactional_system
);

# Check if we are a BYOS test run
sub is_byos() {
return is_public_cloud && get_var('FLAVOR') =~ 'BYOS';
}

# Check if we are a OnDemand test run
sub is_ondemand() {
# By convention OnDemand images are not marked explicitly.
# Check all the other flavors, and if they don't match, it must be on_demand.
return is_public_cloud && (!is_byos()); # When introducing new flavors, add checks here accordingly.
}

# Check if we are on an AWS test run
sub is_ec2() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'EC2');
}

# Check if we are on an Azure test run
sub is_azure() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'AZURE');
}

# Check if we are on an GCP test run
sub is_gce() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'GCE');
}

sub is_container_host() {
return is_public_cloud && get_var('FLAVOR') =~ 'CHOST';
}

sub is_hardened() {
return is_public_cloud && get_var('FLAVOR') =~ 'Hardened';
}

sub is_cloudinit_supported {
return ((is_azure || is_ec2) && !is_sle_micro);
}

# Get the current UTC timestamp as YYYY/mm/dd HH:MM:SS
sub utc_timestamp {
my @weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
Expand Down Expand Up @@ -155,14 +194,17 @@ sub registercloudguest {
my $suseconnect = $path . get_var("PUBLIC_CLOUD_SCC_ENDPOINT", "registercloudguest");
my $cmd_time = time();

# Check what version of registercloudguest binary we use
my $version = $instance->ssh_script_output(cmd => 'rpm -q --queryformat "%{VERSION}\n" cloud-regionsrv-client');
# Only a specific version of the package has issue and only on a specific SP
# Do not activate the workaround if the user explicitly decide using a specific ENDPOINT
record_info("DEBUG", "is_sle():" . is_sle('15-SP2+') . " version:$version check_version:" . check_version('<10.1.7', $version) . " PCSE:" . (!get_var('PUBLIC_CLOUD_SCC_ENDPOINT')));
if (is_sle('15-SP2+') && check_version('<10.1.7', $version) && !get_var('PUBLIC_CLOUD_SCC_ENDPOINT')) {
record_soft_failure("bsc#1217583 IPv6 handling during registration. Force use SUSEConnect to work around it.");
$suseconnect = 'SUSEConnect';
# Check what version of registercloudguest binary we use, chost images have none pre-installed
my $version = $instance->ssh_script_output(cmd => 'rpm -q --queryformat "%{VERSION}\n" cloud-regionsrv-client', proceed_on_failure => 1);
if ($version =~ /cloud-regionsrv-client is not installed/) {
die 'cloud-regionsrv-client should not be installed' if !is_container_host;
} else {
# Only a specific version of the package has issue and only on a specific SP
# Do not activate the workaround if the user explicitly decide using a specific ENDPOINT
if (is_sle('15-SP2+') && check_version('<10.1.7', $version) && !get_var('PUBLIC_CLOUD_SCC_ENDPOINT')) {
record_soft_failure("bsc#1217583 IPv6 handling during registration. Force use SUSEConnect to work around it.");
$suseconnect = 'SUSEConnect';
}
}
$instance->ssh_script_retry(cmd => "sudo $suseconnect -r $regcode", timeout => 420, retry => 3, delay => 120);
if (script_run('ssh -O check ' . $instance->username . '@' . $instance->public_ip) == 0) {
Expand Down Expand Up @@ -215,45 +257,6 @@ sub validate_repo {
die "Unexpected URL \"$maintrepo\"";
}

# Check if we are a BYOS test run
sub is_byos() {
return is_public_cloud && get_var('FLAVOR') =~ 'BYOS';
}

# Check if we are a OnDemand test run
sub is_ondemand() {
# By convention OnDemand images are not marked explicitly.
# Check all the other flavors, and if they don't match, it must be on_demand.
return is_public_cloud && (!is_byos()); # When introducing new flavors, add checks here accordingly.
}

# Check if we are on an AWS test run
sub is_ec2() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'EC2');
}

# Check if we are on an Azure test run
sub is_azure() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'AZURE');
}

# Check if we are on an GCP test run
sub is_gce() {
return is_public_cloud && check_var('PUBLIC_CLOUD_PROVIDER', 'GCE');
}

sub is_container_host() {
return is_public_cloud && get_var('FLAVOR') =~ 'CHOST';
}

sub is_hardened() {
return is_public_cloud && get_var('FLAVOR') =~ 'Hardened';
}

sub is_cloudinit_supported {
return ((is_azure || is_ec2) && !is_sle_micro);
}

# Get credentials from the Public Cloud micro service, which requires user
# and password. The resulting json will be stored in a file.
sub get_credentials {
Expand Down

0 comments on commit 8b8e2d1

Please sign in to comment.