Skip to content

Commit 167d574

Browse files
wilybraceandrewlecuyer
authored andcommitted
enforces required env variables and adds docs (#1047)
add-targeted-namespace.sh has a sinister failure case if PGO_INSTALLATION_NAME is unset in that the pgo-installation-name label does not get set correctly. This causes later failures in selectors built upon the assumption of that label's existence. This change updates add-targeted-namespace.sh to fail if its expected environment variables do not exist and updates the references to the script to warn about needing to ensure its definition.
1 parent 9dc479d commit 167d574

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

deploy/add-targeted-namespace.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414

1515

1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
17-
17+
# Enforce required environment variables
18+
test="${PGO_CMD:?Need to set PGO_CMD env variable}"
19+
test="${PGOROOT:?Need to set PGOROOT env variable}"
20+
test="${PGO_OPERATOR_NAMESPACE:?Need to set PGO_OPERATOR_NAMESPACE env variable}"
21+
test="${PGO_INSTALLATION_NAME:?Need to set PGO_INSTALLATION_NAME env variable}"
1822

1923
if [[ -z "$1" ]]; then
2024
echo "usage: add-targeted-namespace.sh mynewnamespace"
2125
exit
2226
fi
2327

24-
2528
# create the namespace if necessary
2629
$PGO_CMD get ns $1 > /dev/null
2730
if [ $? -eq 0 ]; then

hugo/content/Installation/install-with-ansible/prerequisites.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ can install:
4646

4747
However, if the user wishes to add a new watched namespace after installation, where the user would normally use pgo create namespace to add the new namespace, they should instead run the add-targeted-namespace.sh script or they may give themselves cluster-admin privileges instead of having to run setupnamespaces.sh script. Again, this is only required when running on a Kuberenetes distribution whose version is below 1.12. In Kubernetes version 1.12+ the pgo create namespace command works as expected.
4848

49+
add-targeted-namespace.sh requires the additional environment variable PGO_INSTALLATION_NAME set to the unique name given to the Operator's installation
50+
4951
{{% /notice %}}
5052

5153
## Obtaining Operator Ansible Role

hugo/content/Installation/operator-install.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ created as part of the default installation.
8383

8484
However, if the user wishes to add a new watched namespace after installation, where the user would normally use pgo create namespace to add the new namespace, they should instead run the add-targeted-namespace.sh script or they may give themselves cluster-admin privileges instead of having to run setupnamespaces.sh script. Again, this is only required when running on a Kuberenetes distribution whose version is below 1.12. In Kubernetes version 1.12+ the pgo create namespace command works as expected.
8585

86+
add-targeted-namespace.sh requires the additional environment variable PGO_INSTALLATION_NAME set to the unique name given to the Operator's installation
87+
8688
{{% /notice %}}
8789

8890
The *PGO_OPERATOR_NAMESPACE* environment variable is a comma separated list

0 commit comments

Comments
 (0)