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

[Linux] Update GOSC test scope and handle known issues with workaround #608

Merged
merged 16 commits into from
Jul 16, 2024
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
4 changes: 2 additions & 2 deletions linux/guest_customization/check_gosc_log.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
dest_path: "{{ gosc_deploypkg_log_local }}"

- name: "Check traditional GOSC log in {{ gosc_deploypkg_log_local }}"
when: gosc_workflow == "perl"
when: not enable_cloudinit_gosc
include_tasks: check_log_msg.yml
vars:
check_log_file: "{{ gosc_deploypkg_log_local }}"
Expand All @@ -27,7 +27,7 @@
loop_var: "check_msg_regexp"

- name: "Check cloud-init GOSC log in {{ gosc_deploypkg_log_local }}"
when: gosc_workflow == "cloud-init"
when: enable_cloudinit_gosc
include_tasks: check_log_msg.yml
vars:
check_log_file: "{{ gosc_deploypkg_log_local }}"
Expand Down
69 changes: 43 additions & 26 deletions linux/guest_customization/check_gosc_support_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
- vcenter_version is version('8.0.0', '<')

- name: "Check GOSC support status"
when:
- guest_os_ansible_distribution is defined
- guest_os_ansible_distribution_ver is defined
- vcenter_version is defined and vcenter_version != 'N/A'
- vcenter_build is defined and vcenter_build != 'N/A'
block:
- name: "Initialize GOSC support status"
ansible.builtin.set_fact:
gosc_is_supported: true

- name: "Check Perl GOSC support status for VMware Photon OS"
when:
- guest_os_ansible_distribution == 'VMware Photon OS'
- not enable_cloudinit_gosc
block:
- name: "Get open-vm-tools package info"
include_tasks: ../utils/get_installed_package_info.yml
Expand All @@ -52,10 +60,7 @@
vars:
skip_msg: "Perl GOSC is not applicable for {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} with not bundled open-vm-tools {{ vmtools_version }}."
skip_reason: "Not Applicable"
when: not gosc_is_supported | bool
when:
- guest_os_ansible_distribution == 'VMware Photon OS'
- not enable_cloudinit_gosc | bool
when: not gosc_is_supported

- name: "Set default guest OS list not support GOSC"
ansible.builtin.set_fact:
Expand All @@ -67,13 +72,18 @@
- "Fedora"
- "openSUSE Leap"
- "RHCOS"
- "Amazon"

- name: "Set fact of GOSC support status to False for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
gosc_is_supported: false
when: guest_os_ansible_distribution in gos_not_support_gosc

- name: "Set cloud-init GOSC support status for {{ vm_guest_os_distribution }}"
when:
- enable_cloudinit_gosc
- guest_os_ansible_distribution == "Debian"
- guest_os_ansible_distribution_major_ver | int == 12
block:
- name: "Set fact of cloud-init GOSC support status to False for {{ vm_guest_os_distribution }}"
ansible.builtin.set_fact:
Expand All @@ -86,26 +96,35 @@
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1776452 and
https://bugs.launchpad.net/cloud-init/+bug/1944946.
So skip cloud-init GOSC testing for {{ vm_guest_os_distribution }}.
when:
- enable_cloudinit_gosc | bool
- guest_os_ansible_distribution == "Debian"
- guest_os_ansible_distribution_major_ver | int == 12

- name: "Check Perl GOSC support status for {{ vm_guest_os_distribution }}"
when:
- not enable_cloudinit_gosc | bool
- not enable_cloudinit_gosc
- guest_os_ansible_distribution not in gos_not_support_gosc
block:
- name: "Get GOSC support matrix"
- name: "Set fact of Perl GOSC support matrix"
ansible.builtin.set_fact:
gosc_support_matrix: "{{ lookup('file', 'gosc_support_matrix.yml') | from_yaml }}"

- name: "Set fact of Perl GOSC support matrix for {{ guest_os_ansible_distribution }}"
ansible.builtin.set_fact:
guest_gosc_suport_matrix: "{{ gosc_support_matrix[guest_os_ansible_distribution] | default({}) }}"

# RHEL family OS 9.0 or higher version aligns with GOSC support status for same version of RHEL
- name: "Combine with RedHat family GOSC support status for {{ vm_guest_os_distribution }}"
ansible.builtin.set_fact:
guest_gosc_suport_matrix: "{{ guest_gosc_suport_matrix | combine(gosc_support_matrix[guest_os_family]) }}"
when:
- guest_os_family == "RedHat"
- guest_os_ansible_distribution not in ['RedHat', 'MIRACLE']
- guest_os_ansible_distribution_major_ver | int >= 9

- name: "Check Perl GOSC support status for {{ vm_guest_os_distribution }} in support matrix"
when: gosc_support_matrix[guest_os_ansible_distribution] is defined
when: guest_gosc_suport_matrix | length > 0
block:
- name: "Get {{ guest_os_ansible_distribution }} Perl GOSC testing supported OS versions"
ansible.builtin.set_fact:
gosc_matrix_os_versions: "{{ gosc_support_matrix[guest_os_ansible_distribution] | dict2items | map(attribute='key') }}"
gosc_matrix_os_versions: "{{ guest_gosc_suport_matrix | dict2items | map(attribute='key') }}"
gosc_matrix_first_os_version: None

- name: "Get the first OS version supporting Perl GOSC testing on {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver | int }}.x"
Expand All @@ -117,43 +136,46 @@
((guest_os_ansible_distribution_ver | int) > (item | int))
with_items: "{{ gosc_matrix_os_versions }}"

- name: "Display the first OS version supporting Perl GOSC testing for {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_major_ver }}"
ansible.builtin.debug: var=gosc_matrix_first_os_version

- name: "Get Perl GOSC supported VC versions and builds"
when: gosc_matrix_first_os_version != 'None'
block:
- name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC supported VC versions and builds"
ansible.builtin.set_fact:
gosc_matrix_vc_list: "{{ gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'] | dict2items | map(attribute='key') }}"
gosc_matrix_vc_list: "{{ guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vcenter'] | dict2items | map(attribute='key') }}"

