openshiftio / openshift.io

Red Hat OpenShift.io is an end-to-end development environment for planning, building and deploying modern applications.
https://openshift.io
97 stars 66 forks source link

Deployments API might be confused by . and - replacements in OpenShift #3819

Closed jiekang closed 6 years ago

jiekang commented 6 years ago

If you create an application from a GitHub repository with a '.' in the name, it is deployed in OpenShift with '-' replacing the '.'. E.g. abc.123 is abc-123 in OpenShift.

The deployments API does not seem to be able to find the deployment for the application. The response from https://api.openshift.io/api/deployments/spaces/<spaceId>looks like:

{
    "data": {
        "attributes": {
            "applications": [{
                "attributes": {
                    "deployments": [],
                    "name": "abc.123"
                },
                "id": "abc.123",
                "type": "application"
            }],
            "name": "1234"
        },
        "id": "de778322-5886-4e56-987b-d9de3cd9997f",
        "type": "space"
    }
}

When I look at the OpenShift console, the application name is abc-123.

application

jiekang commented 6 years ago

@ebaron does this look like it could be a problem in the Deployments API?

ebaron commented 6 years ago

@jiekang I forked your abc.123 repo and was not able to reproduce the issue. It works fine for me. Build config is named abc.123:

$ oc get bc
NAME         TYPE              FROM         LATEST
abc.123      JenkinsPipeline   Git@master   2

Deployment config is named abc-123:

$ oc -n ebaron1-run get dc
NAME         REVISION   DESIRED   CURRENT   TRIGGERED BY
abc-123      1          1         1         config,image(abc-123:1.0.1)

screenshot from 2018-06-18 16-36-15

Could you check again, or let me know if I'm missing something?

jiekang commented 6 years ago
$ oc get bc
NAME        TYPE              FROM         LATEST
abc.123     JenkinsPipeline   Git@master   2
arst-1234   JenkinsPipeline   Git@master   1
$ oc -n jkang-stage get dc
NAME        REVISION   DESIRED   CURRENT   TRIGGERED BY
abc-123     1          0         0         config,image(abc-123:1.0.1)
arst-1234   1          0         0         config,image(arst-1234:1.0.1)

Interesting. My space name is 1234 but it should be using uuid's anyways.

The deployments array is definitely empty in the response from https://api.openshift.io/api/deployments/spaces/<spaceId>

When I examine the labels for dc abc-123 it seems to be correct too. I'm not sure why this is happening for me then.

ebaron commented 6 years ago

@jiekang Could you attach the builds for this application? It might give us some clues.

oc get build -l 'openshift.io/build-config.name=abc.123' -o json
jiekang commented 6 years ago

@ebaron

