nitrictech / nitric

Nitric is a multi-language framework for cloud applications with infrastructure from code.
https://nitric.io
Apache License 2.0
1.16k stars 50 forks source link

CLI failing to connect to provider (nitric/awstf@1.14.0) #692

Open GeraldLoeffler opened 3 weeks ago

GeraldLoeffler commented 3 weeks ago

Feature Request

Suggestion

Support development with the nitric CLI on machines with a network configuration that requires usage of an explicit web proxy. Typically, such a proxy is configured with environment variables HTTP_PROXY, HTTPS_PROXY and no_proxy.

Currently, with Docker Desktop on Apple Silicon in such an environment, nitric up fails with error failed to connect to provider: context deadline exceeded

Value

In corporate setups, explicit web proxies are unfortunately not uncommon. This requires correct configuration of all client machines, including development machines, and all web browsers. Nitric development should just work on a development machine configured like that.

Docker Desktop in itself works without issues in the presence of explicit web proxies.

Alternatives

Podman instead of Docker Desktop might work in such a setting?

Other info

Complete output of nitric up:

nitric up --ci
building project services
service matched 'services/hello.ts', auto-naming this service 'hello-nitric_services-hello'
hello-nitric_services-hello [In Progress]: #0 building with "nitric" instance using docker-container driver
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #1 [internal] load build definition from hello-nitric_services-hello-922928650.dockerfile
hello-nitric_services-hello [In Progress]: #1 transferring dockerfile: 1.87kB done
hello-nitric_services-hello [In Progress]: #1 DONE 0.0s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #2 [auth] docker/dockerfile:pull token for registry-1.docker.io
hello-nitric_services-hello [In Progress]: #2 DONE 0.0s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #3 resolve image config for docker-image://docker.io/docker/dockerfile:1
hello-nitric_services-hello [In Progress]: #3 DONE 1.1s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #4 docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5
hello-nitric_services-hello [In Progress]: #4 resolve docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5 done
hello-nitric_services-hello [In Progress]: #4 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #5 [auth] library/node:pull token for registry-1.docker.io
hello-nitric_services-hello [In Progress]: #5 DONE 0.0s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #6 [internal] load metadata for docker.io/library/node:22.4.1-alpine
hello-nitric_services-hello [In Progress]: #6 DONE 0.7s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #7 [build  1/10] FROM docker.io/library/node:22.4.1-alpine@sha256:ba898e86c2cc720c8cf2ae05f8d2d4697fe0c8ca3e920d6fbf14a6cbf50bb9ca
hello-nitric_services-hello [In Progress]: #7 resolve docker.io/library/node:22.4.1-alpine@sha256:ba898e86c2cc720c8cf2ae05f8d2d4697fe0c8ca3e920d6fbf14a6cbf50bb9ca done
hello-nitric_services-hello [In Progress]: #7 DONE 0.0s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #8 [internal] load build context
hello-nitric_services-hello [In Progress]: #8 transferring context: 636B 0.1s done
hello-nitric_services-hello [In Progress]: #8 DONE 0.1s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #9 [build  7/10] RUN --mount=type=cache,sharing=locked,target=/tmp/.yarn_cache     set -ex &&     yarn install --production --prefer-offline --frozen-lockfile --cache-folder /tmp/.yarn_cache
hello-nitric_services-hello [In Progress]: #9 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #10 [final 2/7] RUN apk update &&     apk add --no-cache ca-certificates &&     update-ca-certificates
hello-nitric_services-hello [In Progress]: #10 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #11 [build  4/10] WORKDIR /usr/app
hello-nitric_services-hello [In Progress]: #11 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #12 [build 10/10] RUN --mount=type=cache,sharing=private,target=/tmp/ncc-cache   ncc build services/hello.ts -o lib/ -e .prisma/client -e @prisma/client -t
hello-nitric_services-hello [In Progress]: #12 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #13 [build  3/10] RUN yarn global add typescript @vercel/ncc
hello-nitric_services-hello [In Progress]: #13 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #14 [final 4/7] COPY . .
hello-nitric_services-hello [In Progress]: #14 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #15 [final 5/7] COPY --from=build /usr/app/node_modules/ ./node_modules/
hello-nitric_services-hello [In Progress]: #15 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #16 [final 6/7] COPY --from=build /usr/app/lib/ ./lib/
hello-nitric_services-hello [In Progress]: #16 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #17 [build  6/10] RUN yarn import || echo ""
hello-nitric_services-hello [In Progress]: #17 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #18 [build  5/10] COPY package.json *.lock *-lock.json ./
hello-nitric_services-hello [In Progress]: #18 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #19 [build  8/10] RUN test -f tsconfig.json || echo "{"compilerOptions":{"esModuleInterop":true,"target":"es2015","moduleResolution":"node"}}" > tsconfig.json
hello-nitric_services-hello [In Progress]: #19 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #20 [build  9/10] COPY . .
hello-nitric_services-hello [In Progress]: #20 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #21 [final 3/7] WORKDIR /usr/app
hello-nitric_services-hello [In Progress]: #21 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #22 [build  2/10] RUN --mount=type=cache,sharing=locked,target=/etc/apk/cache     apk --update-cache add git g++ make py3-pip
hello-nitric_services-hello [In Progress]: #22 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #23 [final 7/7] RUN test -d ./prisma && npx prisma generate || echo "";
hello-nitric_services-hello [In Progress]: #23 CACHED
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #24 exporting to docker image format
hello-nitric_services-hello [In Progress]: #24 exporting layers done
hello-nitric_services-hello [In Progress]: #24 exporting manifest sha256:4647872b3fda9e008b3691e93d4ed99f5a51147c648b746282c33da432c424c5 done
hello-nitric_services-hello [In Progress]: #24 exporting config sha256:a91707cd6e33e6d85067bb3757891b52b600149b007ceb7119f57bab3fe9392d done
hello-nitric_services-hello [In Progress]: #24 sending tarball
hello-nitric_services-hello [In Progress]: #24 sending tarball 0.4s done
hello-nitric_services-hello [In Progress]: #24 DONE 0.4s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]: #25 importing to docker
hello-nitric_services-hello [In Progress]: #25 DONE 0.0s
hello-nitric_services-hello [In Progress]:
hello-nitric_services-hello [In Progress]:  2 warnings found (use docker --debug to expand):
hello-nitric_services-hello [In Progress]:  - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 2)
hello-nitric_services-hello [In Progress]:  - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 31)
hello-nitric_services-hello [Complete]: Build Complete
Deploying aws-terraform stack with provider nitric/awstf@1.14.0
nitric/awstf@1.14.0: Deployment server started on [::]:4000
Error: failed to connect to provider: context deadline exceeded

Versions used:

nitric version
1.54.18

docker --version
Docker version 27.3.1, build ce12230

docker buildx version
github.com/docker/buildx v0.17.1-desktop.1 1a2ee7e8d945b88fdc18f1948da491c2f540dec9
jyecusch commented 2 weeks ago

It looks this error is caused by either the nitric/awstf provider failing to start or the two processes failing to communicate. We may want to add more output to the provider/CLI to show any other details about why it failed.

tjholm commented 2 weeks ago

We've also seen other instances of this issue: https://discord.com/channels/955259353043173427/1285193296850845800/1286319877736628356

@GeraldLoeffler is this failure consistent or intermittent? Its possible there may be a race condition between when we start the provider on your machine and when our CLI tries to connect.

jyecusch commented 2 weeks ago

The context deadline for provider startup was 5 seconds. Given we've seen this issue be intermittent in the past, there is a chance the timeout was too short. Any other issue in the provider, such as a panic, is likely to have printed to the console, so slow startup seems like a likely cause.

I've extended the timeout in the Podman support PR https://github.com/nitrictech/cli/pull/815 so we can see if that helps.

jyecusch commented 2 weeks ago

@GeraldLoeffler would you mind testing this again with v1.55.2 of the CLI?