Skip to content

Conversation

@jhadvig
Copy link
Member

@jhadvig jhadvig commented Sep 25, 2019

PR for adding the URL for downloading CLI to the console-config configmap, in clusterInfo.cliDownloadURL field.

Screen Shot 2019-09-25 at 21 27 02

Story: https://jira.coreos.com/browse/CONSOLE-1423

/assign @benjaminapetersen

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 25, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jhadvig
To complete the pull request process, please assign benjaminapetersen
You can assign the PR to them by writing /assign @benjaminapetersen in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@spadgett
Copy link
Member

spadgett commented Sep 25, 2019

We'll need a way to specify different URLs for different platforms

@jhadvig
Copy link
Member Author

jhadvig commented Sep 25, 2019

@spadgett the downloads pod contains binary for linux,osx, widnows... was in impression that it is the route to the pod that we want to wire to the console.

@jhadvig
Copy link
Member Author

jhadvig commented Sep 25, 2019

Or we want a direct link for each platform in the console's "Command Line Tools" page ?

@spadgett
Copy link
Member

Or we want a direct link for each platform in the console's "Command Line Tools" page ?

Yes, IMO this is a much better experience than dumping the user in a directory listing.

@jhadvig
Copy link
Member Author

jhadvig commented Sep 25, 2019

@spadgett also, for each platform there are is a: oc, oc.tar, oc.zip
I suppose we want to provide the plane oc binary since its a single file ?

@spadgett
Copy link
Member

Hm, maybe linux .tar.gz and mac and windows use .zip ?

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 26, 2019
@jhadvig
Copy link
Member Author

jhadvig commented Sep 26, 2019

@spadgett @benjaminapetersen I've update the PR
Now there will be a URL for each platform we build binary for.

PTAL

Screen Shot 2019-09-26 at 17 34 35

@jhadvig
Copy link
Member Author

jhadvig commented Sep 26, 2019

/retest

