Odo: URL length is not checked

Created on 18 Jan 2019  ยท  13Comments  ยท  Source: openshift/odo

[kind/bug]

What versions of software are you using?

  • Operating System: macOS
  • Output of odo version: odo v0.0.17 (78a050bc)

How did you run odo exactly?

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

Actual behavior

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.

Expected behavior

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.

Any logs, error output, etc?

kinbug point2 prioritMedium

All 13 comments

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.

  • If we try to create a component name that's longer than 63 chars, it doesn't let us do that:
    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
  • If we create a component named 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 create work 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 characters

that looks good

I'll open a PR and add an integration test to it.

Tangential question: shouln't odo url create work without having an active connection with the OpenShift cluster? thinking

Yes, it should, there is nothing that we need from the cluster.

1813

Was this page helpful?
0 / 5 - 0 ratings