[kind/bug]
odo version: odo v0.0.17 (78a050bc)git clone git clone https://github.com/openshift-labs/beercan-shooter-game.git frontend
cd frontend
odo create project intro-workshop-ffdba71e1aac11e9b95c
odo create nodejs frontend
odo create url
The URL that is created is:
frontend-nodejs-lmus-frontend-jwzy-intro-workshop-ffdba71e1aac11e9b95c.apps.osevg-cbc0.openshiftworkshop.com in my environment.
First segment, the one created based on application, component and project is 70 chars long, and exceeds 64 chars which is the maximum length allowed.
The route is created but it's not accepted by the OpenShift Router, hence never functional.
The url should be shortened to 64 chars max.
In this example there are some constraints:
The component names and application names might be too long.
I think if we have a good enough salt like maybe an 8 alphanumeric characters e.g. nodejs-asdr-45fsd4es.***.com instead of -<port>-<app>-<project> suffix then we can control the length of the url even when the project name and application name is long
or we can expose the mechanism by which we are generating the format and provide the user to give their own odo url create --format "{{.Name}}-{{.Port}}-{{.App}}-{{.Project}}"
This should in any case be a preference and not a config. Saving this to the config file is not right.
In any case, I would make this more priority, as the url that we produce should be fall safe no matter what.
I'm not able to reproduce this one. Looking at the OpenShift docs, I do see the 63 character limit:
Each route consists of a name (limited to 63 characters), a service selector, and an optional security configuration.
But following the steps mentioned above, I managed to create a URL and shoot some beer bottles!
$ odo push
โ Checking component
โ Checking component version
โ Creating nodejs component with name fronted
โ Initializing 'fronted' component
โ Creating component fronted
โ Successfully created component fronted
โ Checking URL fronted-8080
โ Applying component settings to component: fronted โ Successfully created URL for component: fronted
โ http://fronted-8080-app-intro-workshop-ffdba71e1aac11e9b95c.192.168.42.121.nip.io
โ Applying component settings to component: fronted
โ Successfully updated component with name: fronted
โ Pushing changes to component: fronted of type local
โ Waiting for component to start
โ Copying files to component
โ Building component
โ Changes successfully pushed to component: fronted
$ odo url list
Found the following URLs for component fronted in application app:
NAME URL PORT
fronted-8080 http://fronted-8080-app-intro-workshop-ffdba71e1aac11e9b95c.192.168.42.121.nip.io 8080
$ python master โ
Python 2.7.16 (default, Apr 30 2019, 15:54:43)
[GCC 9.0.1 20190312 (Red Hat 9.0.1-0.10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len('fronted-8080-app-intro-workshop-ffdba71e1aac11e9b95c.192.168.42.121.nip.io')
74
@dharmit The 63 character length limit is on the route name, so only on fronted-8080-app-intro-workshop-ffdba71e1aac11e9b95c. You need to create a longer component name and app name for this to show up-
Yes, that's the case:
$ odo push
โ Checking component
โ Checking component version
โ fronted-really-long-component-name-name-name-name-name-name-name is not a valid name: must be no more than 63 characters
$ odo config view
COMPONENT SETTINGS
------------------------------------------------
PARAMETER CURRENT_VALUE
Type nodejs
Application app
Project intro-workshop-ffdba71e1aac11e9b95c
SourceType local
Ref
SourceLocation ./
Ports
Name fronted-really-long-component-name-name-name-name-name-name-name
MinMemory
MaxMemory
Ignore
MinCPU
MaxCPU
Rather than adding some complicated formatting option, I would just simply impose a character limit on the autogenerated url names.
If the limit is 63, and the generated name is longer than 63 characters just cut it down to 63.
I wouldn't worry about collisions. If there is a collision user can just simply name the url - odo url create myurl
I would just advice when creating the url that is too long and will be truncated and that if the user wants a specific url, to provide a name, also with a confirmation in case of a it'll too long, so that it can be fixed sooner, rather than having to delete the url and create a new (shorter) one.
So, I'm on master and trying to create a URL for a component that's got a really long name. Pretty much like what I did in https://github.com/openshift/odo/issues/1213#issuecomment-499874218. But now the error shows up when creating a URL, i.e., it doesn't let you create a URL when the component name is too long. In fact, it doesn't let you create a component name that's longer than 63 characters either. So I had to first create a component name that was short and then manually modified .odo/config.yml to try to hit the error.
bash
$ odo create nodejs frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long
โ Validating component [32s]
โ frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long is not a valid name: must be no more than 63 characters
frontend, then modify .odo/config.yml to make the name long and then create a url, it doesn't let us do that:bash
$ odo url create --port 8080
โ unable to parse requirement: invalid label value: "frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long": must be no more than 63 characters
odo version output
$ odo version
odo v1.0.0-beta2 (009f9d7e)
Server: https://192.168.42.121:8443
Kubernetes: v1.11.0+d4cacc0
So, I'm wondering if there's anything to fix here. Or am I missing something here? :thinking:
This issue was open a while back, so it is possible that some of the issues were resolved.
I can still see one problem:
โถ odo url create frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long --port 8080
โ URL frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long created
Run `odo push` to apply URL: frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long
โถ odo push
Validation
โ Validating component [10s]
โ Checking component [1s]
Configuration changes
โ Initializing component
โ Creating component [2s]
โ Applying configuration [0s]
Applying URL changes
โ Failed to update config to component deployed
We need to add a check for length to odo url create before we actually try to create the route.
Does this make sense to prevent user from doing so:
$ odo url create frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long --port 8080
โ url name must be shorter than 63 characters
Tangential question: shouln't odo url create work without having an active connection with the OpenShift cluster? :thinking:
Does this make sense to prevent user from doing so:
$ odo url create frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long --port 8080 โ url name must be shorter than 63 characters
that looks good
Tangential question: shouln't
odo url creatework without having an active connection with the OpenShift cluster? ๐ค
Yes, it should, there is nothing that we need from the cluster.
Does this make sense to prevent user from doing so:
$ odo url create frontend-long-long-long-long-long-long-long-long-long-long-long-long-long-long --port 8080 โ url name must be shorter than 63 charactersthat looks good
I'll open a PR and add an integration test to it.
Tangential question: shouln't
odo url creatework without having an active connection with the OpenShift cluster? thinkingYes, it should, there is nothing that we need from the cluster.