-
Notifications
You must be signed in to change notification settings - Fork 202
agent: introduce openshift-appliance flow #1547
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,12 +82,16 @@ function set_device_config_image() { | |
| done | ||
| } | ||
|
|
||
| function set_file_acl() { | ||
| # This is required to allow qemu opening the disk image | ||
| if [ "${OPENSHIFT_CI}" == true ]; then | ||
| setfacl -m u:qemu:rx /root | ||
| fi | ||
| } | ||
|
|
||
| function attach_agent_iso() { | ||
|
|
||
| # This is required to allow qemu opening the disk image | ||
| if [ "${OPENSHIFT_CI}" == true ]; then | ||
| setfacl -m u:qemu:rx /root | ||
| fi | ||
| set_file_acl | ||
|
|
||
| local agent_iso="${OCP_DIR}/agent.$(uname -p).iso" | ||
| if [ ! -f "${agent_iso}" -a -f "${OCP_DIR}/agent.iso" ]; then | ||
|
|
@@ -112,6 +116,35 @@ function attach_agent_iso() { | |
|
|
||
| } | ||
|
|
||
| function attach_appliance_diskimage() { | ||
| set_file_acl | ||
|
|
||
| local config_image_drive="sdd" | ||
| local appliance_disk_image="${OCP_DIR}/appliance.raw" | ||
|
|
||
| # Create the config ISO | ||
| mkdir -p ${config_image_dir} | ||
| cp ${asset_dir}/*.yaml ${config_image_dir} | ||
| create_config_image | ||
|
|
||
| for (( n=0; n<${2}; n++ )) | ||
| do | ||
| name=${CLUSTER_NAME}_${1}_${n} | ||
| disk_image=${appliance_disk_image}_${1}_${n} | ||
|
|
||
| # Every node needs a copy of the appliance disk image | ||
| sudo cp "${appliance_disk_image}" "${disk_image}" | ||
|
|
||
| # Attach the appliance disk image and the config ISO | ||
| sudo virt-xml ${name} --remove-device --disk 1 | ||
| sudo virt-xml ${name} --add-device --disk "${disk_image}",device=disk,target.dev=sda | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: what's the reason to remove and re-add the disk?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we don't need the default disk attached to the machine, as we're using our own generated disk image. I.e. need to replace the existing disk with our own. |
||
| sudo virt-xml ${name} --add-device --disk "${config_image_dir}/agentconfig.noarch.iso",device=cdrom,target.dev=${config_image_drive} | ||
|
|
||
| # Boot machine from the appliance disk image | ||
| sudo virt-xml ${name} --edit target=sda --disk="boot_order=1" --start | ||
| done | ||
| } | ||
|
|
||
| function get_node0_ip() { | ||
| node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0) | ||
| node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -) | ||
|
|
@@ -178,7 +211,7 @@ function enable_assisted_service_ui() { | |
| function wait_for_cluster_ready() { | ||
| local openshift_install="$(realpath "${OCP_DIR}/openshift-install")" | ||
| local dir="${OCP_DIR}" | ||
| if [[ "${AGENT_USE_APPLIANCE_MODEL}" == true ]]; then | ||
| if [[ "${AGENT_USE_APPLIANCE_MODEL}" == true || "${AGENT_E2E_TEST_BOOT_MODE}" == "DISKIMAGE" ]]; then | ||
| dir="${config_image_dir}" | ||
| fi | ||
| if ! "${openshift_install}" --dir="${dir}" --log-level=debug agent wait-for bootstrap-complete; then | ||
|
|
@@ -294,6 +327,14 @@ function agent_pxe_boot() { | |
| done | ||
| } | ||
|
|
||
| function create_appliance() { | ||
| local asset_dir="$(realpath "${1}")" | ||
|
|
||
| # Build appliance with `debug-base-ignition` flag for using the custom openshift-install | ||
| # binary from assets directory. | ||
| sudo podman run -it --rm --pull newer --privileged --net=host -v ${asset_dir}:/assets:Z ${APPLIANCE_IMAGE} build --debug-base-ignition | ||
| } | ||
|
|
||
| asset_dir="${1:-${OCP_DIR}}" | ||
| config_image_dir="${1:-${OCP_DIR}/configimage}" | ||
| openshift_install="$(realpath "${OCP_DIR}/openshift-install")" | ||
|
|
@@ -315,7 +356,16 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in | |
|
|
||
| agent_pxe_boot master $NUM_MASTERS | ||
| agent_pxe_boot worker $NUM_WORKERS | ||
| ;; | ||
| ;; | ||
|
|
||
| "DISKIMAGE" ) | ||
| # Build disk image using openshift-appliance | ||
| create_appliance ${asset_dir} | ||
|
|
||
| # Attach the diskimage to nodes | ||
| attach_appliance_diskimage master $NUM_MASTERS | ||
| attach_appliance_diskimage worker $NUM_WORKERS | ||
| ;; | ||
| esac | ||
|
|
||
| if [ ! -z "${AGENT_TEST_CASES:-}" ]; then | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| - name: write the appliance-config.yaml | ||
| template: | ||
| src: "appliance-config_yaml.j2" | ||
| dest: "{{ install_path }}/appliance-config.yaml" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v1beta1 | ||
| kind: ApplianceConfig | ||
| ocpRelease: | ||
| version: {{ version }} | ||
| channel: candidate | ||
| cpuArchitecture: {{ ansible_architecture }} | ||
| diskSizeGB: 200 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the diskSizeGB be set to a smaller size? 200G per VM fills up the disk on my local test machine. What would be a recommended minimum size?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actaully only the virtual size of the disk, so it shouldn't consume that much space of disk. The actual size is ~40GiB. |
||
| pullSecret: {{ pull_secret_contents }} | ||
| sshKey: {{ ssh_pub_key }} | ||
| imageRegistry: | ||
| uri: quay.io/libpod/registry:2.8 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -457,10 +457,15 @@ if [[ ! -z ${AGENT_E2E_TEST_SCENARIO} ]]; then | |
| fi | ||
|
|
||
| if [[ ! -z ${AGENT_E2E_TEST_BOOT_MODE} ]]; then | ||
| if [[ $AGENT_E2E_TEST_BOOT_MODE != "ISO" && $AGENT_E2E_TEST_BOOT_MODE != "PXE" ]]; then | ||
| printf "Found invalid value \"$AGENT_E2E_TEST_BOOT_MODE\" for AGENT_E2E_TEST_BOOT_MODE. Supported values: ISO (default), PXE." | ||
| case "$AGENT_E2E_TEST_BOOT_MODE" in | ||
| "ISO" | "PXE" | "DISKIMAGE") | ||
| # Valid value | ||
| ;; | ||
| *) | ||
| printf "Found invalid value \"$AGENT_E2E_TEST_BOOT_MODE\" for AGENT_E2E_TEST_BOOT_MODE. Supported values: ISO (default), PXE, DISKIMAGE." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: feeling that a case may be a little bit more readable with a longer list, ie something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea:) Added. |
||
| exit 1 | ||
| fi | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
| # For IPv6 (default case) mirror images are used since quay doesn't support IPv6 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this function populates the $OCP_DIR with several artifacts, but the
make cleanis broken as thecacheandtempfolder are created under therootuser. Please add the required cleaning steps so that it would be possible to remove everything when running thecleantargetThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, good catch, will add.