From 2a5978d66c87cbbe48c81cf34919aef1257ce1df Mon Sep 17 00:00:00 2001 From: BoYuan Chang Date: Tue, 12 Apr 2022 11:08:19 -0500 Subject: [PATCH] Set compression method based on platform core number This change will switch to PIGZ for file compression when working with more platform CPUs for faster run time. PIGZ is also added as the required file in playbook config. Test Plan: 1. Bring up StarlingX and verify that pigz utility is available. 2. Perform prestage for a subcloud with less than 4 platform cores. Verify that gzip compression is used. 3. Perform prestage for a subcloud with 4 platform cores. Verify that pigz compression is used. Story: 2009948 Task: 45045 Signed-off-by: BoYuan Chang Change-Id: I77a999df87183946661ceac6845b986c1a009e2f --- playbookconfig/centos/playbookconfig.spec | 1 + playbookconfig/debian/deb_folder/control | 1 + .../prestage-images/files/gen-image-bundles.sh | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/playbookconfig/centos/playbookconfig.spec b/playbookconfig/centos/playbookconfig.spec index f88dfa696..016407f11 100644 --- a/playbookconfig/centos/playbookconfig.spec +++ b/playbookconfig/centos/playbookconfig.spec @@ -9,6 +9,7 @@ URL: unknown Source0: %{name}-%{version}.tar.gz Requires: ansible +Requires: pigz Requires: pyparted Requires: python Requires: python2-netaddr diff --git a/playbookconfig/debian/deb_folder/control b/playbookconfig/debian/deb_folder/control index f55d30940..71a06472d 100644 --- a/playbookconfig/debian/deb_folder/control +++ b/playbookconfig/debian/deb_folder/control @@ -10,6 +10,7 @@ Package: playbookconfig Architecture: all Depends: ${misc:Depends}, ansible, + pigz, python3, python3-netaddr, python3-ptyprocess, diff --git a/playbookconfig/src/playbooks/roles/prestage/prestage-images/files/gen-image-bundles.sh b/playbookconfig/src/playbooks/roles/prestage/prestage-images/files/gen-image-bundles.sh index a6dbac395..690adcbdc 100644 --- a/playbookconfig/src/playbooks/roles/prestage/prestage-images/files/gen-image-bundles.sh +++ b/playbookconfig/src/playbooks/roles/prestage/prestage-images/files/gen-image-bundles.sh @@ -20,6 +20,12 @@ IMAGE_BUNDLES="" # Registry Images are loaded into this array declare -a IMAGE_ARRAY=() +# Find out how many CPUs are assigned to platform +NUM_OF_PLATFORM_CPU=$(cat /etc/platform/worker_reserved.conf | \ +grep PLATFORM_CPU_LIST | \ +perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg' | \ +grep -Eo '[0-9]+' | wc -l) + LOG_FILE="/tmp/$(basename $0).log" function log { @@ -39,7 +45,11 @@ function generate_image_bundle { log "Generating image bundle ${bundle_num}..." log "Image list: ${images}, list size: ${list_size}, \ bundle: ${bundle_num}, output file: ${OUTPUT}" - docker save $(echo "${images}") | gzip > ${OUTPUT} + if (( NUM_OF_PLAT_CPU < 4)); then + docker save $(echo "${images}") | gzip > ${OUTPUT} + else + docker save $(echo "${images}") | pigz > ${OUTPUT} + fi IMAGE_BUNDLES=${IMAGE_BUNDLES}" "$(basename ${OUTPUT}) }