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

Unable to Deploy Redis Containers Following Instructions #974

Open
yuta519 opened this issue Feb 5, 2025 · 1 comment
Open

Unable to Deploy Redis Containers Following Instructions #974

yuta519 opened this issue Feb 5, 2025 · 1 comment

Comments

@yuta519
Copy link
Contributor

yuta519 commented Feb 5, 2025

Context

Steps Taken

  • Created the compose.yaml file with the following content:

    services:
      web:
        build: .
        ports:
          - "8000:5000"
      redis:
        image: "redis:alpine"
  • Ran the command: defang compose up --project-name=yutadeploy --provider=aws

Issue Encountered

  • Received the following error:

redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name does not resolve

2025-02-04T18:49:39.424-08:00 web 2c8cfa86f988457eaaf0bf842340dac6 redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name does not resolve.
2025-02-04T18:49:39.518-08:00 web 2c8cfa86f988457eaaf0bf842340dac6 10.0.165.192 - - [05/Feb/2025 02:49:39] "GET / HTTP/1.1" 500 -
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6 Traceback (most recent call last):
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6   File "/usr/local/lib/python3.10/site-packages/redis/connection.py", line 357, in connect
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6     sock = self.retry.call_with_retry(
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6   File "/usr/local/lib/python3.10/site-packages/redis/retry.py", line 62, in call_with_retry
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6     return do()
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6   File "/usr/local/lib/python3.10/site-packages/redis/connection.py", line 358, in <lambda>
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6     lambda: self._connect(), lambda error: self.disconnect(error)
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6   File "/usr/local/lib/python3.10/site-packages/redis/connection.py", line 698, in _connect
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6     for res in socket.getaddrinfo(
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6   File "/usr/local/lib/python3.10/socket.py", line 967, in getaddrinfo
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
2025-02-04T18:49:39.520-08:00 web 2c8cfa86f988457eaaf0bf842340dac6 socket.gaierror: [Errno -2] Name does not resolve

Expected Behavior

  • The Redis container should be accessible from the web service.

Modifications Made

  • Updated compose.yaml with the following changes:

    services:
      web:
        build: .
        networks:
          - default
        ports:
          - "8000:5000"
        depends_on:
          - redis
        environment:
          REDIS_HOST: redis
          REDIS_PORT: 6379
    
      redis:
        image: "redis:6.2"
        x-defang-redis: true
        networks:
          - default
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
          interval: 10s
          timeout: 5s
          retries: 3
    
    networks:
      default:
        driver: bridge
    • Specified Redis version 6.2 instead of alpine.
    • Added networking configurations.
    • Introduced a health check for Redis.

Outcome

  • Although the CLI did not return a successful result, an new ElastiCache instance was successfully created.
Image - After Redis cache instance’s status get “Available”, I ran the defang command again and it worked finally. - This is because Redis cache takes time to be available and web container can’t establish connection during redis bootstrap.

Needed Steps

  • Fix the Redis deployment
    • Need to add some workflow to wait for Redis cache up
  • Fix the document
@yuta519
Copy link
Contributor Author

yuta519 commented Feb 10, 2025

defang compose down waits for termination of the managed service. But it took about 10 mins to be completed.

Starting: /Users/yuta/go/bin/dlv dap --listen=127.0.0.1:56385 --log-dest=3 from /Users/yuta/work/defang/src/cmd/cli
DAP server listening at: 127.0.0.1:56385
Type 'dlv help' for list of commands.
 - Reading access token from file /Users/yuta/.local/state/defang/fabric-prod1.defang.dev
 - Using tenant default for cluster fabric-prod1.defang.dev:443
 - fabricClient /io.defang.v1.FabricController/WhoAmI null
 - fabricClient /io.defang.v1.FabricController/GetVersion null
 - Fabric: v0.6.0-299-ge52e2129 CLI: development CLI-Min: v1.0.0
 - fabricClient /io.defang.v1.FabricController/CheckToS null
 - tracking event "COMPOSE-DOWN INVOKED": [{args []} {err <nil>} {non-interactive true} {provider aws} {CalledAs   down} {version development} {debug true} {provider aws}]
 - fabricClient /io.defang.v1.FabricController/Track {"anon_id":"16f77a06-f29e-464e-b7c2-e1862a6d9c49","event":"COMPOSE-DOWN INVOKED","properties":{"CalledAs":"  down","args":"[]","debug":"true","err":"\u003cnil\u003e","non-interactive":"true","provider":"aws","version":"development"},"os":"darwin","arch":"arm64"}
 * Using AWS provider from command line flag
 - Creating aws provider
name: deploy-to-lab
services:
    redis:
        healthcheck:
            test:
                - CMD
                - redis-cli
                - ping
            timeout: 5s
            interval: 10s
            retries: 3
        image: redis:6.2
        networks:
            default: null
        x-defang-redis: true
    web:
        build:
            context: /Users/yuta/work/deploy-to-lab
            dockerfile: Dockerfile
        depends_on:
            redis:
                condition: service_started
                required: true
        environment:
            REDIS_HOST: redis
            REDIS_PORT: "6379"
        networks:
            default: null
        ports:
            - mode: ingress
              target: 5000
              published: "8000"
              protocol: tcp
networks:
    default:
        name: deploy-to-lab_default
        driver: bridge

 - fabricClient /io.defang.v1.FabricController/CanIUse {"project":"deploy-to-lab","provider":2}
 - Destroying project "deploy-to-lab" []
 - Using CD image: "public.ecr.aws/defang-io/cd:public-v0.6.0-299-ge52e2129@sha256:bd6a9b1aa57263f6d384f2de8f9ac241e347071916019b63b553d8794c6c703a"
Waiting for CloudFormation stack defang-cd to be updated...
 - AWS_REGION=us-west-2 AWS_PROFILE=defang-sandbox DEFANG_MODE=unspecified_mode NPM_CONFIG_UPDATE_NOTIFIER=false DEFANG_DEBUG= PROJECT=deploy-to-lab PULUMI_BACKEND_URL=s3://defang-cd-bucket-ren6kjmnovwj?region=us-west-2&awssdk=v2 NO_COLOR=1 DOMAIN=dummy.domain PULUMI_SKIP_UPDATE_CHECK=true DEFANG_ORG=yuta519 DEFANG_PREFIX=Defang PRIVATE_DOMAIN=deploy-to-lab.internal PULUMI_CONFIG_PASSPHRASE=asdf STACK=beta npm run dev down
 - fabricClient /io.defang.v1.FabricController/PutDeployment {"deployment":{"id":"e17920e2691f46faa93196660130cef9","project":"deploy-to-lab","provider":"aws","provider_account_id":"532501343364","timestamp":{"seconds":1739216441,"nanos":486916000},"action":2}}
 * Deleted services, deployment ID e17920e2691f46faa93196660130cef9
 - Tailing RUN,BUILD logs in project "deploy-to-lab"
 - Tailing task arn:aws:ecs:us-west-2:532501343364:task/defang-cd-Cluster-J7Tr6gUfmrEC/e17920e2691f46faa93196660130cef9
2025-02-10T11:41:50.076-08:00 cd  ** Destroy started for stack beta
2025-02-10T11:41:56.999-08:00 cd  ** Refresh succeeded in 3.0s

 * Done.  -> finished around 11:53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant