uselagoon / lagoon

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

Increase or document environment branch reference limits #3815

Open shreddedbacon opened 1 month ago

shreddedbacon commented 1 month ago

The baseref and headref fields on an environment in the database have a max length of 100. This can result in environments or pullrequests that have long branch refs failing to deploy with an obscure error.

https://github.com/uselagoon/lagoon/blob/1cf5c769be03f5b4d17ab1d8ea0ed9faf2a25102/services/api/database/migrations/20220908065119_initial_db.js#L79-L80

We should either increase this, or document these limits. We should also return an clearer error if these limits are exceeded, rather than when the SQL in performed.

tobybellwood commented 1 month ago

It looks like github has a 255 char limit - including refs/heads/

so maybe we can change this - but should we also support longer environment names too - to accommodate it - or are we happy to truncate them when needed?

Context - making lots of db changes in https://github.com/uselagoon/lagoon/pull/3816 - so can accommodate these there if needed

shreddedbacon commented 1 month ago

so maybe we can change this - but should we also support longer environment names too - to accommodate it - or are we happy to truncate them when needed?

TLDR; Yeah, we can probably increase them to 255, but leave the environment name at 100.

Well we add some things into labels in resources, and labels in kubernetes have limits on the length of the value. If we were going to have any issues, it would be on the environment name after it has been modified, but this truncates the calculated name to 63 already (58+5, 5 being -hash).

Luckily, we put the unmodified values of branch/refs into annotations which can definitely support more than 255.

I don't think we do anything to the project name though, and this would suffer from a being greater than 63 thing, which I'm a bit surprised hasn't happened. We limit project names to 100 in the db