Skip to content

Commit

Permalink
Merge pull request #18114 from spadgett/console-config-api-changes
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Update cluster up for console config API changes

Adopt API changes from openshift/api#31

For now, both the new and old config need to be written to avoid breaking cluster up until origin-web-console-server is updated.

/assign @deads2k 
@jwforres FYI
  • Loading branch information
openshift-merge-robot authored Jan 19, 2018
2 parents 91d864d + 5ba8f2f commit 0f43934
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 47 deletions.
41 changes: 31 additions & 10 deletions install/origin-web-console/console-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
kind: WebConsoleConfiguration
apiVersion: webconsole.config.openshift.io/v1
kind: WebConsoleConfiguration
clusterInfo:
consolePublicURL: https://127.0.0.1:8443/console/
loggingPublicURL: ""
logoutPublicURL: ""
masterPublicURL: https://127.0.0.1:8443
metricsPublicURL: ""
# TODO: The new extensions properties cannot be set until
# origin-web-console-server has been updated with the API changes since
# `extensions` in the old asset config was an array.
#extensions:
# scriptURLs: []
# stylesheetURLs: []
# properties: null
features:
inactivityTimeoutMinutes: 0
servingInfo:
bindAddress: 0.0.0.0:8443
bindNetwork: tcp4
certFile: /var/serving-cert/tls.crt
clientCA: ""
keyFile: /var/serving-cert/tls.key
maxRequestsInFlight: 0
namedCertificates: null
requestTimeoutSeconds: 0

# START deprecated properties
# These properties have been renamed and will be removed from the install
# in a future pull. Keep both the old and new properties for now so that
# the install is not broken while the origin-web-console image is updated.
extensionDevelopment: false
extensionProperties: null
extensionScripts: null
Expand All @@ -10,12 +39,4 @@ logoutURL: ""
masterPublicURL: https://127.0.0.1:8443
metricsPublicURL: ""
publicURL: https://127.0.0.1:8443/console/
servingInfo:
bindAddress: 0.0.0.0:8443
bindNetwork: tcp4
certFile: /var/serving-cert/tls.crt
clientCA: ""
keyFile: /var/serving-cert/tls.key
maxRequestsInFlight: 0
namedCertificates: null
requestTimeoutSeconds: 0
# END deprecated properties
43 changes: 32 additions & 11 deletions pkg/oc/bootstrap/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 34 additions & 15 deletions pkg/oc/bootstrap/docker/openshift/webconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
consoleNamespace = "openshift-web-console"
consoleRBACTemplateName = "web-console-server-rbac"
consoleAPIServerTemplateName = "openshift-web-console"
consoleAssetConfigFile = "install/origin-web-console/console-config.yaml"
consoleConfigFile = "install/origin-web-console/console-config.yaml"
)

// InstallWebConsole installs the web console server into the openshift-web-console namespace and waits for it to become ready
Expand All @@ -46,40 +46,59 @@ func (h *Helper) InstallWebConsole(f *clientcmd.Factory, imageFormat string, ser
return errors.NewError("cannot instantiate template service broker permissions").WithCause(err)
}

// read in the asset config YAML file like the installer
assetConfigYaml, err := bootstrap.Asset(consoleAssetConfigFile)
// read in the config YAML file like the installer
consoleConfigYaml, err := bootstrap.Asset(consoleConfigFile)
if err != nil {
return errors.NewError("cannot read web console asset config file").WithCause(err)
return errors.NewError("cannot read web console config file").WithCause(err)
}

// prase the YAML to edit
var assetConfig map[string]interface{}
if err := yaml.Unmarshal(assetConfigYaml, &assetConfig); err != nil {
return errors.NewError("cannot parse web console asset config as YAML").WithCause(err)
var consoleConfig map[string]interface{}
if err := yaml.Unmarshal(consoleConfigYaml, &consoleConfig); err != nil {
return errors.NewError("cannot parse web console config as YAML").WithCause(err)
}

// update asset config values
assetConfig["publicURL"] = publicURL
assetConfig["masterPublicURL"] = masterURL
// update config values
clusterInfo, ok := consoleConfig["clusterInfo"].(map[interface{}]interface{})
if !ok {
return errors.NewError("cannot read clusterInfo in web console config")
}

clusterInfo["consolePublicURL"] = publicURL
clusterInfo["masterPublicURL"] = masterURL
if len(loggingURL) > 0 {
clusterInfo["loggingPublicURL"] = loggingURL
}
if len(metricsURL) > 0 {
clusterInfo["metricsPublicURL"] = metricsURL
}

// START deprecated properties
// These properties have been renamed and will be removed from cluster up
// in a future pull. Keep both the old and new properties for now so that
// the cluster up is not broken while the origin-web-console image is updated.
consoleConfig["publicURL"] = publicURL
consoleConfig["masterPublicURL"] = masterURL
if len(loggingURL) > 0 {
assetConfig["loggingPublicURL"] = loggingURL
consoleConfig["loggingPublicURL"] = loggingURL
}
if len(metricsURL) > 0 {
assetConfig["metricsPublicURL"] = metricsURL
consoleConfig["metricsPublicURL"] = metricsURL
}
// END deprecated properties

// serialize it back out as a string to use as a template parameter
updatedAssetConfig, err := yaml.Marshal(assetConfig)
updatedConfig, err := yaml.Marshal(consoleConfig)
if err != nil {
return errors.NewError("cannot serialize web console asset config").WithCause(err)
return errors.NewError("cannot serialize web console config").WithCause(err)
}

imageTemplate := variable.NewDefaultImageTemplate()
imageTemplate.Format = imageFormat
imageTemplate.Latest = false

params := map[string]string{
"API_SERVER_CONFIG": string(updatedAssetConfig),
"API_SERVER_CONFIG": string(updatedConfig),
"IMAGE": imageTemplate.ExpandOrDie("web-console"),
"LOGLEVEL": fmt.Sprint(serverLogLevel),
"NAMESPACE": consoleNamespace,
Expand Down
43 changes: 32 additions & 11 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f43934

Please sign in to comment.