Bug 1664574

Summary: Console operator is setting wrong master public URL
Product: OpenShift Container Platform Reporter: Yadan Pei <yapei>
Component: Management ConsoleAssignee: bpeterse
Status: CLOSED CURRENTRELEASE QA Contact: Yadan Pei <yapei>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.1.0CC: aos-bugs, hasha, jhadvig, jokerman, mmccomas, spadgett, yapei
Target Milestone: ---   
Target Release: 4.1.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-18 13:17:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Yadan Pei 2019-01-09 08:08:36 UTC
Description of problem:
Webhooks table show all webhooks of a buildconfig, but current Webhook URL contains un-resolvable IP address of API Server

Version-Release number of selected component (if applicable):
source openshift/console commit: c7f598d85ba30c2a8347885d66e44d2c8be448f5
image: quay.io/openshift-release-dev/ocp-v4.0@sha256:82408fbb3dfc31e35679d9dea48c44d7baf6a2af52dd976c60022d446d1eb64e

How reproducible:

Steps to Reproduce:
1. Create test app
$ oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
2. Check Webhook URLs on console, Build Configs -> ruby-ex -> Webhooks table
3. Trigger new build using the Webhook URL got from console
$ oc start-build --from-webhook=
Unable to connect to the server: dial tcp i/o timeout
4. Trigger new build using the Webhook URL got from CLI
$ oc get bc ruby-ex -o yaml | grep -i secret -A 1
      secret: w0AejjF59-ljmn3JqyCs
    type: GitHub
      secret: gFi_dykz-RZT6q3iLDwG
    type: Generic
$ oc start-build --from-webhook=https://yapei0109-api.devcluster.openshift.com:6443/apis/build.openshift.io/v1/namespaces/yapei/buildconfigs/ruby-ex/webhooks/gFi_dykz-RZT6q3iLDwG/generic
build.build.openshift.io/ruby-ex-2 started

Actual results:
2. Github/Generic Webhook URL is shown as:<secret>/github(generic)

"" comes from window.SERVER_FLAGS.kubeAPIServerURL
const kubeAPIServerURL = (window as any).SERVER_FLAGS.kubeAPIServerURL || 'https://<api-server>';

Expected results:
2. We should show correct Webhook URL on console then user can copy & trigger build directly

Additional info:

Comment 1 Jakub Hadvig 2019-01-14 10:16:27 UTC
So when I check the BC's webhook trigger through the development console,
http://localhost:9000/k8s/ns/test/buildconfigs/ruby-ex I can see resolvable 
IP address -> https://jhadvig-api.devcluster.openshift.com:6443/apis/build.openshift.io/v1/namespaces/test/buildconfigs/ruby-ex/webhooks/<secret>/github

In case I check the trigger directly through the cluster IP.
https://console-openshift-console.apps.jhadvig.devcluster.openshift.com/k8s/ns/test/buildconfigs/ruby-ex I see 
un-resolvable  address<secret>/github

Comment 2 Samuel Padgett 2019-01-14 14:10:36 UTC
The operator needs to tell the console the master public URL in console config property `clusterInfo.masterPublicURL`. That's used to build the webhook URL.

Comment 3 Samuel Padgett 2019-03-11 14:03:14 UTC
*** Bug 1676786 has been marked as a duplicate of this bug. ***

Comment 4 Samuel Padgett 2019-03-11 14:04:29 UTC
This is causing other problems such as bug 1676786.

Comment 6 bpeterse 2019-03-12 14:44:12 UTC
PR opened https://github.com/openshift/console-operator/pull/173

Comment 7 bpeterse 2019-03-12 14:45:59 UTC
It may be wise for the console itself to guard against a missing `masterPublicURL` as well.

Comment 8 bpeterse 2019-03-13 02:17:34 UTC
Console operator will now wait for infrastructure config to get the `apiServerURL` to use as `masterPublicURL`.  The sync loop will error & fail until this config is available (which means the configmap will not be generated & the console will not deploy).

Comment 10 Yadan Pei 2019-03-18 06:01:51 UTC
$ git log b9a3350f96176c9b6291 | grep '#173'
    Merge pull request #173 from benjaminapetersen/bug/1664574/incorrect-master-public-url