$ oc get build -l 'openshift.io/build-config.name=abc.123' -o json
{
    "apiVersion": "v1",
    "items": [
        {
            "apiVersion": "build.openshift.io/v1",
            "kind": "Build",
            "metadata": {
                "annotations": {
                    "environment.services.fabric8.io/jkang-stage": "---\nenvironmentName: \"Stage\"\nserviceUrls:\n  abc-123: \"http://abc-123-jkang-stage.8a09.starter-us-east-2.openshiftapps.com\"\ndeploymentVersions:\n  abc-123: \"1.0.1\"\n",
                    "fabric8.io/bayesian.analysisUrl": "https://recommender.api.openshift.io/api/v1/stack-analyses/9cde248cc8b841b898aaf09ee243ed3e",
                    "fabric8.io/jenkins.testReportUrl": "nulltestReport",
                    "openshift.io/build-config.name": "abc.123",
                    "openshift.io/build.number": "1",
                    "openshift.io/jenkins-build-uri": "https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/",
                    "openshift.io/jenkins-log-url": "https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/consoleText",
                    "openshift.io/jenkins-namespace": "jkang-jenkins",
                    "openshift.io/jenkins-pending-input-actions-json": "[{\"id\":\"Proceed\",\"proceedText\":\"Proceed\",\"message\":\"\\nWould you like to promote version 1.0.1 to the next environment?\\n\",\"inputs\":[],\"proceedUrl\":\"//job/jiekang/job/abc.123/job/master/1/wfapi/inputSubmit?inputId=Proceed\",\"abortUrl\":\"//job/jiekang/job/abc.123/job/master/1/input/Proceed/abort\",\"redirectApprovalUrl\":\"//job/jiekang/job/abc.123/job/master/1/input/\"}]",
                    "openshift.io/jenkins-status-json": "{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/wfapi/describe\"},\"changesets\":null,\"pendingInputActions\":null,\"nextPendingInputAction\":null,\"artifacts\":null},\"id\":\"1\",\"name\":\"#1\",\"status\":\"ABORTED\",\"startTimeMillis\":1529336051958,\"endTimeMillis\":1529352021750,\"durationMillis\":15969792,\"queueDurationMillis\":69,\"pauseDurationMillis\":0,\"stages\":[{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/20/wfapi/describe\"},\"log\":null},\"id\":\"20\",\"name\":\"Build Release\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336154794,\"durationMillis\":168223,\"pauseDurationMillis\":0,\"stageFlowNodes\":[{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/21/wfapi/describe\"},\"log\":null},\"id\":\"21\",\"name\":\"Shell Script\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336160709,\"durationMillis\":3899,\"pauseDurationMillis\":0,\"parentNodes\":[\"20\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/22/wfapi/describe\"},\"log\":null},\"id\":\"22\",\"name\":\"Read a maven project file.\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"pom.xml\",\"startTimeMillis\":1529336164608,\"durationMillis\":1080,\"pauseDurationMillis\":0,\"parentNodes\":[\"21\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/23/wfapi/describe\"},\"log\":null},\"id\":\"23\",\"name\":\"Shell Script\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -U -DnewVersion=1.0.1\",\"startTimeMillis\":1529336165688,\"durationMillis\":26838,\"pauseDurationMillis\":0,\"parentNodes\":[\"22\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/24/wfapi/describe\"},\"log\":null},\"id\":\"24\",\"name\":\"Shell Script\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"mvn clean -B -e -U deploy -Dmaven.test.skip=false -P openshift\",\"startTimeMillis\":1529336192526,\"durationMillis\":106893,\"pauseDurationMillis\":0,\"parentNodes\":[\"23\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/25/wfapi/describe\"},\"log\":null},\"id\":\"25\",\"name\":\"Find files in the workspace\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"**/surefire-reports/*.xml\",\"startTimeMillis\":1529336299419,\"durationMillis\":704,\"pauseDurationMillis\":0,\"parentNodes\":[\"24\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/26/wfapi/describe\"},\"log\":null},\"id\":\"26\",\"name\":\"Publish JUnit test result report\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336300123,\"durationMillis\":2161,\"pauseDurationMillis\":0,\"parentNodes\":[\"25\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/27/wfapi/describe\"},\"log\":null},\"id\":\"27\",\"name\":\"Find files in the workspace\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"**/failsafe-reports/*.xml\",\"startTimeMillis\":1529336302284,\"durationMillis\":466,\"pauseDurationMillis\":0,\"parentNodes\":[\"26\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/28/wfapi/describe\"},\"log\":null},\"id\":\"28\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Looking for matching Build abc.123-1\",\"startTimeMillis\":1529336302750,\"durationMillis\":778,\"pauseDurationMillis\":0,\"parentNodes\":[\"27\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/29/wfapi/describe\"},\"log\":null},\"id\":\"29\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Looking for matching Build abc.123-1\",\"startTimeMillis\":1529336303528,\"durationMillis\":100,\"pauseDurationMillis\":0,\"parentNodes\":[\"28\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/30/wfapi/describe\"},\"log\":null},\"id\":\"30\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Adding annotation 'fabric8.io/jenkins.testReportUrl: nulltestReport' to Build abc.123-1\",\"startTimeMillis\":1529336303628,\"durationMillis\":40,\"pauseDurationMillis\":0,\"parentNodes\":[\"29\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/31/wfapi/describe\"},\"log\":null},\"id\":\"31\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"looking for abc.123-1 in namespace jkang\",\"startTimeMillis\":1529336303668,\"durationMillis\":1867,\"pauseDurationMillis\":0,\"parentNodes\":[\"30\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/32/wfapi/describe\"},\"log\":null},\"id\":\"32\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Checking bayesian-link exists\",\"startTimeMillis\":1529336305535,\"durationMillis\":186,\"pauseDurationMillis\":0,\"parentNodes\":[\"31\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/33/wfapi/describe\"},\"log\":null},\"id\":\"33\",\"name\":\"Shell Script\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"mvn io.github.stackinfo:stackinfo-maven-plugin:0.2:prepare\",\"startTimeMillis\":1529336305721,\"durationMillis\":12140,\"pauseDurationMillis\":0,\"parentNodes\":[\"32\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/36/wfapi/describe\"},\"log\":null},\"id\":\"36\",\"name\":\"Bayesian Analysis\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"https://bayesian-link\",\"startTimeMillis\":1529336318042,\"durationMillis\":2060,\"pauseDurationMillis\":0,\"parentNodes\":[\"35\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/37/wfapi/describe\"},\"log\":null},\"id\":\"37\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Looking for matching Build abc.123-1\",\"startTimeMillis\":1529336320102,\"durationMillis\":190,\"pauseDurationMillis\":0,\"parentNodes\":[\"36\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/38/wfapi/describe\"},\"log\":null},\"id\":\"38\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Adding annotation 'fabric8.io/bayesian.analysisUrl: https://recommender.api.openshift.io/api/v1/stack-analyses/9cde248cc8b841b898aaf09ee243ed3e' to Build abc.123-1\",\"startTimeMillis\":1529336320292,\"durationMillis\":42,\"pauseDurationMillis\":0,\"parentNodes\":[\"37\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/39/wfapi/describe\"},\"log\":null},\"id\":\"39\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"looking for abc.123-1 in namespace jkang\",\"startTimeMillis\":1529336320334,\"durationMillis\":227,\"pauseDurationMillis\":0,\"parentNodes\":[\"38\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/42/wfapi/describe\"},\"log\":null},\"id\":\"42\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Checking sonarqube exists\",\"startTimeMillis\":1529336321404,\"durationMillis\":110,\"pauseDurationMillis\":0,\"parentNodes\":[\"41\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/43/wfapi/describe\"},\"log\":null},\"id\":\"43\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Code validation service: sonarqube not available\",\"startTimeMillis\":1529336321514,\"durationMillis\":126,\"pauseDurationMillis\":0,\"parentNodes\":[\"42\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/44/wfapi/describe\"},\"log\":null},\"id\":\"44\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"s2i mode: true\",\"startTimeMillis\":1529336321640,\"durationMillis\":317,\"pauseDurationMillis\":0,\"parentNodes\":[\"43\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/45/wfapi/describe\"},\"log\":null},\"id\":\"45\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Checking content-repository exists\",\"startTimeMillis\":1529336321957,\"durationMillis\":99,\"pauseDurationMillis\":0,\"parentNodes\":[\"44\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/46/wfapi/describe\"},\"log\":null},\"id\":\"46\",\"name\":\"Print Message\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"mvn site disabled\",\"startTimeMillis\":1529336322056,\"durationMillis\":47,\"pauseDurationMillis\":0,\"parentNodes\":[\"45\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/47/wfapi/describe\"},\"log\":null},\"id\":\"47\",\"name\":\"Stash some files to be used later in the build\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336322103,\"durationMillis\":715,\"pauseDurationMillis\":0,\"parentNodes\":[\"46\"]}],\"allChildNodeIds\":[\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"36\",\"37\",\"38\",\"39\",\"40\",\"41\",\"42\",\"43\",\"44\",\"45\",\"46\",\"47\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/60/wfapi/describe\"},\"log\":null},\"id\":\"60\",\"name\":\"Rollout to Stage\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336324268,\"durationMillis\":11782,\"pauseDurationMillis\":0,\"stageFlowNodes\":[{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/61/wfapi/describe\"},\"log\":null},\"id\":\"61\",\"name\":\"Restore files previously stashed\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336324380,\"durationMillis\":727,\"pauseDurationMillis\":0,\"parentNodes\":[\"60\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/62/wfapi/describe\"},\"log\":null},\"id\":\"62\",\"name\":\"Apply resources to Kubernetes, lazily creating environments and routes\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"jkang-stage\",\"startTimeMillis\":1529336325107,\"durationMillis\":10780,\"pauseDurationMillis\":0,\"parentNodes\":[\"61\"]}],\"allChildNodeIds\":[\"61\",\"62\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/66/wfapi/describe\"},\"log\":null},\"id\":\"66\",\"name\":\"Approve\",\"execNode\":\"\",\"status\":\"FAILED\",\"error\":{\"message\":null,\"type\":\"org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\"},\"parameterDescription\":null,\"startTimeMillis\":1529336336152,\"durationMillis\":15684855,\"pauseDurationMillis\":15680012,\"stageFlowNodes\":[{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/67/wfapi/describe\"},\"log\":null},\"id\":\"67\",\"name\":\"Sends a message with proceed/abort instructions to a hubot chat room for a project\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":null,\"startTimeMillis\":1529336336592,\"durationMillis\":460,\"pauseDurationMillis\":0,\"parentNodes\":[\"66\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/68/wfapi/describe\"},\"log\":null},\"id\":\"68\",\"name\":\"Creates an Approve requested event in Elasticsearch\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"Stage\",\"startTimeMillis\":1529336337052,\"durationMillis\":45,\"pauseDurationMillis\":0,\"parentNodes\":[\"67\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/71/wfapi/describe\"},\"log\":null},\"id\":\"71\",\"name\":\"Wait for interactive input\",\"execNode\":\"\",\"status\":\"FAILED\",\"error\":{\"message\":null,\"type\":\"org.jenkinsci.plugins.workflow.steps.FlowInterruptedException\"},\"parameterDescription\":null,\"startTimeMillis\":1529336337276,\"durationMillis\":15680570,\"pauseDurationMillis\":15680012,\"parentNodes\":[\"70\"]},{\"_links\":{\"self\":{\"href\":\"https://jenkins.openshift.io/job/jiekang/job/abc.123/job/master/1/execution/node/74/wfapi/describe\"},\"log\":null},\"id\":\"74\",\"name\":\"Updates an Approve event in Elasticsearch\",\"execNode\":\"\",\"status\":\"SUCCESS\",\"error\":null,\"parameterDescription\":\"false\",\"startTimeMillis\":1529352019157,\"durationMillis\":1648,\"pauseDurationMillis\":0,\"parentNodes\":[\"73\"]}],\"allChildNodeIds\":[\"67\",\"68\",\"69\",\"70\",\"71\",\"72\",\"73\",\"74\"]}]}"
                },
                "creationTimestamp": "2018-06-18T15:27:14Z",
                "labels": {
                    "buildconfig": "abc.123",
                    "openshift.io/build-config.name": "abc.123",
                    "openshift.io/build.start-policy": "Serial",
                    "openshift.io/gitRepository": "abc.123",
                    "space": "1234"
                },
                "name": "abc.123-1",
                "namespace": "jkang",
                "ownerReferences": [
                    {
                        "apiVersion": "build.openshift.io/v1",
                        "controller": true,
                        "kind": "BuildConfig",
                        "name": "abc.123",
                        "uid": "121dfbed-730c-11e8-88ca-0233cba325d9"
                    }
                ],
                "resourceVersion": "1151097121",
                "selfLink": "/apis/build.openshift.io/v1/namespaces/jkang/builds/abc.123-1",
                "uid": "13e0fb2e-730c-11e8-88ca-0233cba325d9"
            },
            "spec": {
                "nodeSelector": {},
                "output": {},
                "postCommit": {},
                "resources": {},
                "serviceAccount": "builder",
                "source": {
                    "git": {
                        "uri": "https://github.com/jiekang/abc.123.git"
                    },
                    "type": "Git"
                },
                "strategy": {
                    "jenkinsPipelineStrategy": {
                        "env": [
                            {
                                "name": "FABRIC8_SPACE",
                                "value": "1234"
                            }
                        ],
                        "jenkinsfilePath": "Jenkinsfile"
                    },
                    "type": "JenkinsPipeline"
                },
                "triggeredBy": [
                    {
                        "message": "Forge triggered"
                    }
                ]
            },
            "status": {
                "completionTimestamp": "2018-06-18T20:00:21Z",
                "config": {
                    "kind": "BuildConfig",
                    "name": "abc.123",
                    "namespace": "jkang"
                },
                "output": {},
                "phase": "Cancelled",
                "startTimestamp": "2018-06-18T15:34:11Z"
            }
        },
        {
            "apiVersion": "build.openshift.io/v1",
            "kind": "Build",
            "metadata": {
                "annotations": {
                    "openshift.io/build-config.name": "abc.123",
                    "openshift.io/build.number": "2"
                },
                "creationTimestamp": "2018-06-18T15:35:22Z",
                "labels": {
                    "buildconfig": "abc.123",
                    "openshift.io/build-config.name": "abc.123",
                    "openshift.io/build.start-policy": "Serial",
                    "openshift.io/gitRepository": "abc.123",
                    "space": "1234"
                },
                "name": "abc.123-2",
                "namespace": "jkang",
                "ownerReferences": [
                    {
                        "apiVersion": "build.openshift.io/v1",
                        "controller": true,
                        "kind": "BuildConfig",
                        "name": "abc.123",
                        "uid": "121dfbed-730c-11e8-88ca-0233cba325d9"
                    }
                ],
                "resourceVersion": "1150926194",
                "selfLink": "/apis/build.openshift.io/v1/namespaces/jkang/builds/abc.123-2",
                "uid": "3675328f-730d-11e8-8455-02e52a0be43d"
            },
            "spec": {
                "nodeSelector": {},
                "output": {},
                "postCommit": {},
                "resources": {},
                "serviceAccount": "builder",
                "source": {
                    "git": {
                        "ref": "master",
                        "uri": "https://github.com/jiekang/abc.123.git"
                    },
                    "type": "Git"
                },
                "strategy": {
                    "jenkinsPipelineStrategy": {
                        "env": [
                            {
                                "name": "FABRIC8_SPACE",
                                "value": "1234"
                            }
                        ],
                        "jenkinsfilePath": "Jenkinsfile"
                    },
                    "type": "JenkinsPipeline"
                },
                "triggeredBy": [
                    {
                        "message": "Triggered by Jenkins job at https://jenkins-jkang-jenkins.8a09.starter-us-east-2.openshiftapps.com/job/jiekang/job/abc.123/job/master/"
                    }
                ]
            },
            "status": {
                "config": {
                    "kind": "BuildConfig",
                    "name": "abc.123",
                    "namespace": "jkang"
                },
                "output": {},
                "phase": "New"
            }
        }
    ],
    "kind": "List",
    "metadata": {
        "resourceVersion": "",
        "selfLink": ""
    }
}
ebaron commented 6 years ago

@jiekang It looks like the problem is that there are no completed builds for the build config. The first build was cancelled, and the second seems to be stuck in the "New" phase. I think what may have happened is the first build finished and rolled out to the stage environment, but was cancelled instead of promoted.

In order to find the deployment config name when it differs from the build config name, we have do dig through builds to find the annotation that begins with environment.services.fabric8.io. We currently look for the most recently completed build, but this fails in the above case. Perhaps instead we should look for the most recent build that contains the annotation we require.

jiekang commented 6 years ago

Okay, awesome; thanks for the explanation. The situation of a cancelled promotion is valid and results in a deployment to stage but not to run. How hard would it be to make the changes for your suggested path? I think it's worthwhile to fix this.

ebaron commented 6 years ago

@jiekang This shouldn't be too hard to change.

I think a better long-term solution would be to apply labels to associating OpenShift objects to their OSIO application, but this will affect several different areas.