Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Commit e0bb763

Browse files
committed
toolbox: gpu-operator/deploy_from_operatorhub.sh: add --install-plan=Automatic|Manual flag
1 parent e539e14 commit e0bb763

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

CHANGELOG.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
(Organized release by release)
44

5+
Features of version 0.1.3 (July 2021)
6+
-------------------------------------
7+
8+
New feature
9+
~~~~~~~~~~~
10+
11+
- gpu_operator_deploy_from_operatorhub: allow overriding subscription.spec.installPlanApproval `#219<https://github.com/openshift-psap/ci-artifacts/pull/219>`_
12+
13+
- ``./toolbox/gpu-operator/deploy_from_operatorhub.sh`` can receive a new flag ``--install-plan=Manual|Automatic`` (``Manual`` is the default) to override the Subscription install-plan approval setting when deploying from OperatorHub.
14+
15+
16+
Features of version 0.1.2 (July 2021)
17+
-------------------------------------
18+
19+
Bug fixes
20+
~~~~~~~~~
21+
22+
- Extra fix for the ``subscriptions`` conflict `#218 <https://github.com/openshift-psap/ci-artifacts/pull/218>`_
23+
24+
525
Features of version 0.1.1 (July 2021)
626
-------------------------------------
727

docs/toolbox/gpu_operator.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Deployment
99

1010
.. code-block:: shell
1111
12-
toolbox/gpu-operator/deploy_from_operatorhub.sh [<version>] [<channel>]
12+
toolbox/gpu-operator/deploy_from_operatorhub.sh [<version> [<channel>]] [--install-plan=Automatic|Manual]
1313
toolbox/gpu-operator/undeploy_from_operatorhub.sh
1414
1515
**Examples:**
@@ -26,6 +26,10 @@ Deployment
2626
2727
- Installs ``v1.6.2`` from the ``stable`` channel
2828
29+
- ``./toolbox/gpu-operator/deploy_from_operatorhub.sh --install-plan=Automatic``
30+
31+
- Forces the install plan approval to be set to ``Automatic``.
32+
2933
**Note about the GPU Operator channel:**
3034
3135
- Before ``v1.7.0``, the GPU Operator was using a unique channel name

toolbox/gpu-operator/deploy_from_operatorhub.sh

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
44
source ${THIS_DIR}/../_common.sh
55

66
DEPLOY_FROM_BUNDLE_FLAG="--from-bundle=master"
7+
INSTALL_PLAN="--install-plan="
78

89
usage() {
910
cat <<EOF
1011
Deploys the GPU Operator from OperatorHub / OLM
1112
1213
Usage:
1314
$0
14-
$0 <version> [<channel>]
1515
$0 $DEPLOY_FROM_BUNDLE_FLAG
16+
$0 <version> [<channel>] [--install-plan=Automatic|Manual]
1617
1718
Flags:
1819
-h, --help Display this help message
1920
2021
$DEPLOY_FROM_BUNDLE_FLAG Deploy the current master-branch version from the bundle image
2122
See roles/gpu_operator_deploy_from_operatorhub/defaults/main/bundle.yml for the image path.
23+
${INSTALL_PLAN}Automatic|Manual
24+
When deploying from OperatorHub, set the Subscription 'installPlanApproval' to Automatic or Manual (default).
2225
2326
<empty> Deploy the latest version available in OperatorHub
2427
@@ -44,19 +47,48 @@ if [[ "${1:-}" == "$DEPLOY_FROM_BUNDLE_FLAG" ]]; then
4447
usage
4548
exit 1
4649
fi
47-
elif [[ "$#" == 0 ]]; then
50+
51+
elif [[ "${1:-}" == "-"* && "${1:-}" != "$INSTALL_PLAN"* ]]; then
52+
echo "FATAL: unexpected parameters ... ($@)"
53+
usage
54+
exit 1
55+
elif [[ "$#" == 0 || "$#" == 1 && "$1" == "$INSTALL_PLAN"* ]]; then
4856
echo "Deploying the GPU Operator from OperatorHub using the latest version available."
49-
elif [[ "$#" == 1 || "$#" == 2 ]]; then
57+
if [[ "${1:-}" == "$INSTALL_PLAN"* ]]; then
58+
approval=$(echo $1 | cut -d= -f2)
59+
if [[ "$approval" != "Manual" && "$approval" != "Automatic" ]]; then
60+
echo "FATAL: invalid value for $1. Must be Manual or Automatic."
61+
usage
62+
exit 1
63+
fi
64+
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_installplan_approval=$approval"
65+
echo "Deploying the GPU Operator from OperatorHub using InstallPlan approval '$approval'."
66+
fi
67+
else
5068
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_version=$1"
5169
echo "Deploying the GPU Operator from OperatorHub using version '$1'."
52-
if [[ "$#" == 2 ]]; then
53-
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_channel=$2"
54-
echo "Deploying the GPU Operator from OperatorHub using channel '$2'."
70+
shift
71+
if [[ "$#" -ge 1 && "$1" != "-"* ]]; then
72+
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_channel=$1"
73+
echo "Deploying the GPU Operator from OperatorHub using channel '$1'."
74+
shift
75+
fi
76+
if [[ "$#" -ge 1 ]]; then
77+
if [[ "$1" != "$INSTALL_PLAN"* ]]; then
78+
echo "FATAL: unknown flag: $1"
79+
usage
80+
exit 1
81+
fi
82+
83+
approval=$(echo $1 | cut -d= -f2)
84+
if [[ "$approval" != "Manual" && "$approval" != "Automatic" ]]; then
85+
echo "FATAL: invalid value for $1. Must be Manual or Automatic."
86+
usage
87+
exit 1
88+
fi
89+
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_installplan_approval=$approval"
90+
echo "Deploying the GPU Operator from OperatorHub using InstallPlan approval '$approval'."
5591
fi
56-
else
57-
echo "FATAL: unexpected number of paramters (got '$@')"
58-
usage
59-
exit 1
6092
fi
6193

6294
exec ansible-playbook ${ANSIBLE_OPTS} playbooks/gpu_operator_deploy_from_operatorhub.yml

0 commit comments

Comments
 (0)