- name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC support status on VC {{ vcenter_version }} build {{ vcenter_build }}"
ansible.builtin.set_fact:
gosc_is_supported: false
when: >
(vcenter_version in gosc_matrix_vc_list and
((gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'][vcenter_version] == 'N/A') or
(vcenter_build | int < gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'][vcenter_version] | int)) or
((guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vcenter'][vcenter_version] == 'N/A') or
(vcenter_build | int < guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vcenter'][vcenter_version] | int)) or
(vcenter_version is version(gosc_matrix_vc_list[0], '<')))

- name: "Get Perl GOSC supported open-vm-tools version for {{ vm_guest_os_distribution }}"
when:
- gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'] is defined
- gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools']
- guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vmtools'] is defined
- guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vmtools']
block:
- name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC supported open-vm-tools version"
ansible.builtin.set_fact:
gosc_matrix_vmtools_version: "{{ gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'] }}"
gosc_matrix_vmtools_version: "{{ guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vmtools'] }}"

- name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC support status with open-vm-tools {{ vmtools_version }}"
ansible.builtin.set_fact:
gosc_is_supported: false
when: vmtools_version is version(gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'], '<')
when: vmtools_version is version(guest_gosc_suport_matrix[gosc_matrix_first_os_version]['vmtools'], '<')

keirazhang marked this conversation as resolved.
Show resolved Hide resolved
- name: "Display GOSC support status for {{ vm_guest_os_distribution }}"
ansible.builtin.debug:
msg: >-
GOSC is supported for {{ vm_guest_os_distribution }} with open-vm-tools {{ vmtools_version }}
on vCenter Server {{ vcenter_version }} build {{ vcenter_build }}.
See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf.
when: gosc_is_supported | bool
when: gosc_is_supported

- name: "Skip test case due to GOSC is not supported for {{ vm_guest_os_distribution }}"
include_tasks: ../../common/skip_test_case.yml
Expand All @@ -164,9 +186,4 @@
vCenter Server {{ vcenter_version }} build {{ vcenter_build }}.
See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf.
skip_reason: "Not Supported"
when: not gosc_is_supported | bool
when:
- guest_os_ansible_distribution is defined
- guest_os_ansible_distribution_ver is defined
- vcenter_version is defined and vcenter_version != 'N/A'
- vcenter_build is defined and vcenter_build != 'N/A'
when: not gosc_is_supported
8 changes: 4 additions & 4 deletions linux/guest_customization/check_network_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@
- name: "Set traditional GOSC network configuration file on Ubuntu {{ guest_os_ansible_distribution_ver }}"
ansible.builtin.set_fact:
src_network_file: "/etc/netplan/99-netcfg-vmware.yaml"
when: "gosc_workflow == 'perl'"
when: not enable_cloudinit_gosc

- name: "Set cloud-init GOSC network configuration file on Ubuntu {{ guest_os_ansible_distribution_ver }}"
ansible.builtin.set_fact:
src_network_file: "/etc/netplan/50-cloud-init.yaml"
when: "gosc_workflow == 'cloud-init'"
when: enable_cloudinit_gosc

# On Debian 10/11 or Ubuntu Desktop eariler than 19.10, the network configure file is
# /etc/network/interfaces
Expand All @@ -145,10 +145,10 @@
- name: "Set traditional GOSC network configuration file on {{ vm_guest_os_distribution }}"
ansible.builtin.set_fact:
src_network_file: "/etc/network/interfaces"
when: "gosc_workflow == 'perl'"
when: not enable_cloudinit_gosc

- name: "Set cloud-init GOSC network configuration file on {{ vm_guest_os_distribution }}"
when: "gosc_workflow == 'cloud-init'"
when: enable_cloudinit_gosc
block:
- name: "Set cloud-init GOSC network configuration file on {{ vm_guest_os_distribution }}"
ansible.builtin.set_fact:
Expand Down
76 changes: 46 additions & 30 deletions linux/guest_customization/check_timezone_and_hwclock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,62 @@
ansible.builtin.set_fact:
guest_hwclockUTC: ""
hwclock_success: ""
when: gosc_workflow == "perl"
when: not enable_cloudinit_gosc

# Try to get timezone info by 'timedatectl' command
- include_tasks: ../../common/vm_shell_in_guest.yml
# Try to get timedatectl status
- name: "Get the result of 'timedatectl status'"
include_tasks: ../../common/vm_shell_in_guest.yml
vars:
vm_shell_cmd: "/usr/bin/timedatectl"
vm_shell_args: "status"
vm_shell_out: "/tmp/timedatectl_status.txt"

# If 'timedatectl' command succeed
- block:
- include_tasks: ../../common/vm_guest_file_operation.yml
- name: "Get timezone and hardware clock when 'timedatectl status' succeeded"
when:
- vm_shell_result.exit_code is defined
- vm_shell_result.exit_code == 0
block:
- name: "Fetch the output file of 'timedatectl status'"
include_tasks: ../../common/vm_guest_file_operation.yml
vars:
operation: "fetch_file"
src_path: "/tmp/timedatectl_status.txt"
dest_path: "{{ current_test_log_folder }}/timedatectl_status.txt"

- name: "Get time zone from 'timedatectl status'"
- name: "Get timezone from 'timedatectl status'"
ansible.builtin.set_fact:
guest_timedate_status: "{{ lookup('file', current_test_log_folder ~ '/timedatectl_status.txt') | regex_search('\\s*Time zone:\\s*[^\\n]+\\n?') }}"

- name: "Set fact of guest time zone after GOSC"
- name: "Set fact of guest timezone after GOSC"
ansible.builtin.set_fact:
guest_timezone: "{{ guest_timedate_status | regex_replace('.*\\s*Time zone:\\s*([^\\s]+)\\s*.*\\n?', '\\1')}}"

- block:
- name: "Get hwclock from 'timedatectl status'"
- name: "Get hardware clock from 'timedatectl status'"
when: not enable_cloudinit_gosc
block:
- name: "Get hardware clock from 'timedatectl status'"
include_tasks: ../utils/file_content_search.yml
vars:
path: "{{ current_test_log_folder }}/timedatectl_status.txt"
regexp: "^ *RTC in local TZ: no"
register: hwclock_result

- name: "Save guest hardware clock setting after GOSC"
ansible.builtin.set_fact:
guest_hwclockUTC: "{{ regexp_found | int > 0 }}"
when: (gosc_workflow == "perl")
when: vm_shell_result.exit_code is defined and vm_shell_result.exit_code == 0

# If 'timedatectl' command failed
# Get timezone by reading symbolic link of /etc/localtime
- block:
- include_tasks: ../../common/vm_shell_in_guest.yml
- name: "Get timezone and hardware clock when 'timedatectl status' command failed"
when: vm_shell_result.exit_code is undefined or vm_shell_result.exit_code != 0
block:
- name: "Read the symbolic link of /etc/localtime"
include_tasks: ../../common/vm_shell_in_guest.yml
vars:
vm_shell_cmd: "/usr/bin/readlink"
vm_shell_args: "/etc/localtime"
vm_shell_out: "/tmp/readlink_etc_localtime.txt"

- include_tasks: ../../common/vm_guest_file_operation.yml
- name: "Fetch the real file of /etc/localtime"
include_tasks: ../../common/vm_guest_file_operation.yml
vars:
operation: "fetch_file"
src_path: "/tmp/readlink_etc_localtime.txt"
Expand All @@ -67,53 +75,61 @@
ansible.builtin.set_fact:
guest_timezone: "{{ lookup('file', current_test_log_folder ~ '/readlink_etc_localtime.txt') | replace('/usr/share/zoneinfo/','') }}"

# Get hwclock by running command "hwclock -D" when test perl GOSC
- block:
- include_tasks: ../../common/vm_shell_in_guest.yml
- name: "Get hardware clock by running command 'hwclock -D' for perl GOSC"
when: not enable_cloudinit_gosc
block:
- name: "Execute command 'hwclock -D'"
include_tasks: ../../common/vm_shell_in_guest.yml
vars:
vm_shell_cmd: "/usr/sbin/hwclock"
vm_shell_args: "-D"
vm_shell_out: "/tmp/hwclock_D.txt"
- include_tasks: ../../common/vm_guest_file_operation.yml

- name: "Fetch the output file of 'hwclock -D'"
include_tasks: ../../common/vm_guest_file_operation.yml
vars:
operation: "fetch_file"
src_path: "/tmp/hwclock_D.txt"
dest_path: "{{ current_test_log_folder }}/hwclock_D.txt"
- name: "Get hwclock from 'hwclock -D'"

- name: "Get hardware clock from the output of 'hwclock -D'"
include_tasks: ../utils/file_content_search.yml
vars:
path: "{{ current_test_log_folder }}/hwclock_D.txt"
regexp: "^Hardware clock is on UTC time"

- name: "Save hardware clock settting after GOSC"
ansible.builtin.set_fact:
guest_hwclockUTC: "{{ regexp_found | int > 0 }}"
when: gosc_workflow == "perl"
when: vm_shell_result.exit_code is undefined or vm_shell_result.exit_code != 0

# Check guest time zone
# Check guest timezone
- name: "Check guest timezone is customized"
ansible.builtin.set_fact:
timezone_success: "{{ guest_timezone == linux_gosc_spec['timezone'] }}"

- name: "Print timezone check result"
ansible.builtin.debug: var=timezone_success

- include_tasks: set_gosc_validation_result.yml
- name: "Set validation result for customizing timezone"
include_tasks: set_gosc_validation_result.yml
vars:
gosc_check_item: "timezone_success"
gosc_check_error_msg: "VM timezone is {{ guest_timezone }}, expected timezone is {{ linux_gosc_spec['timezone'] }}"

# Check guest hwclock
# cloud-init GOSC doesn't support hwclock customization
- block:
- name: Check guest hwclock is customized
- name: "Check guest hardware clock is customized"
when: not enable_cloudinit_gosc
block:
- name: "Check guest hardware clock is customized"
ansible.builtin.set_fact:
hwclock_success: "{{ guest_hwclockUTC == linux_gosc_spec['hwclockUTC'] }}"

- name: "Print hardware clock check result"
ansible.builtin.debug: var=hwclock_success

- include_tasks: set_gosc_validation_result.yml
- name: "Set validation result for customizing hardware clock"
include_tasks: set_gosc_validation_result.yml
vars:
gosc_check_item: "hwclock_success"
gosc_check_error_msg: "VM hwclockUTC is {{ guest_hwclockUTC }}, expected hwclockUTC is {{ linux_gosc_spec['hwclockUTC'] }}"
when: gosc_workflow == "perl"
Loading