From 7315cdd864d2722b32ecb633ebc545a1c429bd40 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 22 Jan 2025 12:02:27 -0500 Subject: [PATCH 1/4] #322: comma path test --- examples/c,o,m,m,a/.lando.yml | 23 +++++++++++++++++++++++ examples/c,o,m,m,a/README.md | 35 +++++++++++++++++++++++++++++++++++ examples/c,o,m,m,a/index.html | 1 + 3 files changed, 59 insertions(+) create mode 100644 examples/c,o,m,m,a/.lando.yml create mode 100644 examples/c,o,m,m,a/README.md create mode 100644 examples/c,o,m,m,a/index.html diff --git a/examples/c,o,m,m,a/.lando.yml b/examples/c,o,m,m,a/.lando.yml new file mode 100644 index 000000000..90da2ee06 --- /dev/null +++ b/examples/c,o,m,m,a/.lando.yml @@ -0,0 +1,23 @@ +name: commapp +services: + defaults: + type: lando + services: + image: nginx:1.22.1 + command: /docker-entrypoint.sh nginx -g "daemon off;" + ports: + - 80 + volumes: + - ./:/usr/share/nginx/html:ro + + defaults-v4: + api: 4 + type: l337 + image: nginx:1.22.1 + ports: + - 80 + volumes: + - ./:/usr/share/nginx/html:ro + +plugins: + "@lando/core": "../.." diff --git a/examples/c,o,m,m,a/README.md b/examples/c,o,m,m,a/README.md new file mode 100644 index 000000000..8f037e087 --- /dev/null +++ b/examples/c,o,m,m,a/README.md @@ -0,0 +1,35 @@ +# C,O,M,M,A Example + +This example exists primarily to test the following: + +* [Issue #322](https://github.com/lando/core/issues/322) + +## Start up tests + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +## Verification commands + +Run the following commands to validate things are rolling as they should. + +```bash +# Should serve from the app root by default +lando exec defaults -- curl http://localhost | grep ROOTDIR +lando exec defaults-v4 -- curl http://localhost | grep ROOTDIR +``` + +## Destroy tests + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/c,o,m,m,a/index.html b/examples/c,o,m,m,a/index.html new file mode 100644 index 000000000..83213b29b --- /dev/null +++ b/examples/c,o,m,m,a/index.html @@ -0,0 +1 @@ +ROOTDIR From a4bb7e94e19f10e891c23e3ec35b63208830e3a3 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 22 Jan 2025 12:08:14 -0500 Subject: [PATCH 2/4] #322: comma path test part 2 --- .github/workflows/pr-core-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-core-tests.yml b/.github/workflows/pr-core-tests.yml index 4d0f3edae..0d0811344 100644 --- a/.github/workflows/pr-core-tests.yml +++ b/.github/workflows/pr-core-tests.yml @@ -14,6 +14,7 @@ jobs: leia-test: - badname - build + - c,o,m,m,a - cache - certs - config From 481fce59787f19e211e6f1169e121ed02fcce13f Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 23 Jan 2025 14:07:20 -0500 Subject: [PATCH 3/4] #322: fix bug causing service reaping for apps with commans in their paths --- CHANGELOG.md | 2 ++ app.js | 2 ++ builders/lando-v4.js | 3 +++ examples/lando-v4/.lando.yml | 2 ++ utils/to-lando-container.js | 18 ++++++++++++++++-- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6c6a235..a7a8d6937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed bug where an app’s services were inadvertently reaped if the app’s path included a comma [#322](https://github.com/lando/core/issues/322) + ## v3.23.25 - [January 18, 2025](https://github.com/lando/core/releases/tag/v3.23.25) * Fixed bug causing `--accept-license` flag to not work when installing Docker Desktop on macOS diff --git a/app.js b/app.js index 77965eece..9a93f1217 100644 --- a/app.js +++ b/app.js @@ -240,6 +240,8 @@ module.exports = async (app, lando) => { BITNAMI_DEBUG: 'true', }, labels: { + 'io.lando.landofiles': app.configFiles.map(file => path.basename(file)).join(','), + 'io.lando.root': app.root, 'io.lando.src': app.configFiles.join(','), 'io.lando.http-ports': '80,443', }, diff --git a/builders/lando-v4.js b/builders/lando-v4.js index 80e9c03fc..6f5b42412 100644 --- a/builders/lando-v4.js +++ b/builders/lando-v4.js @@ -443,7 +443,10 @@ module.exports = { const labels = merge({}, app.labels, { 'dev.lando.container': 'TRUE', 'dev.lando.id': lando.config.id, + 'dev.lando.landofiles': app.configFiles.map(file => path.basename(file)).join(','), + 'dev.lando.root': app.root, 'dev.lando.src': app.root, + 'io.lando.http-ports': '80,443', }, config.labels); // add it all 2getha diff --git a/examples/lando-v4/.lando.yml b/examples/lando-v4/.lando.yml index 1aaf725dc..b28213e79 100644 --- a/examples/lando-v4/.lando.yml +++ b/examples/lando-v4/.lando.yml @@ -42,6 +42,8 @@ services: # build # files + # check labels + # appmount # support appMount but prefer app-mount # project-mount: /project how does this work? diff --git a/utils/to-lando-container.js b/utils/to-lando-container.js index 50f95d97d..0c7b54855 100644 --- a/utils/to-lando-container.js +++ b/utils/to-lando-container.js @@ -1,22 +1,36 @@ 'use strict'; -module.exports = ({Labels, Id, Status}, separator = '_') => { +const path = require('path'); + +module.exports = ({Labels, Id, Status}, separator = '_', src = []) => { // Get name of docker container. const app = Labels['com.docker.compose.project']; const service = Labels['com.docker.compose.service']; const num = Labels['com.docker.compose.container-number']; const lando = Labels['io.lando.container']; const special = Labels['io.lando.service-container']; + + // if we have io.lando.root and io.lando. + if (Labels['io.lando.root'] && Labels['io.lando.landofiles']) { + src = Labels['io.lando.landofiles'].split(',').map(landofile => path.join(Labels['io.lando.root'], landofile)); + + // or legacy support for Labels['io.lando.src'] + } else if (Labels['io.lando.src']) { + src = Labels['io.lando.src'].split(','); + + // or its just unknown + } else src = 'unknown'; + // Build generic container. return { id: Id, service: service, name: [app, service, num].join(separator), app: (special !== 'TRUE') ? app : '_global_', - src: (Labels['io.lando.src']) ? Labels['io.lando.src'].split(',') : 'unknown', kind: (special !== 'TRUE') ? 'app' : 'service', lando: (lando === 'TRUE') ? true : false, instance: Labels['io.lando.id'] || 'unknown', status: Status, + src, }; }; From 3fb59e621405a1cb7451c56eb32b5f2d48565ee2 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 23 Jan 2025 14:19:52 -0500 Subject: [PATCH 4/4] update to lando/pkg-action@v6 to avoide deprecation of actions/upload-artifact@v3 deprecation --- .github/workflows/pr-core-tests.yml | 2 +- .github/workflows/pr-docs-tests.yml | 2 +- .github/workflows/pr-setup-linux-tests.yml | 2 +- .github/workflows/pr-setup-macos-tests.yml | 2 +- .github/workflows/pr-setup-windows-tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-core-tests.yml b/.github/workflows/pr-core-tests.yml index 0d0811344..405221f95 100644 --- a/.github/workflows/pr-core-tests.yml +++ b/.github/workflows/pr-core-tests.yml @@ -94,7 +94,7 @@ jobs: - name: Install pkg dependencies run: npm clean-install --prefer-offline --frozen-lockfile --production - name: Package into node binary - uses: lando/pkg-action@v5 + uses: lando/pkg-action@v6 id: pkg-action with: entrypoint: bin/lando diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index 78afe9586..e3dce4b1e 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -66,7 +66,7 @@ jobs: - name: Install pkg dependencies run: npm clean-install --prefer-offline --frozen-lockfile --production - name: Package into node binary - uses: lando/pkg-action@v5 + uses: lando/pkg-action@v6 id: pkg-action with: entrypoint: bin/lando diff --git a/.github/workflows/pr-setup-linux-tests.yml b/.github/workflows/pr-setup-linux-tests.yml index cec2665f7..fa9ec363a 100644 --- a/.github/workflows/pr-setup-linux-tests.yml +++ b/.github/workflows/pr-setup-linux-tests.yml @@ -36,7 +36,7 @@ jobs: - name: Install pkg dependencies run: npm clean-install --prefer-offline --frozen-lockfile --production - name: Package into node binary - uses: lando/pkg-action@v5 + uses: lando/pkg-action@v6 id: pkg-action with: entrypoint: bin/lando diff --git a/.github/workflows/pr-setup-macos-tests.yml b/.github/workflows/pr-setup-macos-tests.yml index 4f2f2c4cc..5ddbe500a 100644 --- a/.github/workflows/pr-setup-macos-tests.yml +++ b/.github/workflows/pr-setup-macos-tests.yml @@ -37,7 +37,7 @@ jobs: - name: Install pkg dependencies run: npm clean-install --prefer-offline --frozen-lockfile --production - name: Package into node binary - uses: lando/pkg-action@v5 + uses: lando/pkg-action@v6 id: pkg-action with: entrypoint: bin/lando diff --git a/.github/workflows/pr-setup-windows-tests.yml b/.github/workflows/pr-setup-windows-tests.yml index fa076c06c..822c89381 100644 --- a/.github/workflows/pr-setup-windows-tests.yml +++ b/.github/workflows/pr-setup-windows-tests.yml @@ -35,7 +35,7 @@ jobs: - name: Install pkg dependencies run: npm clean-install --prefer-offline --frozen-lockfile --production - name: Package into node binary - uses: lando/pkg-action@v5 + uses: lando/pkg-action@v6 id: pkg-action with: entrypoint: bin/lando