-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #532 from itewk/feature/operators-installer-increm…
…ental-upgrades operators-installer: incremental upgrades
- Loading branch information
Showing
26 changed files
with
870 additions
and
209 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
.github/workflows/install-integration-tests-operators-installer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
# these integration tests need to be per operator since they don't do clean up | ||
# | ||
# 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 | ||
|
||
name: Install Integration Test - operators-installer | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/** | ||
- _test/charts-integration-tests/operators-installer/** | ||
- charts/operators-installer/** | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
install-integration-test: | ||
runs-on: ubuntu-latest | ||
env: | ||
# renovate: datasource=github-releases depName=helm/helm | ||
HELM_VERSION: v3.15.0 | ||
# renovate: datasource=github-tags depName=python/cpython | ||
PYTHON_VERSION: v3.12.3 | ||
# renovate: datasource=github-releases depName=kubernetes-sigs/kind | ||
KIND_VERSION: v0.23.0 | ||
# renovate: datasource=github-releases depName=operator-framework/operator-lifecycle-manager | ||
OLM_VERSION: v0.28.0 | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Helm 🧰 | ||
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
- name: Setup Python 🐍 | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Setup kind cluster 🧰 | ||
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 | ||
with: | ||
version: ${{ env.KIND_VERSION }} | ||
|
||
# for helm charts we are testing that require installing operators | ||
- name: Setup kind cluster - Install OLM 🧰 | ||
run: | | ||
curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/install.sh -o install.sh | ||
chmod +x install.sh | ||
./install.sh ${OLM_VERSION} | ||
# for helm charts we are testing that require ingress | ||
- name: Setup kind cluster - Install ingress controller 🧰 | ||
run: | | ||
helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts | ||
helm install haproxy-ingress haproxy-ingress/haproxy-ingress \ | ||
--create-namespace --namespace=ingress-controller \ | ||
--set controller.hostNetwork=true | ||
kubectl apply -f - <<EOF | ||
apiVersion: networking.k8s.io/v1 | ||
kind: IngressClass | ||
metadata: | ||
name: haproxy | ||
annotations: | ||
ingressclass.kubernetes.io/is-default-class: 'true' | ||
spec: | ||
controller: haproxy-ingress.github.io/controller | ||
EOF | ||
# 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 | ||
- name: Run integration tests 🧪 | ||
timeout-minutes: 30 | ||
run: | | ||
echo "##########################################################################################################" | ||
echo "# Install argo at old version #" | ||
echo "##########################################################################################################" | ||
helm upgrade --install operators-installer-integration-test charts/operators-installer \ | ||
--namespace operators-installer-integration-test \ | ||
--create-namespace \ | ||
--wait \ | ||
--values charts/operators-installer/_integration-tests/test-install-operator-0-automatic-intermediate-manual-upgrades-values.yaml \ | ||
--debug --timeout 10m0s | ||
echo "##########################################################################################################" | ||
echo "# Upgrade argo to newer version requiring many intermediate updates along the way #" | ||
echo "##########################################################################################################" | ||
helm upgrade --install operators-installer-integration-test charts/operators-installer \ | ||
--namespace operators-installer-integration-test \ | ||
--wait \ | ||
--values charts/operators-installer/_integration-tests/test-install-operator-1-automatic-intermediate-manual-upgrades-values.yaml \ | ||
--debug --timeout 30m0s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...egration-tests/test-install-operator-0-automatic-intermediate-manual-upgrades-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
approveManualInstallPlanViaHook: true | ||
|
||
installPlanApproverAndVerifyJobsImage: quay.io/openshift/origin-cli:4.15 | ||
|
||
operatorGroups: | ||
- name: argocd-operator | ||
createNamespace: true | ||
targetOwnNamespace: false | ||
otherTargetNamespaces: | ||
|
||
operators: | ||
- name: argocd-operator | ||
channel: alpha | ||
csv: argocd-operator.v0.8.0 | ||
installPlanApproval: Manual | ||
source: operatorhubio-catalog | ||
sourceNamespace: olm | ||
namespace: argocd-operator | ||
installPlanVerifierActiveDeadlineSeconds: 1200 | ||
automaticIntermediateManualUpgrades: true | ||
config: | ||
env: | ||
- name: DISABLE_DEFAULT_ARGOCD_INSTANCE | ||
value: "true" |
24 changes: 24 additions & 0 deletions
24
...egration-tests/test-install-operator-1-automatic-intermediate-manual-upgrades-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
approveManualInstallPlanViaHook: true | ||
|
||
installPlanApproverAndVerifyJobsImage: quay.io/openshift/origin-cli:4.15 | ||
|
||
operatorGroups: | ||
- name: argocd-operator | ||
createNamespace: true | ||
targetOwnNamespace: false | ||
otherTargetNamespaces: | ||
|
||
operators: | ||
- name: argocd-operator | ||
channel: alpha | ||
csv: argocd-operator.v0.10.1 | ||
installPlanApproval: Manual | ||
source: operatorhubio-catalog | ||
sourceNamespace: olm | ||
namespace: argocd-operator | ||
installPlanVerifierActiveDeadlineSeconds: 1200 | ||
automaticIntermediateManualUpgrades: true | ||
config: | ||
env: | ||
- name: DISABLE_DEFAULT_ARGOCD_INSTANCE | ||
value: "true" |
62 changes: 62 additions & 0 deletions
62
charts/operators-installer/_scripts/installplan-approver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/python | ||
|
||
import os | ||
import sys | ||
import installplan_utils | ||
|
||
NAMESPACE_NAME = os.getenv("NAMESPACE") or installplan_utils.error_and_exit( | ||
"env is missing expected value: NAMESPACE", 2 | ||
) | ||
SUBSCRIPTION_NAME = os.getenv("SUBSCRIPTION") or installplan_utils.error_and_exit( | ||
"env is missing expected value: SUBSCRIPTION", 2 | ||
) | ||
CSV = os.getenv("CSV") or installplan_utils.error_and_exit( | ||
"env is missing expected value: CSV", 2 | ||
) | ||
|
||
print() | ||
print("********************************************************************") | ||
print("* START InstallPlan approver") | ||
print(f"*\t- NAMESPACE_NAME: {NAMESPACE_NAME}") | ||
print(f"*\t- SUBSCRIPTION_NAME: {SUBSCRIPTION_NAME}") | ||
print(f"*\t- CSV: {CSV}") | ||
print("********************************************************************") | ||
|
||
# find the subscription uid | ||
print() | ||
print(f"Get Subscription ({SUBSCRIPTION_NAME}) UID") | ||
subscription_uid = installplan_utils.get_subscription_uid(SUBSCRIPTION_NAME) | ||
print(f"\t- Subscription ({SUBSCRIPTION_NAME}) UID: {subscription_uid}") | ||
|
||
# if found subscription uid find InstallPlan for given CSV with owner of the given subscription | ||
# else error | ||
if subscription_uid: | ||
# find the InstallPlan that has expected owner subscription id and expected target CSV name | ||
# NOTE: if more then one InstallPlan matches, choose the first one | ||
print( | ||
f"Find InstallPlan in Namespace ({NAMESPACE_NAME}) for CSV ({CSV}) with Subscription (${subscription_uid}) owner" | ||
) | ||
target_installplan = installplan_utils.get_installplan( | ||
NAMESPACE_NAME, CSV, subscription_uid | ||
) | ||
|
||
# if found target InstallPlan, approve it, and success exit | ||
# else fail | ||
if target_installplan: | ||
print(f"\t- Found InstallPlan: {target_installplan.model.metadata.name}") | ||
installplan_utils.approve_installplan(target_installplan) | ||
sys.exit(0) | ||
else: | ||
print() | ||
print( | ||
f"ERROR: Could not find next InstallPlan to reach CSV ${CSV}) with Subscription ({SUBSCRIPTION_NAME}) ({subscription_uid}) owner." | ||
+ "\nThis can happen if InstallPlan isn't created yet or no valid upgrade path between current CSV and target CSV." | ||
+ "\nTry again." | ||
) | ||
sys.exit(1) | ||
else: | ||
print() | ||
print( | ||
f"ERROR: Failed to get Subscription ({SUBSCRIPTION_NAME}) UID. This really shouldn't happen." | ||
) | ||
sys.exit(1) |
Oops, something went wrong.