opendevstack / ods-jenkins-shared-library

Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
72 stars 57 forks source link

Slow helm component deployments sometimes fail at the finalize step #1031

Closed angelmp01 closed 1 year ago

angelmp01 commented 1 year ago

Describe the bug When using a single postgres component with multiple images being built with odsComponentStageBuildOpenShiftImage() and deployed via Helm, the pipeline fails due a NPE within the finalize Step.

To Reproduce Steps to reproduce the behavior:

  1. Create a postgres component from the postgres quickstarter that use helm to deploy.
  2. Deploy the comoponent to dev.

Expected behavior The postgres is deployed into dev correctly with two pods.

Log Output (ensure to remove any confidential information like tokens, project names, etc. See json below:

{
    "id": "backend-first",
    "type": "ods-service",
    "data": {
        "openshift": {
            "builds": {
                "backend-first": {
                    "buildId": "backend-first-1",
                    "image": "image-registry.openshift-image-registry.svc:5000/e2ets-cd/backend-first@sha256:04b1a78007e852a2398f1331bf376a205ffa561c4521ebbe9c419c7a3907ed77"
                }
            },
            "deployments": {
                "backend-first-surus1-deploymentMean": {
                    "type": "helm",
                    "selector": "app=backend-first",
                    "chartDir": "chart",
                    "helmReleaseName": "backend-first",
                    "helmEnvBasedValuesFiles": [

                    ],
                    "helmValuesFiles": [
                        "values.yaml"
                    ],
                    "helmValues": {
                        "registry": "image-registry.openshift-image-registry.svc:5000",
                        "componentId": "backend-first"
                    },
                    "helmDefaultFlags": [
                        "--install",
                        "--atomic"
                    ],
                    "helmAdditionalFlags": [

                    ]
                },
                "backend-first-surus1": null,
                "backend-first-surus2-deploymentMean": {
                    "type": "helm",
                    "selector": "app=backend-first",
                    "chartDir": "chart",
                    "helmReleaseName": "backend-first",
                    "helmEnvBasedValuesFiles": [

                    ],
                    "helmValuesFiles": [
                        "values.yaml"
                    ],
                    "helmValues": {
                        "registry": "image-registry.openshift-image-registry.svc:5000",
                        "componentId": "backend-first"
                    },
                    "helmDefaultFlags": [
                        "--install",
                        "--atomic"
                    ],
                    "helmAdditionalFlags": [

                    ]
                },
                "backend-first-surus2": null
            },
            "testResultsFolder": "build/test-results/test",
            "testResults": 0,
            "CREATED_BY_BUILD": "CHG000001/1"
        }
    ...

Affected version (please complete the following information):

Additional context The bug seems that is not in the validation method in the Finalize step. The buggy code is in the HelmDeployStrategy, building the json with the pod data retrieved from oc