Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly reported "You cannot assign url xxx.lndo.site/ to more than one service!" #246

Closed
in0ni opened this issue Oct 7, 2024 · 14 comments · Fixed by #249
Closed

Incorrectly reported "You cannot assign url xxx.lndo.site/ to more than one service!" #246

in0ni opened this issue Oct 7, 2024 · 14 comments · Fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@in0ni
Copy link

in0ni commented Oct 7, 2024

Recently a colleague and I have been receiving the following error:
ERROR ==> You cannot assign url xxx.lndo.site/ to more than one service!

We've both spent a considerable amount of time trying to get rid of it, and have come to the conclusion this might be a bug or falsely reported. In desperation I have completely nuked everything:

  • fully wiped /var/lib/docker
  • fully wiped ~/.lando
  • have only one recipe with multiple services
  • 100% do not have services sharing the same URL.

Quick additional points:

  • I run multiple recipes and have never had any issues in my last few years running lando (of this sort, or this error)
  • I received this after a recent lando update
  • I am running the latest stable version of lando 3.21.2
  • I am running docker 26.1.4 (and have been for quite some time)
  • Only using lando for Drupal 10

We have both decided to continue working, as it seems to not be causing any issues.

Here is an excerpt of the config my organization has been using without issues for a few years, and after introduction of the proxy for appserver throws the error:

name: NAME
proxy:
  appserver:
    - hostname: NAME.lndo.site
  search:
    - search.NAME.lndo.site:8983
  mailhog:
    - mailhog.NAME.lndo.site
  storybook:
    - storybook.NAME.lndo.site:6006

After some testing I found out that the following variations do not throw the same error:

name: NAME
proxy:
  appserver:
    - hostname: NAME-app.lndo.site
  search:
    - NAME-search.lndo.site:8983
  mailhog:
    - NAME-mail.lndo.site
  storybook:
    - NAME-story.lndo.site:6006

and

name: NAME
proxy:
  appserver:
    - hostname: NAME.app.lndo.site
  search:
    - NAME.search.lndo.site:8983
  mailhog:
    - NAME.mailhog.lndo.site
  storybook:
    - NAME.storybook.lndo.site:6006

Any feedback or insight to this would be much appreciated.

@in0ni in0ni added the bug Something isn't working label Oct 7, 2024
@AaronFeledy
Copy link
Member

It's hard to say what's going on without seeing the rest of the config, but NAME.lndo.site is often set automatically by a recipe configuration. You might be creating the conflict by manually adding it to appserver.

@idiazroncero
Copy link

@AaronFeledy the reason why we need to add it to the proxy is because we need to add some headers using traefik:

proxy:
  appserver:
    - hostname: SITE.lndo.site
      middlewares:
        - name: cors
          key: headers.customresponseheaders.Access-Control-Allow-Origin
          value: "*"
  search:
    - search.SITE.lndo.site:8983
  mailhog:
    - mailhog.SITE.lndo.site
  storybook:
    - storybook.SITE.lndo.site:6006

@idiazroncero
Copy link

And, in my case, this is causing actually the CORS headers to fail sometimes.

@in0ni
Copy link
Author

in0ni commented Oct 8, 2024

So, to add more context here -- I have to correct my original post, as I just know understand that this addition is recent. So clearly this is a new issue related to the need to add add these headers.

@AaronFeledy
Copy link
Member

It's difficult to determine whether this is a configuration issue, a bug in Lando, or a bug in one of the plugins without more context. Could you provide more of your configuration from the landofile? I mainly need to see the recipe, config, and services sections to understand what Lando is trying to do with your proxy. The output of lando info may also provide some clues as to the URL assignment.

@in0ni
Copy link
Author

in0ni commented Oct 8, 2024

Here is our full recipe:

name: sitename
recipe: drupal10
env_file:
  - .env
config:
  php: "8.2"
  database: mysql:8.0
  webroot: web
  xdebug: off
  config:
    php: .lando/php.ini
    database: .lando/my-custom.cnf
# Get nice URLs for solr service.
proxy:
  appserver:
    - hostname: sitename.lndo.site
      middlewares:
        - name: cors
          key: headers.customresponseheaders.Access-Control-Allow-Origin
          value: "*"
  search:
    - search.sitename.lndo.site:8983
  mailhog:
    - mailhog.sitename.lndo.site
  storybook:
    - storybook.sitename.lndo.site:6006

services:
  appserver:
    overrides:
      environment:
        PHP_MEMORY_LIMIT: 256M
      volumes:
        - ${HOME}/.config/composer/auth.json:/var/www/.composer/auth.json:cached
    build_as_root:
      - apt-get update -y && apt-get install -y mydumper
    composer_version: 2.6.0
  # Spin up a Solr container called "search".
  # Set "search" instead of "localhost"
  # on the Drupal search api solr server configuration.
  search:
    # Use a specific Solr version.
    type: solr:8
    # Optionally declare the name of the Solr core.
    # This setting is only applicable for versions 5.5 and above.
    core: drupal
    portforward: true
    # This should be the directory containing the schema.xml and solrconfig.xml files.
    # Download the config.zip and extract it.
    overrides:
      environment:
        SOLR_HEAP: "2048m"
    config:
      dir: solr/uw-solr-conf
  # Node container for frontend operations.
  node:
    type: node:custom
    overrides:
      image: node:20.9
  storybook:
    type: node:custom
    ssl: true
    overrides:
      image: node:20.9
    port: 6006
    command: npm install
  cypress:
    type: compose
    app_mount: delegated
    services:
      image: "cypress/included:12.2.0"
      command: cypress run
  mailhog:
    type: mailhog
    portforward: true
    hogfrom:
      - appserver
  redis:
    type: redis:6
    persist: false
    portforward: false

tooling:
  drush:
    env:
      PHP_MEMORY_LIMIT: 1024M
  reload-local:
    description: Reload your local environment doing a fresh install for testing or development
    env:
      PHP_MEMORY_LIMIT: 3G
    cmd:
      - appserver: composer install
      - appserver: bash scripts/reload_local.sh
      - node: "npm install"
      - node: "npm run assets:build"
      # TODO add drush config to provide well formed url on running `drush uli`
      - appserver: drush uli
  locale-update:
    service: appserver
    description: Check and updates the translations for all languages
    env:
      PHP_MEMORY_LIMIT: 512M
    cmd:
      # Update the translations.
      - drush locale-check
      - drush locale-update
  npm:
    service: node
  npx:
    service: node
  phpcs:
    service: appserver
    description: Run code sniffer to check if code respect codding standard and Drupal best practices.
    cmd:
      - ./vendor/bin/phpcs
  cypress:
    service: cypress
    description: Lando wrapper to run cypress commands
    cmd:
      - cypress
  setup-test:
    service: cypress
    description: Prepares the environment to run cypress tests
    cmd:
      # Enable jsonapi for Cypress BDD E2E testing
      - appserver: drush en -y uw_test
      - appserver: drush cset jsonapi.settings read_only 0 -y
      - appserver: drush user:information jsonapi > /dev/null || drush user:create jsonapi --mail="[email protected]" --password="jsonapi"
      - appserver: drush user-add-role administrator jsonapi
      - appserver: drush sapi-i
      # TODO: Install all tests modules belonging to modules currently installed in the site.
  assets-build:
    service: appserver
    description: Development build of all theme and modules assets.
    cmd:
      - node: "npm run assets:build"
  assets-watch:
    service: appserver
    description: Watch theme and modules files for changes, and rebuild.
    cmd:
      - node: "npm run assets:watch"
  modules-build:
    service: appserver
    description: Development build of modules.
    cmd:
      - node: "npm run modules:build"
  modules-watch:
    service: appserver
    description: Watch module files for changes, and rebuild.
    cmd:
      - node: "npm run modules:watch"
  theme-build:
    service: appserver
    description: Development build of theme.
    cmd:
      - node: "npm run theme:build"
  theme-watch:
    service: appserver
    description: Watch theme files for changes, and rebuild.
    cmd:
      - node: "npm run theme:watch"
  icons-watch:
    service: appserver
    description: Watch icon files for changes, and rebuild.
    cmd:
      - node: "npm run icons:watch"
  icons-build:
    service: appserver
    description: Development build of icons.
    cmd:
      - node: "npm run icons:build"
  icons-drupal-configs:
    service: appserver
    description: Generate drupal configuration files for icons.
    cmd:
      - node: "npm run icons:drupal-configs"
  theme-build-prod:
    service: appserver
    description: Production build of theme.
    cmd:
      - node: npm ci --production --omit=optional
      - node: "npm run theme:build:prod"
  modules-build-prod:
    service: appserver
    description: Production build of theme.
    cmd:
      - node: npm ci --production --omit=optional
      - node: "npm run modules:build:prod"
  assets-build-prod:
    service: appserver
    description: Production build of theme.
    cmd:
      - node: npm ci --production --omit=optional
      - node: "npm run assets:build:prod"
  reset-solr:
    service: appserver
    description: Reset the solr indexed data
    cmd:
      - appserver: drush sapi-sc uw_search_solr_server
      - appserver: "curl 'http://search:8983/solr/drupal/update?commit=true' -H 'Content-Type: text/xml' --data-binary '<delete><query>*:*</query></delete>'"
      - appserver: drush sapi-r
      - appserver: drush sapi-i
  myloader:
    service: appserver
    description: "Import myloader DB"
    args: [arg1]
    cmd: myloader -u drupal10 -p drupal10 -h database -B drupal10 -o -d
  xphp:
    service: appserver
    description: Executes PHP with xDebug
    env:
      XDEBUG_CONFIG: 1
    cmd:
      - appserver: php -dxdebug.start_with_request=yes -dxdebug.client_host=172.17.0.1
  storybook:
    service: appserver
    description: Prepares the local environment to run storybook and launches it.
    cmd:
      # On local, twig debug and cache should already have been disabled via
      # local.services.yml, but we insist here in case we are on a different env.
      # This is the same as render-cache-enable but saldy we can't make a lando
      # command extend/invoke another: https://github.com/lando/core-next/issues/31
      - echo "—⇾ Disabling Drupal render caches. We advise to run 'lando render-cache-enable' after finishing development."
      - drush state:set twig_debug 0
      - drush state:set twig_cache_disable 0
      - drush state:set disable_rendered_output_cache_bins 0
      - echo "—⇾ Generating Storybook stories"
      - drush --uri https://${LANDO_APP_NAME}.lndo.site/ storybook:generate-all-stories --force
      - echo "—⇾ Cache clear"
      - drush cr
      - echo "—⇾ You can now access https://storybook.${LANDO_APP_NAME}.lndo.site/ and browse the component library"
      - echo "—⇾ Got any problem? Check the FAQs! https://wiki.un.org/display/UW2/Local+development+with+Storybook"
  storybook-stories:
    service: appserver
    description: Generate storybook stories.
    cmd:
      - drush --uri https://${LANDO_APP_NAME}.lndo.site/ storybook:generate-all-stories --force
      - echo "—⇾ You can now access https://storybook.${LANDO_APP_NAME}.lndo.site/ and see your changes"
      - echo "—⇾ Got any problem? Check the FAQs! https://wiki.un.org/display/UW2/Local+development+with+Storybook"
  render-cache-enable:
    service: appserver
    description:
      Enables the twig and render-related cache. It is advised to always
      develop with cache and only disable it for specific tasks (testing, debugging)
    cmd:
      - appserver: drush state:set twig_debug 0
      - appserver: drush state:set twig_cache_disable 0
      - appserver: drush state:set disable_rendered_output_cache_bins 0
  render-cache-disable:
    service: appserver
    description:
      Disables the twig and render-related cache. It is advised to always
      develop with cache and only disable it for specific tasks (testing, debugging)
    cmd:
      - appserver: drush state:set twig_debug 1
      - appserver: drush state:set twig_cache_disable 1
      - appserver: drush state:set disable_rendered_output_cache_bins 1
      - appserver: echo "Remember to enable the cache after you are done with your task. Run 'lando render-cache-enable' to do so."

events:
  pre-start:
    - appserver: test -e /app/.env || cp /app/.env.default /app/.env

Here is the output of lando info

[ { service: 'appserver',
    urls:
     [ 'https://localhost:32856',
       'http://localhost:32857',
       'http://sitename.lndo.site/',
       'https://sitename.lndo.site/' ],
    type: 'drupal-php',
    healthy: 'unknown',
    via: 'apache',
    webroot: 'web',
    config: { php: '.lando/php.ini' },
    version: '8.2',
    meUser: 'www-data',
    hasCerts: true,
    api: 3,
    hostnames: [ 'appserver.sitename.internal' ] },
  { service: 'database',
    urls: [],
    type: 'drupal-mysql',
    healthy: true,
    internal_connection: { host: 'database', port: '3306' },
    external_connection: { host: '127.0.0.1', port: '32858' },
    healthcheck:
     'mysql --host=database --user=drupal10 --database=drupal10 --password=drupal10 --silent --execute "SHOW TABLES;"',
    creds: { database: 'drupal10', password: 'drupal10', user: 'drupal10' },
    config: { database: '.lando/my-custom.cnf' },
    version: '8.0',
    meUser: 'www-data',
    hasCerts: false,
    api: 3,
    hostnames: [ 'database.sitename.internal' ] },
  { service: 'search',
    urls: [ 'http://localhost:32861', 'http://search.sitename.lndo.site/' ],
    type: 'solr',
    healthy: true,
    core: 'drupal',
    internal_connection: { host: 'search', port: '8983' },
    external_connection: { host: '127.0.0.1', port: '32861' },
    healthcheck: 'curl http://localhost:8983/solr/drupal/admin/ping',
    config: { dir: 'solr/uw-solr-conf' },
    version: '8',
    meUser: 'solr',
    hasCerts: false,
    api: 3,
    hostnames: [ 'search.sitename.internal' ] },
  { service: 'node',
    urls: [],
    type: 'node',
    healthy: 'unknown',
    config: {},
    version: 'custom',
    meUser: 'node',
    hasCerts: false,
    api: 3,
    hostnames: [ 'node.sitename.internal' ] },
  { service: 'storybook',
    urls:
     [ 'https://localhost:32788',
       'http://localhost:32787',
       'http://storybook.sitename.lndo.site/',
       'https://storybook.sitename.lndo.site/' ],
    type: 'node',
    healthy: 'unknown',
    config: {},
    version: 'custom',
    meUser: 'node',
    hasCerts: true,
    api: 3,
    hostnames: [ 'storybook.sitename.internal' ] },
  { service: 'cypress',
    urls: [],
    type: 'compose',
    healthy: 'unknown',
    config: {},
    version: 'custom',
    meUser: 'www-data',
    hasCerts: false,
    api: 3,
    hostnames: [ 'cypress.sitename.internal' ] },
  { service: 'mailhog',
    urls: [ 'http://localhost:32860', 'http://mailhog.sitename.lndo.site/' ],
    type: 'mailhog',
    healthy: 'unknown',
    hogfrom: [ 'appserver' ],
    internal_connection: { host: 'mailhog', port: '1025' },
    external_connection: { host: '127.0.0.1', port: '32859' },
    config: {},
    version: 'v1.0.1',
    meUser: 'mailhog',
    hasCerts: false,
    api: 3,
    hostnames: [ 'mailhog.sitename.internal' ] },
  { service: 'redis',
    urls: [],
    type: 'redis',
    healthy: 'unknown',
    internal_connection: { host: 'redis', port: '6379' },
    external_connection: { host: '127.0.0.1', port: false },
    config: {},
    version: '6',
    meUser: 'www-data',
    hasCerts: false,
    api: 3,
    hostnames: [ 'redis.sitename.internal' ] } ]

