Skip to content

Commit 20a7dbf

Browse files
committed
WIP - operators-installer - manual incremental upgrades
* adds `automaticIntermediateManualUpgrades` option to allow the approver to automatically approve ever required update between currently installed CSV and target CSV
1 parent 835bc91 commit 20a7dbf

26 files changed

+724
-171
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
# these integration tests need to be per operator since they don't do clean up
3+
#
4+
# NOTE: can't use chart-testing because `ct` does not allow for a fixed release so you can't run two different tests that affect the same resources
5+
6+
name: Install Integration Test - operators-installer
7+
8+
on:
9+
pull_request:
10+
paths:
11+
- .github/**
12+
- _test/charts-integration-tests/operators-installer/**
13+
- charts/operators-installer/**
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
install-integration-test:
24+
runs-on: ubuntu-latest
25+
env:
26+
# renovate: datasource=github-releases depName=helm/helm
27+
HELM_VERSION: v3.15.0
28+
# renovate: datasource=github-tags depName=python/cpython
29+
PYTHON_VERSION: v3.12.3
30+
# renovate: datasource=github-releases depName=kubernetes-sigs/kind
31+
KIND_VERSION: v0.23.0
32+
# renovate: datasource=github-releases depName=operator-framework/operator-lifecycle-manager
33+
OLM_VERSION: v0.28.0
34+
steps:
35+
- name: Checkout 🛎️
36+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Setup Helm 🧰
41+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4
42+
with:
43+
version: ${{ env.HELM_VERSION }}
44+
45+
- name: Setup Python 🐍
46+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
47+
with:
48+
python-version: ${{ env.PYTHON_VERSION }}
49+
50+
- name: Setup kind cluster 🧰
51+
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
52+
with:
53+
version: ${{ env.KIND_VERSION }}
54+
55+
# for helm charts we are testing that require installing operators
56+
- name: Setup kind cluster - Install OLM 🧰
57+
run: |
58+
curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/install.sh -o install.sh
59+
chmod +x install.sh
60+
./install.sh ${OLM_VERSION}
61+
62+
# for helm charts we are testing that require ingress
63+
- name: Setup kind cluster - Install ingress controller 🧰
64+
run: |
65+
helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts
66+
helm install haproxy-ingress haproxy-ingress/haproxy-ingress \
67+
--create-namespace --namespace=ingress-controller \
68+
--set controller.hostNetwork=true
69+
kubectl apply -f - <<EOF
70+
apiVersion: networking.k8s.io/v1
71+
kind: IngressClass
72+
metadata:
73+
name: haproxy
74+
annotations:
75+
ingressclass.kubernetes.io/is-default-class: 'true'
76+
spec:
77+
controller: haproxy-ingress.github.io/controller
78+
EOF
79+
80+
# NOTE: can't use chart-testing because `ct` does not allow for a fixed release so you can't run two different tests that affect the same resources
81+
- name: Run integration tests 🧪
82+
timeout-minutes: 30
83+
run: |
84+
echo "#####################################"
85+
echo "# Install argo at old version #"
86+
echo "#####################################"
87+
helm upgrade --install operators-installer-integration-test charts/operators-installer \
88+
--namespace operators-installer-integration-test \
89+
--create-namespace \
90+
--wait \
91+
--values charts/operators-installer/_integration-tests/test-install-operator-0-automatic-intermediate-manual-upgrades-values.yaml \
92+
--debug --timeout 10m0s
93+
94+
echo "#####################################"
95+
echo "# Install argo at newer version #"
96+
echo "#####################################"
97+
helm upgrade --install operators-installer-integration-test charts/operators-installer \
98+
--namespace operators-installer-integration-test \
99+
--wait \
100+
--values charts/operators-installer/_integration-tests/test-install-operator-1-automatic-intermediate-manual-upgrades-values.yaml \
101+
--debug --timeout 30m0s

.github/workflows/install-test.yaml renamed to .github/workflows/install-unit-test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Install Test
2+
name: Install Unit Tests
33

44
on:
55
pull_request:
@@ -93,7 +93,7 @@ jobs:
9393
kubectl create namespace openshift-operators
9494
if: steps.changed-charts.outputs.changed == 'true'
9595

96-
- name: Run Chart install tests 🧪
96+
- name: Run unit tests 🧪
9797
timeout-minutes: 30
9898
run: |
9999
ct install --target-branch main --debug --config _test/ct-config.yaml

charts/operators-installer/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type: application
1616
# This is the chart version. This version number should be incremented each time you make changes
1717
# to the chart and its templates, including the app version.
1818
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19-
version: 2.4.3
19+
version: 3.0.0
2020

2121
home: https://github.com/redhat-cop/helm-charts
2222

charts/operators-installer/README.md

+28-5
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,48 @@ For all of the Subscription parameters see
2828
| operators[].sourceNamespace | | Yes | [Subscription](https://docs.openshift.com/container-platform/4.14/rest_api/operatorhub_apis/subscription-operators-coreos-com-v1alpha1.html#spec) sourceNamespace.
2929
| operators[].config | | No | [Subscription](https://docs.openshift.com/container-platform/4.14/rest_api/operatorhub_apis/subscription-operators-coreos-com-v1alpha1.html#spec-config) config.
3030
| operators[].csv | | Yes | The CSV to install.
31-
| operators[].installPlanApproverRetries | `10 | No | Number of times to try to approve the InstallPlan. This may need to be increased for unpredictable reasons about some clusters taking longer to create InstallPlans.
32-
| operators[].installPlanApproverActiveDeadlineSeconds | `120` | No | Total amount of time that can be spent waiting for InstallPlan to be approved. This may need to be increased for unpredictable reasons about some clusters taking longer to create InstallPlans.
31+
| operators[].installPlanApproverRetries | `10` | No | Number of times to try to approve the InstallPlan. This may need to be increased for unpredictable reasons about some clusters taking longer to create InstallPlans.
32+
| operators[].installPlanApproverActiveDeadlineSeconds | None | No | Total amount of time that can be spent waiting for InstallPlan to be approved. If having issues with InstallPlans never finishing to install and thus approval job getting infinity stuck, set this to some reasonable number. But, keep in mind if `automaticIntermediateManualUpgrades` is `true` then it can take a while to increment through a bunch of intermediate installs on the way to the specified `csv` if an old `csv` is already installed.
3333
| operators[].installPlanVerifierRetries | `10` | No | Number of times to check if the InstallPlan has actually been installed. This may need to increase of an operator takes a long time to install.
34-
| operators[].installPlanVerifierActiveDeadlineSeconds | `120` | No | Total amount of time that can be spent waiting for InstallPlan to finish installing. This may need to increase of an operator takes a long time to install.
35-
| operators[].namespace | `.Release.Namespace` | No | Specify the namespace to install the operator into, which allows different operators to be installed into different namespaces from the same chart. If
34+
| operators[].installPlanVerifierActiveDeadlineSeconds | None | No | Total amount of time that can be spent waiting for InstallPlan to finish installing. This may need to increase of an operator takes a long time to install. If having issues with InstallPlans never finishing to install and thus verify job getting infinity stuck, set this to some reasonable number. But, keep in mind if `automaticIntermediateManualUpgrades` is `true` then it can take a while to increment through a bunch of intermediate installs on the way to the specified `csv` if an old `csv` is already installed.
35+
| operators[].namespace | `.Release.Namespace` | No | Specify the namespace to install the operator into, which allows different operators to be installed into different namespaces from the same chart.
36+
| operators[].automaticIntermediateManualUpgrades | `false` | | If `true` and `installPlanApproval` is `Manual` and there are required intermediate upgrades between the currently installed `csv` and the specified `csv`, automatically inclemently install those intermediate versions until reaching the specified `csv`. If `false` and there are required intermediate upgrades then chart will fail.
37+
| operators[].automaticIntermediateManualUpgradesIncrementalInstallBackoffLimit | `10` | No | When `automaticIntermediateManualUpgrades` is `true`, the number of retries for installing and then then verifying each incremental install
38+
| operators[].automaticIntermediateManualUpgradesIncrementalInstallDelayIncrement | `5` | No | When `automaticIntermediateManualUpgrades` is `true`, the delay increment to scale by attempts to wait between each retry of installing or verifying each incremental install
3639
| operatorGroups | `[]` | No | Optional list of configuration for OperatorGroups. If this is not supplied then it is assumed OperatorGroups are already in place in the selected `operators[].namespace`s.
3740
| operatorGroups[].name | `.Release.Namespace` | No | Name of the OperatorGroup & Namespace the OperatorGroup will be placed in.
3841
| operatorGroups[].createNamespace | `false` | No | If `true` create the Namespace of the same name of the OperatorGroup. If `false` assumed the Namespace is already in place.
3942
| operatorGroups[].targetOwnNamespace | `false` | No | If `true` add the OperatorGroup's Namespace as a `targetNamespaces`. If `true` then OperatorGroup will only work for Operators using `OwnNamespace` or `MultiNamespace` `installModes`. If blank and no `otherTargetNamespaces` specified then OperatorGroup will be configured to allow for operators using `installModes` `AllNamespaces`.
4043
| operatorGroups[].otherTargetNamespaces | `[]` | No | List of additional Namespaces to target. If specified OperatorGroup will only work for operators using `SingleNamespace` or `MultiNamespace` `installModes` depending on value of `targetOwnNamespace`.
4144
| installPlanApproverAndVerifyJobsImage | `registry.redhat.io/openshift4/ose-cli:v4.10` | Yes | Image to use for the InstallPlan Approver and Verify Jobs
4245
| approveManualInstallPlanViaHook | `true` | No | `true` to create (and clean up) manual InstallPlan approval resources as part of post-install,post-upgrade helm hook<br>`false` to create manual InstallPlan approval resources as part of normal install<br><br>The hook method is nice to not have lingering resources needed for the manual InstallPlan approval but has the downside that no CustomResources using CustomResourceDefinitions installed by the operator can be used in the same chart because the operator InstallPlan wont be approved, and therefor the operator wont be installed, until the post-install,post-upgrade phase which means you will never get to that phase because your CustomResources wont be able to apply because the Operator isn't installed.<br><br>This is is ultimately a trade off between cleaning up these resources or being able to install and configure the operator in the same helm chart that has a dependency on this helm chart.
46+
| installRequiredPythonLibraries | `true` | No | If `true`, install the required Python libraries (openshift-client, semver==2.13.0) dynamically from the given `pythonIndexURL` and `pythonExtraIndexURL` into the `installPlanApproverAndVerifyJobsImage` at run time
47+
| pythonIndexURL | https://pypi.org/simple/ | No | If `installRequiredPythonLibraries` is `true` then use this python index to pull required libraries
48+
| pythonExtraIndexURL | https://pypi.org/simple/ | No | If `installRequiredPythonLibraries` is `true` then use this python extra index to pull required library dependencies
4349
| commonLabels | `{}` | No | Common labels to add to all chart created resources. Implements the same idea from Kustomize for this chart.
4450
| global.commonLabels | `{}` | No | Common labels coming from global values to add to all chart created resources. Implements the same idea from Kustomize for this chart.
4551

4652
## Warnings
4753

48-
### Can not install / upgrade different operators in same namespace independently
54+
### Disconnected Use
55+
If wanting use this chart in a disconnected environment you need to either:
56+
57+
#### Option 1: local python index
58+
Set the `pythonIndexURL` and `pythonExtraIndexURL` values to a local disconnected python index that minimally includes (and their dependencies):
59+
* openshift-client
60+
* semver==2.13.0
61+
62+
#### Option 2: custom `installPlanApproverAndVerifyJobsImage` with required dependencies
63+
Build a custom container image with:
64+
* binary - `oc`
65+
* python lib - `openshift-client`
66+
* python lib - `semver==2.13.0`
4967

68+
Suggestion is to build such an image on top of the latest `registry.redhat.io/openshift4/ose-cli` image
69+
70+
Then provide that custom image to `installPlanApproverAndVerifyJobsImage` and set `installRequiredPythonLibraries` to false.
71+
72+
### Can not install / upgrade different operators in same namespace independently
5073
As documented in [How can Operators be updated independently from each other?](https://access.redhat.com/solutions/6389681) when more then one operator install or update is pending in the same namespace the Operator Lifecycle Manager (OLM) will combine those installs/updates into a single InstallPlan and there is no way to separate them. Therefor if you use this helm chart in namespace ZZZ to install operator A at v1.0 and it has a pending update to v1.1 and then update the configuration to also install operator B at v42.0 in namespace ZZZ the ZZZ v42.0 InstallPlan and the A v1.1 InstallPlan will get merged (by OLM) and this helm chart will then approve that InstallPlan as it will match on the ZZZ v42.0 pending install, which will incidentally install the A v1.1 update.
5174

5275
There is no way for this or any helm chart, automation, or even click ops to prevent this, as documented in [How can Operators be updated independently from each other?](https://access.redhat.com/solutions/6389681) this is currently considered "a feature of OLM".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
approveManualInstallPlanViaHook: true
2+
3+
installPlanApproverAndVerifyJobsImage: quay.io/openshift/origin-cli:4.15
4+
5+
operatorGroups:
6+
- name: argocd-operator
7+
createNamespace: true
8+
targetOwnNamespace: false
9+
otherTargetNamespaces:
10+
11+
operators:
12+
- name: argocd-operator
13+
channel: alpha
14+
csv: argocd-operator.v0.8.0
15+
installPlanApproval: Manual
16+
source: operatorhubio-catalog
17+
sourceNamespace: olm
18+
namespace: argocd-operator
19+
installPlanVerifierActiveDeadlineSeconds: 1200
20+
automaticIntermediateManualUpgrades: true
21+
config:
22+
env:
23+
- name: DISABLE_DEFAULT_ARGOCD_INSTANCE
24+
value: "true"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
approveManualInstallPlanViaHook: true
2+
3+
installPlanApproverAndVerifyJobsImage: quay.io/openshift/origin-cli:4.15
4+
5+
operatorGroups:
6+
- name: argocd-operator
7+
createNamespace: true
8+
targetOwnNamespace: false
9+
otherTargetNamespaces:
10+
11+
operators:
12+
- name: argocd-operator
13+
channel: alpha
14+
csv: argocd-operator.v0.10.1
15+
installPlanApproval: Manual
16+
source: operatorhubio-catalog
17+
sourceNamespace: olm
18+
namespace: argocd-operator
19+
installPlanVerifierActiveDeadlineSeconds: 1200
20+
automaticIntermediateManualUpgrades: true
21+
config:
22+
env:
23+
- name: DISABLE_DEFAULT_ARGOCD_INSTANCE
24+
value: "true"

0 commit comments

Comments
 (0)