From bf84d27403d02a4a64bd7d9019c43c7585fd804d Mon Sep 17 00:00:00 2001 From: Matthew Fuller Date: Mon, 24 Feb 2020 16:01:29 -0800 Subject: [PATCH] Add support for modifying genesis kernel parameters for OVS-DPDK OVS-DPDK requires that hugepages are configured and available on the host. This change allows the kernel parameters specified in the primary CP HostProfile to be applied to the genesis node by setting GENESIS_HOST_PROFILE and sourcing it before running gate.sh. Change-Id: I392a08300920327d7002a413ba40edbb81c020c2 --- .../airship_gate/lib/bootaction-runner.sh | 54 ++++++++++++++++++- .../airship_gate/stages/genesis-setup.sh | 6 ++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/tools/deployment/seaworthy-virt/airship_gate/lib/bootaction-runner.sh b/tools/deployment/seaworthy-virt/airship_gate/lib/bootaction-runner.sh index 747c740bf..bd2f37891 100755 --- a/tools/deployment/seaworthy-virt/airship_gate/lib/bootaction-runner.sh +++ b/tools/deployment/seaworthy-virt/airship_gate/lib/bootaction-runner.sh @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +GENESIS_HOST_PROFILE=${2:-} ############################################################################### # Helper functions @@ -64,8 +65,8 @@ install_file(){ local path="$1" local content="$2" local permissions="$3" - local dirname - dirname=$(dirname "$path") + local reboot="${4:-false}" + local dirname=$(dirname "$path") if [[ ! -d $dirname ]]; then mkdir -p "$dirname" @@ -74,6 +75,9 @@ install_file(){ if [[ ! -f $path ]] || [ "$(cat "$path")" != "$content" ]; then echo "$content" > "$path" chmod "$permissions" "$path" + if [[ $reboot = reboot ]]; then + REBOOT=true + fi export FILE_UPDATED=true else export FILE_UPDATED=false @@ -136,6 +140,7 @@ if [[ ! $DISABLE_SECCOMP_PROFILE ]]; then install_file "$path" "$content" "$permissions" fi + ############################################################################### # bootaction: apparmor-profiles ############################################################################### @@ -171,3 +176,48 @@ if [[ ! $DISABLE_APPARMOR_PROFILES ]]; then systemctl reload apparmor.service fi fi + + +############################################################################### +# bootaction: Additional kernel parameters and hugepages for OVS-DPDK +############################################################################### + +if [[ -n "$GENESIS_HOST_PROFILE" ]]; then + + manifests_lookup "$rendered_file" "drydock/HostProfile/v1" \ + "$GENESIS_HOST_PROFILE" \ + "['data']['platform']['kernel_params']" \ + "dict_keys" "true" + kernel_params=$RESULT + + grub_args=() + # NOTE: reverse sort is to ensure hugepagesz is before hugepages + for kp in $(echo $kernel_params | tr ' ' '\n' | sort -r); do + manifests_lookup "$rendered_file" "drydock/HostProfile/v1" \ + "$GENESIS_HOST_PROFILE" \ + "['data']['platform']['kernel_params']['$kp']" + if [[ $(tr '[:lower:]' '[:upper:]' <<< "$RESULT") == "TRUE" ]]; then + grub_args+=("$kp") + else + grub_args+=("$kp=$RESULT") + fi + done + + path="/etc/default/grub.d/50-curtin-settings.cfg" + content="GRUB_CMDLINE_LINUX_DEFAULT=\"${grub_args[*]}\"" + + install_file "$path" "$content" '644' reboot + + update-grub +fi + + +############################################################################### +# Reboot node +############################################################################### + +if [[ ! $DISABLE_REBOOT ]] && [[ $REBOOT = true ]]; then + echo Rebooting node $(hostname)... + reboot now & +fi + diff --git a/tools/deployment/seaworthy-virt/airship_gate/stages/genesis-setup.sh b/tools/deployment/seaworthy-virt/airship_gate/stages/genesis-setup.sh index 2d2033bc2..3b67a79f2 100755 --- a/tools/deployment/seaworthy-virt/airship_gate/stages/genesis-setup.sh +++ b/tools/deployment/seaworthy-virt/airship_gate/stages/genesis-setup.sh @@ -17,10 +17,14 @@ set -e source "${GATE_UTILS}" +GENESIS_HOST_PROFILE=${GENESIS_HOST_PROFILE:-} + # Copies script and virtmgr private key to genesis VM rsync_cmd "${REPO_ROOT}/tools/deployment/seaworthy-virt/airship_gate/lib/bootaction-runner.sh" "${GENESIS_NAME}:/root/airship/" rsync_cmd "${RENDERED_DEPOT}/rendered.yaml" "${GENESIS_NAME}:/root/airship/" set -o pipefail -ssh_cmd "${GENESIS_NAME}" /root/airship/bootaction-runner.sh /root/airship/rendered.yaml 2>&1 | tee -a "${LOG_FILE}" +ssh_cmd "${GENESIS_NAME}" /root/airship/bootaction-runner.sh /root/airship/rendered.yaml "${GENESIS_HOST_PROFILE}" |& tee -a "${LOG_FILE}" +ssh_wait "${GENESIS_NAME}" set +o pipefail +