|
23 | 23 | from jinja2 import Environment, FileSystemLoader |
24 | 24 |
|
25 | 25 | from .ocp import getConsoleURL, waitForCRD, waitForDeployment, crdExists |
| 26 | +from .mas import waitForPVC, patchPendingPVC |
26 | 27 |
|
27 | 28 | logger = logging.getLogger(__name__) |
28 | 29 |
|
29 | 30 |
|
30 | | -def installOpenShiftPipelines(dynClient: DynamicClient) -> bool: |
| 31 | +# customStorageClassName is used when no default Storageclass is available on cluster, |
| 32 | +# openshift-pipelines creates PVC which looks for default. customStorageClassName is patched into PVC when default is unavailable. |
| 33 | +def installOpenShiftPipelines(dynClient: DynamicClient, customStorageClassName: str = None) -> bool: |
31 | 34 | """ |
32 | 35 | Install the OpenShift Pipelines Operator and wait for it to be ready to use |
33 | 36 | """ |
@@ -79,11 +82,30 @@ def installOpenShiftPipelines(dynClient: DynamicClient) -> bool: |
79 | 82 | foundReadyWebhook = waitForDeployment(dynClient, namespace="openshift-pipelines", deploymentName="tekton-pipelines-webhook") |
80 | 83 | if foundReadyWebhook: |
81 | 84 | logger.info("OpenShift Pipelines Webhook is installed and ready") |
82 | | - return True |
83 | 85 | else: |
84 | 86 | logger.error("OpenShift Pipelines Webhook is NOT installed and ready") |
85 | 87 | return False |
86 | 88 |
|
| 89 | + # Wait for the postgredb-tekton-results-postgres-0 PVC to be ready |
| 90 | + # this PVC doesn't come up when there's no default storage class is in the cluster, |
| 91 | + # this is causing the pvc to be in pending state and causing the tekton-results-postgres statefulSet in pending, |
| 92 | + # due to these resources not coming up, the MAS pre-install check in the pipeline times out checking the health of this statefulSet, |
| 93 | + # causing failure in pipeline. |
| 94 | + # Refer https://github.com/ibm-mas/cli/issues/1511 |
| 95 | + logger.debug("Waiting for postgredb-tekton-results-postgres-0 PVC to be ready") |
| 96 | + foundReadyPVC = waitForPVC(dynClient, namespace="openshift-pipelines", pvcName="postgredb-tekton-results-postgres-0") |
| 97 | + if foundReadyPVC: |
| 98 | + logger.info("OpenShift Pipelines postgres is installed and ready") |
| 99 | + return True |
| 100 | + else: |
| 101 | + patchedPVC = patchPendingPVC(dynClient, namespace="openshift-pipelines", pvcName="postgredb-tekton-results-postgres-0", storageClassName=customStorageClassName) |
| 102 | + if patchedPVC: |
| 103 | + logger.info("OpenShift Pipelines postgres is installed and ready") |
| 104 | + return True |
| 105 | + else: |
| 106 | + logger.error("OpenShift Pipelines postgres PVC is NOT ready") |
| 107 | + return False |
| 108 | + |
87 | 109 |
|
88 | 110 | def updateTektonDefinitions(namespace: str, yamlFile: str) -> None: |
89 | 111 | """ |
|
0 commit comments