From d973322529548423a12a17e1e776455b48a78802 Mon Sep 17 00:00:00 2001 From: Adam Harwell Date: Wed, 2 Oct 2019 10:53:37 -0700 Subject: [PATCH] Add diskimage-create arg for Octavia Git branch Use `-g` to select the current Git branch to use for the amphora build. This has historically been confusing for people, and this should make it a little easier. Change-Id: Iab01faaa17507c7bea399db7ee8f27f88d8de183 --- diskimage-create/README.rst | 72 ++++++++++++++++++- diskimage-create/diskimage-create.sh | 18 ++++- ...ge-create-git-branch-9c44e7e3fa70a985.yaml | 5 ++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/diskimage-create-git-branch-9c44e7e3fa70a985.yaml diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index fcd2b93c57..292418efbc 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -104,6 +104,7 @@ Command syntax: [-d **bionic**/**8** | ] [-e] [-f] + [-g **repository branch** | stable/train | stable/stein | ... ] [-h] [-i **ubuntu-minimal** | fedora | centos-minimal | rhel ] [-k ] @@ -124,6 +125,7 @@ Command syntax: '-d' distribution release id (default on ubuntu: bionic) '-e' enable complete mandatory access control systems when available (default: permissive) '-f' disable tmpfs for build + '-g' build the image for a specific OpenStack Git branch (default: current repository branch) '-h' display help message '-i' is the base OS (default: ubuntu-minimal) '-k' is the kernel meta package name, currently only for ubuntu-minimal base OS (default: linux-image-virtual) @@ -139,6 +141,66 @@ Command syntax: '-x' enable tracing for diskimage-builder +Building Images for Alternate Branches +====================================== + +By default, the diskimage-create.sh script will build an amphora image using +the Octavia Git branch of the repository. If you need an image for a specific +branch, such as "stable/train", you need to specify the "-g" option with the +branch name. An example for "stable/train" would be: + +.. code-block:: bash + + diskimage-create.sh -g stable/train + +Advanced Git Branch/Reference Based Images +------------------------------------------ + +If you need to build an image from a local repository or with a specific Git +reference or branch, you will need to set some environment variables for +diskimage-builder. + +.. note:: + + These advanced settings will override the "-g" diskimage-create.sh setting. + +Building From a Local Octavia Repository +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set the DIB_REPOLOCATION_amphora_agent variable to the location of the Git +repository containing the amphora agent: + +.. code-block:: bash + + export DIB_REPOLOCATION_amphora_agent=/opt/stack/octavia + +Building With a Specific Git Reference +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set the DIB_REPOREF_amphora_agent variable to point to the Git branch or +reference of the amphora agent: + +.. code-block:: bash + + export DIB_REPOREF_amphora_agent=refs/changes/40/674140/7 + +See the `Environment Variables`_ section below for additional information and +examples. + +Amphora Agent Upper Constraints +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You may also need to specify which version of the OpenStack +upper-constraints.txt file will be used to build the image. For example, to +specify the "stable/train" upper constraints Git branch, set the following +environment variable: + +.. code-block:: bash + + export DIB_REPOLOCATION_upper_constraints=https://opendev.org/openstack/requirements/raw/branch/stable/train/upper-constraints.txt + +See `Dependency Management for OpenStack Projects `_ for more information. + Environment Variables ===================== These are optional environment variables that can be set to override the script @@ -150,12 +212,18 @@ DIB_REPOLOCATION_amphora_agent - Example: /tmp/octavia DIB_REPOREF_amphora_agent - - The git reference to checkout for the amphora-agent code inside the + - The Git reference to checkout for the amphora-agent code inside the image. - - Default: master + - Default: The current branch - Example: stable/stein - Example: refs/changes/40/674140/7 +DIB_REPOLOCATION_upper_constraints + - Location of the upper-constraints.txt file used for the image. + - Default: The upper-constraints.txt for the current branch + - Example: https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt + - Example: https://opendev.org/openstack/requirements/raw/branch/stable/train/upper-constraints.txt + CLOUD_INIT_DATASOURCES - Comma separated list of cloud-int datasources - Default: ConfigDrive diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh index 74561ee6a0..6f0eeb807c 100755 --- a/diskimage-create/diskimage-create.sh +++ b/diskimage-create/diskimage-create.sh @@ -26,6 +26,7 @@ usage() { echo " [-d **bionic**/**8** | ]" echo " [-e]" echo " [-f]" + echo " [-g **repository branch** | stable/train | stable/stein | ... ]" echo " [-h]" echo " [-i **ubuntu-minimal** | fedora | centos-minimal | rhel ]" echo " [-k ]" @@ -46,6 +47,7 @@ usage() { echo " '-d' distribution release id (default on ubuntu: bionic)" echo " '-e' enable complete mandatory access control systems when available (default: permissive)" echo " '-f' disable tmpfs for build" + echo " '-g' build the image for a specific OpenStack Git branch (default: current repository branch)" echo " '-h' display this help message" echo " '-i' is the base OS (default: ubuntu-minimal)" echo " '-k' is the kernel meta package name, currently only for ubuntu-minimal base OS (default: linux-image-virtual)" @@ -89,7 +91,7 @@ dib_enable_tracing= AMP_LOGFILE="" -while getopts "a:b:c:d:efhi:k:l:no:pt:r:s:vw:x" opt; do +while getopts "a:b:c:d:efg:hi:k:l:no:pt:r:s:vw:x" opt; do case $opt in a) AMP_ARCH=$OPTARG @@ -121,6 +123,20 @@ while getopts "a:b:c:d:efhi:k:l:no:pt:r:s:vw:x" opt; do f) AMP_DISABLE_TMP_FS='--no-tmpfs' ;; + g) + if [ -z "$DIB_REPOREF_amphora_agent" ]; then + echo "Building image with amphora agent from $OPTARG." + export DIB_REPOREF_amphora_agent=$OPTARG + else + echo "Environment variable DIB_REPOREF_amphora_agent is set. Building the image with amphora agent $DIB_REPOREF_amphora_agent." + fi + if [ -z "$DIB_REPOLOCATION_upper_constraints" ]; then + echo "Using upper constraints from https://opendev.org/openstack/requirements/raw/branch/$OPTARG/upper-constraints.txt." + export DIB_REPOLOCATION_upper_constraints="https://opendev.org/openstack/requirements/raw/branch/$OPTARG/upper-constraints.txt" + else + echo "Environment variable DIB_REPOLOCATION_upper_constraints is set. Building the image with upper-constraints.txt from $DIB_REPOLOCATION_upper_constraints." + fi + ;; h) usage ;; diff --git a/releasenotes/notes/diskimage-create-git-branch-9c44e7e3fa70a985.yaml b/releasenotes/notes/diskimage-create-git-branch-9c44e7e3fa70a985.yaml new file mode 100644 index 0000000000..8dcfe74194 --- /dev/null +++ b/releasenotes/notes/diskimage-create-git-branch-9c44e7e3fa70a985.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added an option to the diskimage-create.sh script to specify the Octavia + Git branch to build the image from.