Giter VIP home page Giter VIP logo

Comments (8)

mildaniel avatar mildaniel commented on June 20, 2024 1

Hi @cford1080, thanks for raising this issue. I was able to reproduce the problem and I've raised a PR #6697 that should hopefully resolve it.

There is another factor here, however, which is how Docker runs SAM CLI inside the container. You need to ensure that it is being run as the main process and that it's not being wrapped by sh. In those cases, the SIGTERM interrupt will never reach the SAM CLI process and there's nothing that SAM CLI can do to handle it. This article goes into more detail.

from aws-sam-cli.

mildaniel avatar mildaniel commented on June 20, 2024 1

We were able to find the root cause. It has to do with the --docker-volume-basedir overriding the file path that the observer watches which happens to be on the host machine instead of inside the container.

I've raised a draft PR which should solve this issue too but the integration tests for this might take me some more time.

from aws-sam-cli.

mildaniel avatar mildaniel commented on June 20, 2024 1

These two commands use the same underlying logic for starting and running containers, including file watching and volume mounting. The PRs I've raised above should address the issue for both start-api and start-lambda commands.

from aws-sam-cli.

cford1080 avatar cford1080 commented on June 20, 2024

@mildaniel
Thanks. I see that addresses the issue of spawned containers not being cleaned up, but what of the issue of warm-containers not working inside of a docker container and producing a FileObserverException?

from aws-sam-cli.

ryanb77 avatar ryanb77 commented on June 20, 2024

When using the warm-containers option to start-api running inside a docker container, it will also fail to resolve http://host.docker.internal and a timeout will result.

Omitting the warm-containers for either EAGER or LAZY resolves the issue.

from aws-sam-cli.

cford1080 avatar cford1080 commented on June 20, 2024

@ryanb77

When using the warm-containers option to start-api running inside a docker container, it will also fail to resolve http://host.docker.internal and a timeout will result.

This is mitigated by adding the extra_hosts directive:

extra_hosts:
    - host.docker.internal:host-gateway

Omitting the warm-containers for either EAGER or LAZY resolves the issue.

I am currently omitting this option, but I wish to use the feature. If you review the Steps to reproduce, you may notice that I have provided 2 workarounds where warm-containers is working (with exception for cleaning up spawned containers), but requires some suboptimal volume mapping. In the provided logs (not using any workaround, where warm-containers is failing), you may also notice the following:

sam-local-1  | 2024-02-13 22:48:13,235 | Resolving code path. Cwd=/home/cford1080/github/sample, CodeUri=./src
sam-local-1  | 2024-02-13 22:48:13,236 | Resolved absolute path to code is /home/cford1080/github/sample/src

I am at a loss as to why this is using the host directories rather than the container's.

from aws-sam-cli.

cford1080 avatar cford1080 commented on June 20, 2024

Thank you, @mildaniel. As I mentioned, this isn't causing any showstopping issues because the option can be left omitted for now, but some testing could be sped up significantly if the container can remain warm throughout.

Does this impact other sam local commands which use these same options? For example, if I open another project which uses start-lambda instead of start-api, would I run into the same issues with the same options, and if so, will the solutions in motion now resolve the issues for these options on all commands, assuming they resolve the issues reported for start-api? Or do the options have different implementations per command that would all need to be addressed individually if issues are present? Hope that all makes sense; I got lost myself along the way and rewrote that a few times.

from aws-sam-cli.

github-actions avatar github-actions commented on June 20, 2024

Patch is released in v1.113.0. Closing

from aws-sam-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.