lando / platformsh

The Official Platform.sh Lando Plugin
https://docs.lando.dev/platformsh
GNU General Public License v3.0
6 stars 4 forks source link

Fixing DB port with portforward is not working #39

Closed aimfeld closed 2 years ago

aimfeld commented 3 years ago

I'm trying to set a fixed port for the DB connection according to the guide. However, the port keeps getting assigned randomly on every lando rebuild and lando restart, as shown by lando info. Maybe this doesn't work with the platformsh recipe?

I have this in my .lando.yaml (I tried other port numbers, no luck):

services:
  database:
    portforward: 3307
pirog commented 3 years ago

@aimfeld it should work but there is a good chance your service isn't called database. Should match up with what is in your services.yaml

aimfeld commented 3 years ago

@pirog Thanks for the crazy fast response! You're right, when trying lando rebuild --yes, I got this error: ERROR: No such service: database

My services.yaml looks like this:

mysql:
  type: mysql:10.2
  disk: 2048
cacheredis:
  type: redis:6.0

So I changed my lando.yaml accordingly:

services:
  mysql:
    portforward: 3307

However, I still get random port numbers after lando rebuild --yes, e.g.: external_connection: { host: '127.0.0.1', port: '32851' },

pirog commented 3 years ago

@aimfeld interesting. I'll see if i can replicate.

iKlsR commented 3 years ago

I'm getting this for regular mysql but it only seems to happen when I'm running multiple lando projects. I tend to increase my ports by 1000 starting from 3306 when forwarding.

chrisk-cy2 commented 3 years ago

Has this issue been resolved? I'm getting similar issues as @aimfeld. Getting the correct services and adding the portforward but its being ignored.

Hazmatyre commented 3 years ago

Ports aren't being locked down for me etiher on a latest Lando stable release.

pirog commented 3 years ago

I can replicate this and looking at the code it definitely looks like either a bug or just an oversight.

pirog commented 3 years ago

Ok this should be resolved in v3.1.0 once the release posts. https://github.com/lando/lando/releases/tag/v3.1.0

Def remember that you need to use the service names you define in your Platform.sh services.yaml

aimfeld commented 3 years ago

Works for me in v3.1.0, thanks for fixing! :+1:

kwiechmann commented 3 years ago

I have the latest version of lando installed: v3.1.4 but have not been able to lock the port. Although I can initially see my target port of 3307 with lando info, it eventually moves to a random database port. This appears to be the latest but is this the version the correction?

Here are my configuration files:

.platform/services.yaml:

# The services of the project.
#
# Each service listed will be deployed
# to power your Platform.sh project.

db:
    type: mariadb:10.2
    disk: 2048

.lando.yml

name: sandbox
recipe: platformsh
config:
  id: na4ynz2lwtdyd
services:
  db:
    portforward: 3307
markushausammann commented 2 years ago

I have this problem in 3.6.5

jasloe commented 2 years ago

I, too, have this problem in 3.6.5.

lando rebuild with the following configuration:

services:
  db:
    portforward: 3333
  db2:
    portforward: 4444

yields:

{ service: 'db',
...
  external_connection: { host: '127.0.0.1', port: '58789' },
...

and:

{ service: 'db',
...
  external_connection: { host: '127.0.0.1', port: '58787' },
...

Checking the ports shows:

lsof -i:3333
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 54451 jasloe   85u  IPv4 0x81f000c092148157      0t0  TCP localhost:dec-notes (LISTEN)

lsof -i:4444
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 54451 jasloe   78u  IPv4 0x81f000c05f7b8adf      0t0  TCP localhost:krb524 (LISTEN)

So, no idea what's going on here.

amaisano commented 1 year ago

Same issue on v3.18.0. Cannot set my database portforward to 3307. Use to work in the old days :(

Lando is just handing out random port IDs as if it wasn't set to portforward at all.