managedConfig *corev1.ConfigMap,
infrastructureConfig *configv1.Infrastructure,
rt *routev1.Route) (consoleConfigmap *corev1.ConfigMap, unsupportedOverridesHaveMerged bool, err error) {
rt *routev1.Route,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably update to

consoleRoute *routev1.Route,
downloadsRoute *routev1.Route) (consoleConfigmap *corev1.ConfigMap, unsupportedOverridesHaveMerged bool, err error) {

Mean name both routes now that there are two.


const (
host = "localhost"
downloadHost = "https://downloads-openshift-console.apps.some.cluster.openshift.com"
Copy link
Contributor

@benjaminapetersen benjaminapetersen Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, for the test I'd rather inline these. Its a tad repetitious, but I think it makes a better test if the input and output are specific to each test and the output (ie, the want) is hard-coded in the specific test.

Also, it's nice to know that if one test breaks, you can be certain that fixing it won't accidentally break other tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to add one test w/o the downloads route (nil) and make sure the config is still properly generated:

{
     name: "Test default configmap, no customization overrides",
     // downloadsRoute: &routev1.Route{ ... }
}, {
     name: "Test default configmap, without downloads",
     // downloadsRoute: nil
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to add one test w/o the downloads route (nil) and make sure the config is still properly generated:

All other TCs have the download route set :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the we have the host const here

}

// CLIDownloadURLs contains download URLs for each of the platforms we provide CLI binary.
type CLIDownloadURLs struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simplify this a bit:

type CLIDownloadURLs struct {
	Linux   string `yaml:"linuxDownloadURL"`
	Mac    string `yaml:"macDownloadURL"`
	Windows string `yaml:"windowsDownloadURL"`

Since its already a heading CLIDownloadURLs we don't need to repeat the DownloadURL part in the field names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, we may want to do CLIDownloadURLs[arch][platform] just like the downloads deployment. Only amd64 now.

Copy link
Member Author

@jhadvig jhadvig Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjaminapetersen how about?

type ClusterInfo struct {
	ConsoleBaseAddress string          `yaml:"consoleBaseAddress,omitempty"`
	ConsoleBasePath    string          `yaml:"consoleBasePath,omitempty"`
	MasterPublicURL    string          `yaml:"masterPublicURL,omitempty"`
	CLIDownloadURLs    *CLIDownloadURLs `yaml:"cliDownloadURLs,omitempty"`
}

// CLIDownloadURLs contains all the architertures that we are building CLI binaries for.
type CLIDownloadURLs struct {
	Amd64 ArchPlatformsURL `yaml:"amd64,omitempty"`
}

// ArchPlatformsURL contains URLs for each of the platforms we provide CLI binary.
type ArchPlatformsURL struct {
	Linux   string `yaml:"linux"`
	Mac     string `yaml:"mac"`
	Windows string `yaml:"windows"`
}

Although Im not really sure about the CLIDownloadURLs, but its pretty generic and with the aditional architecture specified it kinda dioes make sense?

Copy link
Contributor

@benjaminapetersen benjaminapetersen Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! Though I wonder if ArchPlatformsURL vs ArchPlatformURLs. As "one platform has many urls", and if you had many archs, you would []ArchPlatformURLs, which have many URLs but are named.

type CLIDownloadURLs struct {
   Amd64 ArchPlatformURLs `yaml:"amd64,omitempty"`
   Foo32 ArchPlatformURLs `yaml:"Foo32,omitempty"`
   Bar64 ArchPlatformURLs `yaml:"Bar64,omitempty"`
}

Since we expect 3+ URLs for archs added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we tan to chain it like you mentioned in your previous comment it cant be an array.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on ArchPlatformURLs

secured := fmt.Sprintf("%s%s", protocol, host)
return secured
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can keep this func in the configmap_builder.go file. It isn't shared elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should we give it a unit test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add !

pkg/api/api.go Outdated
@@ -1,5 +1,12 @@
package api

const (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to move these into the configmap_builder.go file, since they are only used in one place.

return nil, false, "FailedGetDownloadsRoute", err
}

defaultConfigmap, _, err := configmapsub.DefaultConfigMap(operatorConfig, consoleConfig, managedConfig, infrastructureConfig, rt, downloadsRoute)
Copy link
Contributor

@benjaminapetersen benjaminapetersen Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to update the var name to consoleRoute, downloadsRoute?

},
},
{
name: "Test openshift-console namespace without downloads route",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for a test without the downloads route.
Test openshift-console namespace without downloads route - namespace? I'm a bit confused by the test name, however.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasnt really sure how to name the test, other then this since the setup is nil download route. But really should be something like : Test getting URLs for downloading CLI, without downloads route. ... maybe ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation is that there would be no downloads then, if there is no route, correct? I'm good with long tests names that clearly indicate everything, including expected output.

Perhaps Validate that there is no download CLI links when download route is nil``?

Out test naming convention isn't super strong, so if we have to break it for clarity, thats fine. We could always go back and improve the names of the other tests if you have something that works better.

},
},
{
name: "Test operator config with Statuspage pageID",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we already had this test, trying to figure out why its showing up as new.

}
func (b *ConsoleServerCLIConfigBuilder) CLIDownloadURL(cliDownloadURL string) *ConsoleServerCLIConfigBuilder {
if cliDownloadURL != "" {
b.cliDownloadURLs = &CLIDownloadURLs{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment about dropping the DownloadURL redundancy. I think we can clean this up just a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense !

Copy link
Contributor

@benjaminapetersen benjaminapetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor things, thx!

@jhadvig
Copy link
Member Author

jhadvig commented Sep 27, 2019

@benjaminapetersen comments addressed. PTAL

@jhadvig
Copy link
Member Author

jhadvig commented Sep 29, 2019

/retest

@jhadvig
Copy link
Member Author

jhadvig commented Sep 30, 2019

@benjaminapetersen so was looking into the console side of this story and figured out that it might be better to create ConsoleCLIDownload CR that will represent the per architecture binaries for all the different platforms.

Eg. I've created following CR :

yaml
apiVersion: console.openshift.io/v1
kind: ConsoleCLIDownload
metadata:
  name: download-cli-amd64
spec:
  description: >
    With the OpenShift command line interface, you can create applications and
    manage OpenShift projects from a terminal.


    The oc binary offers the same capabilities as the kubectl binary, but it is
    further extended to natively support OpenShift Container Platform features.
  displayName: oc - OpenShift Command Line Interface (CLI)  - amd64
  links:
    - href: 'https://www.example.com'
      text: Download oc for Linux
    - href: 'https://www.example.com'
      text: Download oc for Mac
    - href: 'https://www.example.com'
      text: Download oc for Windows

which will produce the third section in the below screenshot:

Screen Shot 2019-09-30 at 13 02 42

With this I was thinking that instead of adding logic to operator and console, let the operator create the CR for each arch type, that will contain the binaries for all the platforms.

cc'ing @spadgett for opinion

@benjaminapetersen
Copy link
Contributor

Ha, I like this. leverages what we already built, no point in all the additional wiring.


func getCliDownloadUrl(downloadsRoute *routev1.Route) string {
if downloadsRoute != nil {
return downloadsRoute.Spec.Host
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route.Spec.Host will actually be removed, we have a GetCanonicalHost() func that could be used instead.

@spadgett
Copy link
Member

If we're going to do this for oc, we might want to do it for odo as well. I'd suggest special handling to make sure oc is moved to the top of the list. We'll need to handle the case where you are running against native k8s and this resource doesn't exist.

Only potential downside I see is we can't give special handling to the different platforms (e.g., highlight the macos link if we detect you are on a mac).

@benjaminapetersen
Copy link
Contributor

@spadgett @jhadvig agree we discussed the ordering problem a little bit. ConsoleCLIDownload as a type is pretty specific, We could add an optional platform tag to each link, which would give us the opportunity to have the filtering logic in the console.

@benjaminapetersen
Copy link
Contributor

Something like this could be worth discussing:

apiVersion: console.openshift.io/v1
kind: ConsoleCLIDownload
metadata:
  name: example-oc
spec:
  displayName: example-oc
  description: >
    This is a link with platforms
  links:
    - href: 'https://www.example.com'
      name: oc for linux
      platform: linux
    - href: 'https://www.example.com'
      name: oc for mac
      platform: mac
    - href: 'https://www.example.com'
      name: oc for windows
      platform: windows

@benjaminapetersen
Copy link
Contributor

/hold

As we investigate this other direction.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2019
@jhadvig
Copy link
Member Author

jhadvig commented Oct 3, 2019

Closing in favour of #306

@jhadvig jhadvig closed this Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants