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

[BUG] "docker-compose config" consumes huge amounts of memory with broken config #12235

Closed
ahollmann opened this issue Oct 25, 2024 · 4 comments
Assignees
Labels
area/interpolation related with variables interpolation kind/bug

Comments

@ahollmann
Copy link

ahollmann commented Oct 25, 2024

Description

docker-compose config with the following config consumes huge amounts of memory. I had to SIGTERM it with ctrl-c in order not to run out of memory.

The config is obviously broken as services: is missing.

I'm using docker-compose config to verify if the config is correct so it seems to be valid use case.

Version used: Docker Compose version v2.29.7

x-healthcheck: &healthcheck
  healthcheck:
    test: [ "CMD", "wget", "--quiet", "--spider", "--timeout=1", "http://localhost:9000/health/live" ]
    start_period: 20s
    start_interval: 1s
    interval: 30s
    timeout: 2s
    retries: 5


  egress-service:
    <<: *healthcheck

Steps To Reproduce

Create compose.yaml with the input

x-healthcheck: &healthcheck
  healthcheck:
    test: [ "CMD", "wget", "--quiet", "--spider", "--timeout=1", "http://localhost:9000/health/live" ]
    start_period: 20s
    start_interval: 1s
    interval: 30s
    timeout: 2s
    retries: 5


  egress-service:
    <<: *healthcheck

run: docker-compose config

Compose Version

Docker Compose version v2.29.7

Docker Environment

Client: Docker Engine - Community
Version: 27.3.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.7
Path: /usr/libexec/docker/cli-plugins/docker-compose

Anything else?

No response

@idsulik
Copy link
Collaborator

idsulik commented Oct 26, 2024

@ahollmann Hi! I think the reason is the recursive alias. the egress-service is located inside the healthcheck alias and the egress-service uses the healthcheck alias

@ahollmann
Copy link
Author

ahollmann commented Oct 26, 2024

@idsulik Thanks. This seems to be the case.

Thanks for creating the MR.

@jhrotko jhrotko added area/interpolation related with variables interpolation and removed status/0-triage labels Oct 28, 2024
@jhrotko jhrotko closed this as completed Oct 28, 2024
@caseywebdev
Copy link

This fix broke references for services that are prefixed with the name of a preceding service.

docker-compose.yaml

services:
  a: &a
    image: alpine
  a2: *a
$ dc config
cycle detected at path: services.a2

Switch the order and see that since the services.a-test prefix hasn't been seen at the point of services.a, it's fine:

docker-compose.yaml

services:
  a2: &a
    image: alpine
  a: *a
$ dc config
...
services:
  a:
    image: alpine
    networks:
      default: null
  a2:
    image: alpine
    networks:
      default: null
...

The fix I believe would be to check the visited path plus a dot, so that at services.a2. in the example would not match the prefix check for services.a.

@idsulik
Copy link
Collaborator

idsulik commented Oct 29, 2024

@caseywebdev thank you for the details! pushed fix for it compose-spec/compose-go#704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/interpolation related with variables interpolation kind/bug
Projects
None yet
Development

No branches or pull requests

4 participants