From 7cf6c9bc39fe709149a24fa521320bc7193605fa Mon Sep 17 00:00:00 2001 From: Alec Reynolds Date: Tue, 22 Oct 2024 10:35:04 -0700 Subject: [PATCH 1/9] #244: Variable for setting the network limit. --- docs/config/networking.md | 6 ++++++ plugins/networking/index.js | 2 +- utils/get-config-defaults.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/config/networking.md b/docs/config/networking.md index b40f0c281..25a836934 100644 --- a/docs/config/networking.md +++ b/docs/config/networking.md @@ -58,3 +58,9 @@ You can also use the environment variable `LANDO_HOST_IP`. ```sh lando exec my-service -- ping "\$LANDO_HOST_IP" -c 3 ``` + +## Network Limits + +By default Docker has a limit of 32 networks. If you're running a large number of sites, you'll see a message `Lando has detected you are at Docker's network limit`, after which Lando will attempt to clean up unused networks to put you below the network limit. + +If you've [modified your Docker daemon](https://discussion.fedoraproject.org/t/increase-limit-of-30-docker-networks-in-a-clean-way/96622/4) to allow more networks, you can set Lando's network limit to a higher number by setting the `networkLimit` variable in [Lando's global config](./global.html). diff --git a/plugins/networking/index.js b/plugins/networking/index.js index 8fd7c51b4..2e8f218a3 100644 --- a/plugins/networking/index.js +++ b/plugins/networking/index.js @@ -10,7 +10,7 @@ const getDockerDesktopBin = require('../../utils/get-docker-desktop-x'); */ const cleanNetworks = lando => lando.engine.getNetworks() .then(networks => { - if (_.size(networks) >= 32) { + if (_.size(networks) >= lando.config.networkLimit) { // Warn user about this action lando.log.warn('Lando has detected you are at Docker\'s network limit!'); lando.log.warn('Give us a moment as we try to make space by cleaning up old networks...'); diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index e30b64e30..cc9b3803b 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -31,6 +31,7 @@ const defaultConfig = options => ({ home: os.homedir(), isArmed: _.includes(['arm64', 'aarch64'], process.arch), logLevel: 'debug', + networkLimit: 32, node: process.version, os: { type: os.type(), From 3f1a0b0142302ee1c4851645435946c38e34964d Mon Sep 17 00:00:00 2001 From: Alec Reynolds <1153738+reynoldsalec@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:38:33 -0800 Subject: [PATCH 2/9] #244: Add test for the networkLimit config var. --- examples/networking/README.md | 7 +++++++ examples/networking/config.yml | 1 + 2 files changed, 8 insertions(+) create mode 100644 examples/networking/config.yml diff --git a/examples/networking/README.md b/examples/networking/README.md index 5b4e507e9..5b639135f 100644 --- a/examples/networking/README.md +++ b/examples/networking/README.md @@ -22,6 +22,10 @@ cp -rf index.php lemp/index.php cp -rf nginx.conf lemp/nginx.conf cp -rf .lando.lemp.yml lemp/.lando.yml cd lemp && lando start + +# Should copy .config.yml to ~/.lando/config.yml +cp config.yml ~/.lando/config.yml +lando --clear ``` ## Verification commands @@ -63,6 +67,9 @@ lando exec appserver_nginx -- curl https://appserver.landolamp.internal # Should even be able to connect to a database in a different app cd lamp lando exec database -- mysql -uroot -h database.landolemp.internal -e "quit" + +# Should see the correct network limit +lando config | grep "networkLimit: 64" ``` ## Destroy tests diff --git a/examples/networking/config.yml b/examples/networking/config.yml new file mode 100644 index 000000000..558339625 --- /dev/null +++ b/examples/networking/config.yml @@ -0,0 +1 @@ +networkLimit: 64 From b38ea0a08de77169cda95e30c1d9840677098698 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Tue, 17 Dec 2024 17:27:07 -0500 Subject: [PATCH 3/9] #297: fixed incorrect -EncodedCommand fallback detection for powershell.exe script execution --- CHANGELOG.md | 5 +++++ utils/run-powershell-script.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c9ab0839..ded551b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245) +* Fixed incorrect `-EncodedCommand` fallback detection for `powershell.exe` script execution [#297](https://github.com/lando/core/issues/297) + +[#297](https://github.com/lando/core/issues/297) + ## v3.23.21 - [December 14, 2024](https://github.com/lando/core/releases/tag/v3.23.21) * Fixed `powershell` scripts from failing when user cannot set `-ExecutionPolicy` to `Bypass` for `Process` scope [#297](https://github.com/lando/core/issues/297) diff --git a/utils/run-powershell-script.js b/utils/run-powershell-script.js index 820ee8977..dfbdb9dd0 100644 --- a/utils/run-powershell-script.js +++ b/utils/run-powershell-script.js @@ -24,9 +24,9 @@ module.exports = (script, args = [], options = {}, stdout = '', stderr = '', car // if encode is not explicitly set then we need to pick a good value if (options.encode === undefined) { - const bargs = ['Set-ExecutionPolicy', '-Scope', 'UserPolicy', '-ExecutionPolicy', 'Bypass']; + const bargs = ['Set-ExecutionPolicy', '-Scope', 'Process', '-ExecutionPolicy', 'Bypass']; const {status} = spawnSync('powershell.exe', bargs, options); - options.encode === status !== 0; + options.encode = status !== 0; } // if encode is true we need to do a bunch of other stuff From a6f1d5c3929d82d24df9443234a2243e391b0588 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Tue, 17 Dec 2024 17:45:13 -0500 Subject: [PATCH 4/9] cl --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ded551b7a..e824dd149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,6 @@ * Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245) * Fixed incorrect `-EncodedCommand` fallback detection for `powershell.exe` script execution [#297](https://github.com/lando/core/issues/297) -[#297](https://github.com/lando/core/issues/297) - ## v3.23.21 - [December 14, 2024](https://github.com/lando/core/releases/tag/v3.23.21) * Fixed `powershell` scripts from failing when user cannot set `-ExecutionPolicy` to `Bypass` for `Process` scope [#297](https://github.com/lando/core/issues/297) From 7fe60464d72eef4b34ccfa5622827328960c83a5 Mon Sep 17 00:00:00 2001 From: rtfm-47 Date: Tue, 17 Dec 2024 23:05:05 +0000 Subject: [PATCH 5/9] release v3.23.22 generated by @lando/prepare-release-action --- CHANGELOG.md | 2 ++ package-lock.json | 2 +- package.json | 2 +- release-aliases/3-STABLE | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e824dd149..1e6f5ec94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22) + * Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245) * Fixed incorrect `-EncodedCommand` fallback detection for `powershell.exe` script execution [#297](https://github.com/lando/core/issues/297) diff --git a/package-lock.json b/package-lock.json index 27386d283..5a5bfa0a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@lando/core", - "version": "3.23.21", + "version": "3.23.22", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index c1c5b7cd3..58a0e4b69 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@lando/core", "description": "The libraries that power all of Lando.", - "version": "3.23.21", + "version": "3.23.22", "author": "Mike Pirog @pirog", "license": "GPL-3.0", "repository": "lando/core", diff --git a/release-aliases/3-STABLE b/release-aliases/3-STABLE index ba4bef1ab..71f6f0f88 100644 --- a/release-aliases/3-STABLE +++ b/release-aliases/3-STABLE @@ -1 +1 @@ -v3.23.21 +v3.23.22 From 20d2ba57d56b680d6f21a5861c8c7b74d621e729 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Tue, 14 Jan 2025 10:33:20 -0500 Subject: [PATCH 6/9] fix bug causing service script loading collisions --- CHANGELOG.md | 2 ++ builders/_lando.js | 23 +++++++++++++++++------ examples/tooling/.lando.yml | 14 ++++++++++++++ examples/tooling/README.md | 4 ++++ examples/tooling/scripts/args.sh | 3 +++ 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 examples/tooling/scripts/args.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6f5ec94..d1ea18609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed bug causing service script loading collisions + ## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22) * Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245) diff --git a/builders/_lando.js b/builders/_lando.js index 8556de70e..e1f21cdf4 100644 --- a/builders/_lando.js +++ b/builders/_lando.js @@ -41,6 +41,7 @@ module.exports = { refreshCerts = false, remoteFiles = {}, scripts = [], + scriptsDir = '', sport = '443', ssl = false, sslExpose = true, @@ -66,16 +67,23 @@ module.exports = { console.error(color.yellow(`${type} version ${version} is a legacy version! We recommend upgrading.`)); } + // normalize scripts dir if needed + if (!path.isAbsolute(scriptsDir)) scriptsDir = path.resolve(root, scriptsDir); + + // Get some basic locations + const globalScriptsDir = path.join(userConfRoot, 'scripts'); + const serviceScriptsDir = path.join(userConfRoot, 'helpers', project, type, name); + const entrypointScript = path.join(globalScriptsDir, 'lando-entrypoint.sh'); + const addCertsScript = path.join(globalScriptsDir, 'add-cert.sh'); + const refreshCertsScript = path.join(globalScriptsDir, 'refresh-certs.sh'); + // Move our config into the userconfroot if we have some // NOTE: we need to do this because on macOS and Windows not all host files // are shared into the docker vm if (fs.existsSync(confSrc)) require('../utils/move-config')(confSrc, confDest); - // Get some basic locations - const scriptsDir = path.join(userConfRoot, 'scripts'); - const entrypointScript = path.join(scriptsDir, 'lando-entrypoint.sh'); - const addCertsScript = path.join(scriptsDir, 'add-cert.sh'); - const refreshCertsScript = path.join(scriptsDir, 'refresh-certs.sh'); + // ditto for service helpers + if (fs.existsSync(scriptsDir)) require('../utils/move-config')(scriptsDir, serviceScriptsDir); // Handle Environment const environment = { @@ -94,11 +102,14 @@ module.exports = { // Handle volumes const volumes = [ `${userConfRoot}:/lando:cached`, - `${scriptsDir}:/helpers`, + `${globalScriptsDir}:/helpers`, `${entrypointScript}:/lando-entrypoint.sh`, `${dataHome}:/var/www`, ]; + // add in service helpers if we have them + if (fs.existsSync(serviceScriptsDir)) volumes.push(`${serviceScriptsDir}:/etc/lando/service/helpers`); + // Handle ssl if (ssl) { // also expose the sport diff --git a/examples/tooling/.lando.yml b/examples/tooling/.lando.yml index 66d5d8c74..399f16275 100644 --- a/examples/tooling/.lando.yml +++ b/examples/tooling/.lando.yml @@ -10,6 +10,7 @@ services: api: 3 type: lando meUser: node + scriptsDir: scripts services: image: node:16 command: docker-entrypoint.sh tail -f /dev/null @@ -261,6 +262,19 @@ tooling: arg2: describe: Uses arg2 type: string + sdargs: + cmd: /etc/lando/service/helpers/args.sh + service: node + positionals: + arg1: + describe: Uses arg1 + type: string + choices: + - thing + - stuff + arg2: + describe: Uses arg2 + type: string plugins: "@lando/core": "../.." diff --git a/examples/tooling/README.md b/examples/tooling/README.md index e8991e604..44de5792c 100644 --- a/examples/tooling/README.md +++ b/examples/tooling/README.md @@ -159,6 +159,10 @@ lando everything --help | grep "lando everything \[arg1\] \[arg2\] MORETHINGS" # Should allow for example pasthru in task definition lando everything --help | grep "lando this is just for testing" +# Should be able to access scriptsDir from the landofile +lando exec node -- stat /etc/lando/service/helpers/args.sh +lando sdargs hello there | grep "hello there" + # Should be able to run even if options are empty lando emptyopter diff --git a/examples/tooling/scripts/args.sh b/examples/tooling/scripts/args.sh new file mode 100755 index 000000000..b00e31206 --- /dev/null +++ b/examples/tooling/scripts/args.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "$1 $2" From e3c448eded9be109b768a27a48fb4d7d0c01c70a Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Tue, 14 Jan 2025 10:38:42 -0500 Subject: [PATCH 7/9] todo https://www.drupal.org/community/events --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 554d1debf..1c79b4c45 100644 --- a/netlify.toml +++ b/netlify.toml @@ -20,6 +20,7 @@ "https://docs.google.com/document", "https://docs.google.com/forms", "https://github.com", + "https://www.drupal.org/community/events", "/v/" ] skipPatterns = [ From 5c88ea6234d8e822635294bc523d3b29c4934149 Mon Sep 17 00:00:00 2001 From: rtfm-47 Date: Tue, 14 Jan 2025 16:19:05 +0000 Subject: [PATCH 8/9] release v3.23.23 generated by @lando/prepare-release-action --- CHANGELOG.md | 2 ++ package-lock.json | 2 +- package.json | 2 +- release-aliases/3-STABLE | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1ea18609..e4a3a12c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +## v3.23.23 - [January 14, 2025](https://github.com/lando/core/releases/tag/v3.23.23) + * Fixed bug causing service script loading collisions ## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22) diff --git a/package-lock.json b/package-lock.json index 5a5bfa0a1..b837e2841 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@lando/core", - "version": "3.23.22", + "version": "3.23.23", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 58a0e4b69..1ecbf4448 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@lando/core", "description": "The libraries that power all of Lando.", - "version": "3.23.22", + "version": "3.23.23", "author": "Mike Pirog @pirog", "license": "GPL-3.0", "repository": "lando/core", diff --git a/release-aliases/3-STABLE b/release-aliases/3-STABLE index 71f6f0f88..ca6ec96f5 100644 --- a/release-aliases/3-STABLE +++ b/release-aliases/3-STABLE @@ -1 +1 @@ -v3.23.22 +v3.23.23 From af5b36b5c80b9d8f4f29517d6d25218e995ba055 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Tue, 14 Jan 2025 11:28:43 -0500 Subject: [PATCH 9/9] fix networking test --- examples/networking/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/networking/README.md b/examples/networking/README.md index 4ac9ea182..08b97334b 100644 --- a/examples/networking/README.md +++ b/examples/networking/README.md @@ -22,10 +22,6 @@ cp -rf index.php lemp/index.php cp -rf nginx.conf lemp/nginx.conf cp -rf .lando.lemp.yml lemp/.lando.yml cd lemp && lando start - -# Should copy .config.yml to ~/.lando/config.yml -cp config.yml ~/.lando/config.yml -lando --clear ``` ## Verification commands