uselagoon / lagoon

Lagoon, the developer-focused application delivery platform
https://docs.lagoon.sh/
Apache License 2.0
565 stars 148 forks source link

Slashes and Fullstops in branch names confuse Lagoon's production branch detection #2461

Open seanhamlin opened 3 years ago

seanhamlin commented 3 years ago

Describe the bug

If you have branch name with 'special' characters in them, e.g.:

If you set the production branch to be the exact same name as the branch, you will get a non-production environment, as Lagoon appears to be doing normalisation on the name prior to matching the branch name.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new project with the production branch name set to 9.x
  2. Deploy the branch
  3. Notice how the environment is marked as development

Expected behavior

Lagoon would not normalise prior to matching

Screenshots

$ lagoon -l amazeeio list environments -p drupal-example-REDACTED
ID      NAME                                            DEPLOYTYPE  ENVIRONMENT OPENSHIFTPROJECTNAME                                        ROUTE
246885  9.x                                             branch      production  drupal-example-REDACTED-9-x                                     none
247626  renovate/8.x-advanced-composer-installers-1.x   branch      development drupal-example-REDACTED-renovate-8-x-advanced-composer-ins-abfa none
247589  renovate/8.x-composer-installers-1.x            branch      development drupal-example-REDACTED-renovate-8-x-composer-installers-1-x    none
247590  renovate/9.x-advanced-composer-installers-1.x   branch      development drupal-example-REDACTED-renovate-9-x-advanced-composer-ins-c5c1 none
247587  renovate/9.x-composer-installers-1.x            branch      development drupal-example-REDACTED-renovate-9-x-composer-installers-1-x    none
247630  renovate/9.x-postgres-composer-installers-1.x   branch      development drupal-example-REDACTED-renovate-9-x-postgres-composer-ins-c2a6 none

$ lagoon -l amazeeio deploy branch -p drupal-example-REDACTED -b 9.x
✔ Yes
Error: '9.x' would exceed the configured limit of 5 development environments for project drupal-example-REDACTED

Additional context

This also impacts the development environment limits as well (as seen above).

Cluster is using the new controllers for deployment.

Also appears to be related to https://github.com/amazeeio/lagoon/issues/1944

smlx commented 3 years ago

duplicate of https://github.com/amazeeio/lagoon/issues/2322 I believe

seanhamlin commented 3 years ago

Yes, it looks like it for sure. I searched for an existing issue, and did not find anything at the time.

smlx commented 3 years ago

I ran into this bug today when trying to deploy a production environment with an underscore.

Situation:

Deploying the production environment was not possible and returned this error:

Error: 'myproject_production' would exceed the configured limit of 6 development environments for project myproject

I guess this is because the code that checks the limits on projects compares the unsanitised environment name to the production environment, which is set to work around #2322.

"productionEnvironment": "myproject-production",