Greatly appreciate your feedback @AaronFeledy

@AaronFeledy
Copy link
Member

AaronFeledy commented Oct 8, 2024

Okay, I think this is a bug related to Lando's PHP service plugin, which is a dependency of the Drupal recipe. The expected result here is that your proxy config would override the default one. I tested several recipes and when the PHP service is in use, it seems to try to add a new entry to the proxy config rather than merge in your overrides. The only workaround that comes to mind is to use an alternate URL for the time being.

@AaronFeledy
Copy link
Member

AaronFeledy commented Oct 8, 2024

Some dev notes from my troubleshooting:

Any recipe I tried that has PHP has the issue described, but the MEAN recipe, with a similar appserver setup but no PHP service does not experience this issue. Replacing the PHP service in LAMP with another causes the error to go away.

This has the issue:

name: sitename
recipe: lamp
proxy:
  appserver:
    - hostname: sitename.lndo.site
      middlewares:
        - name: cors
          key: headers.customresponseheaders.Access-Control-Allow-Origin
          value: "*"

This does not:

name: sitename
recipe: lamp
services:
  appserver:
    type: node
proxy:
  appserver:
    - hostname: sitename.lndo.site
      middlewares:
        - name: cors
          key: headers.customresponseheaders.Access-Control-Allow-Origin
          value: "*"

@AaronFeledy
Copy link
Member

Actually, it may be related to a change that was recently made to several PHP-based recipe plugins, but not the MEAN recipe.
lando/drupal@7b5737e

@in0ni
Copy link
Author

in0ni commented Oct 8, 2024

Thank you @AaronFeledy, I have shared with colleagues with more lando experience to see if they have any feedback.

@idiazroncero
Copy link

Thank you for your incredibly fast input @AaronFeledy . Much appreciated.

@reynoldsalec
Copy link
Member

Replicated the message using your .lando.yml and confirmed @AaronFeledy's theory. Adding the hostname entry into the proxy settings seems (from my perspective) like it should be an override of the default, but the default URL gets merged in regardless.

I've created a check that can be used on these getProxy functions to not add the default URL if a hostname: [DEFAULTURL] entry exists: https://github.com/lando/drupal/pull/136/files

And this not existing on MEAN is simply an oversight that should be corrected as well.

reynoldsalec referenced this issue in lando/drupal Oct 22, 2024
reynoldsalec referenced this issue in lando/drupal Oct 22, 2024
@rtfm-47 rtfm-47 transferred this issue from lando/lando Oct 22, 2024
@pirog pirog self-assigned this Oct 23, 2024
@pirog
Copy link
Member

pirog commented Oct 23, 2024

i can replicate this. looking for a place we can handle this better in @lando/core.

@pirog
Copy link
Member

pirog commented Oct 24, 2024

Ok i think this should be fixed in our next core release.

pirog added a commit that referenced this issue Oct 24, 2024
pirog added a commit that referenced this issue Oct 24, 2024
#249)

* #246: improve merging of same-service, same-hostname-path proxy configuration

* #246: improve merging of same-service, same-hostname-path proxy configuration part 2

* #246: improve merging of same-service, same-hostname-path proxy configuration part 3

* #246: improve merging of same-service, same-hostname-path proxy configuration part 4

* #246: improve merging of same-service, same-hostname-path proxy configuration part 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants